0

I'm trying to receive a simple .shp file, without been zipped, via web request and convert it to a geopandas dataframe. I tried to use io.BytesIO to wrap the file but also didn't worked.. I tried to load directly to geopandas but this is what happened:

File "fiona/_shim.pyx", line 81, in fiona._shim.gdal_open_vector fiona.errors.DriverError: '/vsimem/9ead9a26f6de48e987cc6474e377012b/9ead9a26f6de48e987cc6474e377012b' not recognized as a supported file format. 

The code:

import geopandas as gpd ... file = request.files[filename] if file and allowed_file(filename): geo2 = gpd.read_file(file) print(geo2) 
4
  • Shapefiles have at least three components. .shp without .dbf isn't of much use. Commented Feb 18, 2021 at 18:36
  • @Vince thank you for your answering but I trying to replicate the same as I have where I'm reading the file locally and then converting to geoJSON. Commented Feb 18, 2021 at 18:51
  • 1
    What exactly is returned from this request? It should be a zipped file containing a shp, dbf, and shx files. Commented Feb 18, 2021 at 20:45
  • Only a .shp. Thank you @LeonPowałka, Since the geopandas.read_file() only requires the path for the .shp I thought was not necessary the corresponding dbf and shx files. Commented Feb 18, 2021 at 22:51

1 Answer 1

0

Although you only pass the .shp filepath to geopandas.read_file(), geopandas requires the corresponding .dbf and .shx files to exist and determines their paths relative to the .shp.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.