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)
  • Shapefiles have at least three components. .shp without .dbf isn't of much use.
    – Vince
    Feb 18 '21 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.
    – bmalbusca
    Feb 18 '21 at 18:51
  • 1
    What exactly is returned from this request? It should be a zipped file containing a shp, dbf, and shx files. Feb 18 '21 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.
    – bmalbusca
    Feb 18 '21 at 22:51

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.