Saturday 2 June 2018

python - Writing shapefile with projection defined crashes fiona


I've just started trying to use Fiona to write out shapefiles. I found the example code below, which seems to work fine



from shapely.geometry import mapping, Polygon
import fiona

# Here's an example Shapely geometry
poly = Polygon([(0, 0), (0, 1), (1, 1), (0, 0)])

# Define a polygon feature geometry with one attribute
schema = {
'geometry': 'Polygon',
'properties': {'id': 'int'},

}

# Write a new Shapefile
with fiona.open('my_shp2.shp', 'w', 'ESRI Shapefile', schema) as c:
## If there are multiple geometries, put the "for" loop here
c.write({
'geometry': mapping(poly),
'properties': {'id': 123},
})


However, if I alter this to define a projection for the output shapefile, by changing the open call to:


from fiona.crs import from_epsg
with fiona.open('my_shp2.shp', 'w', 'ESRI Shapefile', schema, crs=from_epsg(3405)) as c:

then Python hangs for a while, and then crashes with the following error:


Python(12985,0x7fff72746180) malloc: *** error for object 0x7fce4aa2c930: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
[IPythonQtConsoleApp] WARNING | kernel restarted

Does anyone have any idea what's going on here? Am I doing something crazy, is my computer misconfigured somehow, or is this a bug?



I'm running this on OS X 10.8.5, and I've been using GDAL/OGR on this machine for a long time with no problems. The full stack trace, in case that helps, is available here.




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...