tarsh / pyshp

Automatically exported from code.google.com/p/pyshp
MIT License
0 stars 0 forks source link

Fail to detect shapetype #47

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This code:
import shapefile
sf = shapefile.Editor('/home/jorge/temp/42MUE250GC_SIR.shp')
shapes = sf.shapes()
for s in shapes:
    print( s.shapeType)
    for p in range(1):#len(s.points)):
        s.points[p][0] = -s.points[p][0]
sf.save('/home/jorge/temp/x.shp')

give all shapetype = 25 and a error:
"  File 
"/usr/local/lib/python2.7/site-packages/pyshp-1.1.4-py2.7.egg/shapefile.py", 
line 687, in __shpRecords
    [f.write(pack("<d", p[3])) for p in s.points]
IndexError: array index out of range
"
But my shapefile have only 2D objects, there is no exists p[2] or p[3]

Another code, using gdal/osgeo that read the same shapefile, give me that most 
objects are POLYGON' and a few are MULTIPOLYGON

What is the expected output? What do you see instead?
Why the two libraries have different results for the geometry type for the same 
file?

What version of the product are you using? On what operating system?
pyshape 1.1.4 and openSUSE 12.2 (x86_64)

Please provide any additional information below.
This code is a simple test. I'm trying to convert a 2D file in a 3D file.
I receive a shapefile of highways and need to add the elevation data to all 
points.

Original issue reported on code.google.com by jorge.de...@labtrans.ufsc.br on 20 Mar 2013 at 9:18

GoogleCodeExporter commented 9 years ago
This issue should be fixed in version 1.2.x.  The Editor still has some bugs. 
Recommended method to edit shapefiles is to use a Reader and copy data to a 
Writer and make edits to Python objects.  See:
http://geospatialpython.com/2013/10/editing-shapefile.html

Original comment by jlawh...@geospatialpython.com on 20 Nov 2013 at 8:49