ListSpatialReferences
汇总
ListSpatialReferences 函数可列出可用的空间参考名称,以用作 SpatialReference 类的参数。
语法
ListSpatialReferences({wild_card}, {spatial_reference_type})
| 参数 | 说明 | 数据类型 | ||||||
|---|---|---|---|---|---|---|---|---|
|
wild_card |
限制返回的结果。如果未指定某一值,则返回所有值。通配符不区分大小写。
|
* |
||||||
|
spatial_reference_type |
Specifies the spatial reference types that will be listed.
(默认值为 All) |
String |
返回值
| 数据类型 | 说明 |
|---|---|
|
String |
与通配符和空间参考类型匹配的空间参考的列表。 列表中的每项都包含采用正斜线进行分隔的限定信息,有助于限定搜索范围或更好地了解空间参考的用途。 例如,列表中可能包含 另一个示例为 |
代码示例
列出所有地理空间参考。
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)
输出新西兰 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))