[Community] loads wkt error?

iomeneandrei aborruso at tin.it
Thu Aug 12 17:12:36 EEST 2010

Dear all,
I have written this simple code to read every features of a polygon vector
file, and print the centroid coordinates of each feature.

### the code ###
import os, sys
from osgeo import ogr
from shapely.wkt import dumps, loads


# open nadir2r.shp and get the layer
driver1 = ogr.GetDriverByName('ESRI Shapefile')
quadrati = driver1.Open('nadir2r.shp', 0)
if quadrati is None:
  print 'Could not open nadir2r.shp'
layer_in = quadrati.GetLayer()

# loop through the features in the layer
feature = layer_in.GetNextFeature()

while feature:
	geom = feature.GetGeometryRef()
	#print geom
	print polywkt.centroid

  	feature = layer_in.GetNextFeature()

# close the data source
### the code ###

The process starts without any error but I have this one before the end of
the while loop:
"Traceback (most recent call last):
  File "shapely_error.py", line 21, in <module>
  File "C:\Python26\lib\site-packages\shapely\wkt.py", line 17, in loads
    "Could not create geometry because of errors while reading input."
shapely.geos.ReadingError: Could not create geometry because of errors while
reading input."

What's wrong in my code? 

I'm attaching the vector layer I have used to test my .py code.

Thank you very much,


Andrea Borruso

email: aborruso at tin.it
website: http://blog.spaziogis.it
my 2.0 life: http://aborruso.spaziogis.it
feed: http://feeds2.feedburner.com/Tanto
38° 7' 48" N, 13° 21' 9" E
View this message in context: http://community-gispython-org-community-projects.955323.n3.nabble.com/loads-wkt-error-tp1111154p1111154.html
Sent from the Community -- gispython.org community projects mailing list archive at Nabble.com.

More information about the Community mailing list