Skip to content

Instantly share code, notes, and snippets.

@macoj
Created May 25, 2016 14:20
Show Gist options
  • Save macoj/2a1ef331067f465810111963a274ea11 to your computer and use it in GitHub Desktop.
Save macoj/2a1ef331067f465810111963a274ea11 to your computer and use it in GitHub Desktop.
trying to get the projection of a shapefile
from osgeo import ogr, osr
driver = ogr.GetDriverByName('ESRI Shapefile')
dataset = driver.Open(r'tabblock2010_25_pophu.shp')
# from Layer
layer = dataset.GetLayer()
spatialRef = layer.GetSpatialRef()
print spatialRef
# from Geometry
feature = layer.GetNextFeature()
geom = feature.GetGeometryRef()
spatialRef = geom.GetSpatialReference()
print spatialRef
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment