[FWTools] Fwd: Get projection from shp using GDAL and Python
David Fawcett
david.fawcett at gmail.com
Mon Oct 25 11:58:46 EST 2010
Susana,
I just ran this code on my local machine and it works. It prints the
text representation of the SRS. (I am actually running these Python
modules from OSGEO4W, but it shouldn't really matter.)
from osgeo import ogr,osr
shpPath = "c:/workshop/examples/data/mn_counties.shp"
shapeData = ogr.Open(shpPath)
layer = shapeData.GetLayer()
srsObj = layer.GetSpatialRef()
srsText = srsObj.ExportToWkt()
print srsText
On Mon, Oct 25, 2010 at 11:29 AM, Susana Iraiis Delgado Rodriguez
<susana.delgado_s at utzmg.edu.mx> wrote:
>
>
> ---------- Forwarded message ----------
> From: Susana Iraiis Delgado Rodriguez <susana.delgado_s at utzmg.edu.mx>
> Date: 2010/10/25
> Subject: Re: [FWTools] Get projection from shp using GDAL and Python
> To: David Fawcett <david.fawcett at gmail.com>
>
>
> Thank you David for your help! I tried the code and got the next error:
>
> Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)]
> on
> win32
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import crawler_shp
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "crawler_shp.py", line 85, in <module>
> srsText = srsObj.ExportToWkt()
> AttributeError: 'NoneType' object has no attribute 'ExportToWkt'
>>>>
>
> Any idea?
>
More information about the FWTools
mailing list