Topics

supplying SHAPE_RESTORE_SHX=YES to fiona.open


Ricky Teachey
 

Hello: I hope this is the right place to ask a question. I also hope I am not creating this topic twice; I tried emailing main@fiona.groups.io but it did not work.

I am trying to figure out how to open a .shp while without all the other accompanying files. I THINK want to do this because I believe I don't care about the data in those other files. However I'm also a total beginner in usage of shape files so please let me know if I am wrong about what it is I believe.

My belief is that the geometric information- basically, the XY coordinates- of the shapes I intend to plot (using plotly.express.choropleth) and turn into a little app for my own use is contained in the .shp file. These .shp files are being created for me in Autocad by a coworker; they are not actually maps of any kind, just a bunch of shapes, and .shp is a much more convenient way to save them than .dxf.

I understand that most of the time, you will pass shape files around with other files, such as .shx, and Autocad does create these files. However it would be easier to not worry about these other files for my purposes.

It appears it is possible to do what I want to do by supplying the option of SHAPE_RESTORE_SHX=YES to GDAL. However, I'm trying to do this using a python script with fiona, and not using the CLI.

Assuming what I am wanting to do makes some kind of sense, is there a way to supply the SHAPE_RESTORE_SHX=YES directive to fiona.open so that I can open a .shp file without the other files? I tried just doing this:

fiona.open(pathlib.Path(shp), SHAPE_RESTORE_SHX="YES")

But it doesn't seem to work.

details: Python 3.8.1 Windows 10 Fiona 1.8.13 GDAL 3.0.4 Installed using the wheels at Christoph Gohlke's web page