I'm trying to get to a point where I can quickly filter thousands of points in a shapefile. My Django application asks for a zipped shapefile to upload, where the zipped file contains at least the .shp, .shx, and .dbf files. Once in my Django view, the zip file is as follows:
request.FILES['file'] > <InMemoryUploadedFile: test.zip (application/x-zip-compressed)>
type(request.FILES['file']) > <class 'django.core.files.uploadedfile.InMemoryUploadedFile'>
request.FILES['file'].file > <_io.BytesIO object at 0x0000028E29F8FE00>
Assuming Geopandas is the best option for efficient filtering/masking (if I'm wrong, I'm definitely open to suggestions), I'm not sure how to go from current state to a Geopandas DataFrame. When I try to use the read_file() method
import geopandas as gpd
gpd.read_file(request.FILES['file'].file)
I get the following error:
fiona.errors.DriverError: no driver
The geopandas.read_file() docs state:
Either the absolute or relative path to the file or URL to be opened, or any object with a
read()method (such as an open file or StringIO)
I'm not sure how to get what I have into an appropriate format for the read_file() method.
Note: The masking and filtering I'm looking to perform are on attribute data and not the geometry.
zipfile = "zip:///Users/name/Downloads/cb_2017_us_state_500k.zip" states = geopandas.read_file(zipfile)from the official docs - https://geopandas.org/en/stable/docs/user_guide/io.html – user88484 May 24 '22 at 07:49