6
我正在尋找一種方法來獲取具有200個國家/地區的功能集的現有ESRI Shapefile。每個國家/地區特徵都具有「NAME」屬性。我的目標是創建一個Python腳本,添加一個任意的(現在)附加屬性,比如說「POPULATION」。使用Python將自定義要素屬性添加到ESRI Shapefile
當然,我安裝了OSGeo和GeoDjango模塊。我儘可能:
from osgeo import ogr
infile = ogr.Open('sample.shp', 1) #'sample.shp' is a pre-existing ESRI shapefile described above
inlyr = infile.GetLayerByIndex(0)
我是否缺少一個OGR函數,允許我將Feature屬性字段插入到現有的Shapefile中?
非常感謝你。 – mattdeboard 2010-11-23 17:39:23
然後在這之後我需要調用Destroy()來寫入數據嗎? – mattdeboard 2010-11-23 18:07:16
要關閉文件,建議使用'infile = None' – 2011-03-20 23:02:23