[gdal-dev] Unable to use geom.ExportToWkt() in Python ?
Frank Warmerdam
warmerdam at pobox.com
Tue Nov 23 21:31:06 EST 2010
Gregor at HostGIS wrote:
> Hey all. I am using the OGR binding for python, to open a SHP and print
> a geometry's WKT. This works until I try to call geom.ExportToWkt() At
> that time I simply get "Premature end of script headers" Running it from
> the command line I get a segmentation fault.
>
> The code snippet:
>
> driver = ogr.GetDriverByName('ESRI Shapefile')
> datasource = driver.Open(shapefile,0)
> layer = datasource.GetLayer()
> spatialRef = layer.GetSpatialRef()
> firstgeom = layer.GetFeature(0).GetGeometryRef()
> wkt = firstgeom.ExportToWkt()
Gregor,
Geometries do not have the ExportToWkt() method. This is a method on
the ogr.SpatialReference class.
Perhaps try:
wkt = spatialRef.ExportToWkt()
Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush | Geospatial Programmer for Rent
More information about the gdal-dev
mailing list