GeospatialPython / pyshp

This library reads and writes ESRI Shapefiles in pure Python.
MIT License
1.1k stars 259 forks source link

2.0.dev bbox extent #118

Closed apiszcz closed 6 years ago

apiszcz commented 6 years ago

Creating output shapefile I am noticing one corner of the bbox set to 0.0, 0.0 when there is no data near that location. reviewing the __box call, the final line bbox = [min....) shows correct bbox values, however the next line, self._bbox is returning 0.0, 0.0, .....

so in the final line of __box is part of the issue, self._bbox[0] is 0, should these values be initialized to different values?

This code section changed from version 1.0.

If I set the following in Writer::init i get the correct behavior self._bbox=[180,90,-180,-90]

I am wondering if negative value points are in the test cases?

Testing point,lines,polygons with GDAL all created the proper bounding box. shapefile.py test results do not.

karimbahgat commented 6 years ago

Initiating bbox with 0s was indeed problematic. Instead, initiate with None and explicitly test if the bbox is None or is actually valid. Fixed in 2782be8301eddcca038d3a75546e80cfed719115. Tested that positive, negative, and empty file works with this.