1. Open Python
2. Import OGR module
3. Set data type
4. Open data source
5. Get layers (here we have only one)
And now we can e.g.:
6. Get layer extension
7. Get an object on the layer
8. Get attribute
9. Get object geometry
10. Get coordinates (point in this case).
from osgeo import ogr #2
driver = ogr.GetDriverByName('ESRI Shapefile') #3
dataSource = driver.Open('plik.shp',0) #4
layer = dataSource.GetLayer() #5
layer.GetExtent() #6
feature = layer.GetFeature(0) #7 (pobieramy obiekt pierwszy)
feature.GetField('ID') #8
geometry = feature.GetGeometryRef() #9
geometry.GetX() #10
geometry.GetY() #10
______________________________________________________________
Src: Geoprocessing with Python using Open Source GIS
Src: Geoprocessing with Python using Open Source GIS
Brak komentarzy:
Prześlij komentarz