ListSpatialReferences

摘要

ListSpatialReferences 函数可列出可用的空间参考名称,以用作 SpatialReference 类的参数。

语法

ListSpatialReferences ({wild_card}, {spatial_reference_type})
参数说明数据类型
wild_card

限制返回的结果。如果未指定某一值,则返回所有值。通配符不区分大小写。

符号说明示例

*

表示零个或多个字符。

Te* 可找到田纳西州和德克萨斯州。

String
spatial_reference_type

Specifies the spatial reference types that will be listed.

  • GCSOnly geographic coordinate systems will be listed.
  • PCSOnly projected coordinate systems will be listed.
  • ALLBoth projected and geographic coordinate systems will be listed. This is the default.

(默认值为 All)

String
返回值
数据类型说明
String

与通配符和空间参考类型匹配的空间参考的列表。 列表中的每项都包含采用正斜线进行分隔的限定信息,有助于限定搜索范围或更好地了解空间参考的用途。

例如,列表中可能包含 'Projected Coordinate Systems/World/Sinusoidal (world)'。 其路径表示此空间参考是正弦曲线,即投影坐标系,旨在用于全局范围。

另一个示例为 'Projected Coordinate Systems/UTM/South America/Corrego Alegre UTM Zone 25S'。 这是一个针对南美洲 UTM 带的 UTM 空间参考。

代码示例

ListSpatialReferences 示例 1

列出所有地理空间参考。

import arcpy

# Get the list of spatial references and print it.
srs = arcpy.ListSpatialReferences(spatial_reference_type="GCS")
for sr_name in srs:
    print(sr_name)
ListSpatialReferences 示例 2

输出新西兰 UTM 带的中央经线和名称。

import arcpy

# Get the list of spatial references
srs = arcpy.ListSpatialReferences("*utm/new zealand*")

# Create a SpatialReference object for each one and print the
# central meridian
for sr_string in srs:
    sr_object = arcpy.SpatialReference(sr_string)
    print("{0.centralMeridian}   {0.name}".format(sr_object))

相关主题