jannelg92 / pyshp

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

OverflowError: Python int too large to convert to C long #35

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Install attached file.
2. Run

from shapefile import Reader
rdr = Reader('brownfield_sites')
for s in rdr.shapes():
   print s.shapeType

What is the expected output? What do you see instead?

Expect to see list of shapeType constants, instead see exception:

Traceback (most recent call last):
  File "LoadGISFeatures.py", line 27, in <module>
    load_file('X:/IT/Florida/brownfield_sites/brownfield_sites')
  File "LoadGISFeatures.py", line 20, in load_file
    for shape in rdr.shapes()[:10]:
  File "C:\Python27\lib\site-packages\pyshp-1.1.4-py2.7.egg\shapefile.py", line
310, in shapes
    shapes.append(self.__shape())
  File "C:\Python27\lib\site-packages\pyshp-1.1.4-py2.7.egg\shapefile.py", line
239, in __shape
    record.parts = _Array('i', unpack("<%si" % nParts, f.read(nParts * 4)))
OverflowError: Python int too large to convert to C long

What version of the product are you using? On what operating system?

v 1.1.4 on Windows 7 w/ Python 2.7

Original issue reported on code.google.com by larrylus...@gmail.com on 27 Apr 2012 at 8:17

Attachments:

GoogleCodeExporter commented 8 years ago
I have the same problem on a Shapefile from SWBD, w004n16f.shp, which can be 
found:
  http://dds.cr.usgs.gov/srtm/version2_1/SWBD/SWBDwest/w004n16f.zip

Original comment by nicolas....@gmail.com on 31 May 2012 at 10:17

GoogleCodeExporter commented 8 years ago
I've been having the same problem. Apparently, there may be gaps between shapes 
in the .shp file (for. example, Quantum GIS doesn't seem to recreate the entire 
.shp file if I cut a line, it just shortens the record, leaving other records 
intact). Only the offsets in the .shx file can be trusted. However, the 
shapes() method assumes that shapes follow one another in the .shp file.

The attached patch (against revision 76) seems to have fixed the problem for me.

Original comment by filip.si...@gmail.com on 18 Jun 2012 at 4:11

Attachments:

GoogleCodeExporter commented 8 years ago
I had the same issue with another shapefile, and confirm that the patch worked 
for me. Thanks.

Original comment by jqu...@cit.ac.ug on 8 Oct 2012 at 11:48

GoogleCodeExporter commented 8 years ago

Original comment by jlawh...@geospatialpython.com on 2 May 2013 at 5:01