當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


Python Django SpatialReference.__getitem__用法及代碼示例


本文介紹django.contrib.gis.gdal.SpatialReference.__getitem__的用法。

聲明

__getitem__(target)

如果節點不存在,則返回給定字符串屬性節點的值 None。也可以取一個元組作為參數,(target, child),其中child是WKT中屬性的索引。例如:

>>> wkt = 'GEOGCS["WGS 84", DATUM["WGS_1984, ... AUTHORITY["EPSG","4326"]]')
>>> srs = SpatialReference(wkt) # could also use 'WGS84', or 4326
>>> print(srs['GEOGCS'])
WGS 84
>>> print(srs['DATUM'])
WGS_1984
>>> print(srs['AUTHORITY'])
EPSG
>>> print(srs['AUTHORITY', 1]) # The authority value
4326
>>> print(srs['TOWGS84', 4]) # the fourth value in this wkt
0
>>> print(srs['UNIT|AUTHORITY']) # For the units authority, have to use the pipe symbol.
EPSG
>>> print(srs['UNIT|AUTHORITY', 1]) # The authority value for the units
9122

相關用法


注:本文由純淨天空篩選整理自djangoproject.com大神的英文原創作品 django.contrib.gis.gdal.SpatialReference.__getitem__。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。