Hello,
I was wondering if it was possible to create an "in_memory" or a "memory" feature layer from a downloaded zipped shapefile, without saving that zip file to the disk. I am hoping to download multiple zip files from an ftp site and compile them into one final deliverable with only the final shapefile or feature class being written to disk.
Thanks,
Solved! Go to Solution.
Could you use tempfile.mkdtemp() to make a temporary directory to unzip the shapefile and then clean it up when finished?
Could you use tempfile.mkdtemp() to make a temporary directory to unzip the shapefile and then clean it up when finished?
I was able to get this to work, I ended up using:
with TemporaryDirectory() as TempDownloadLocation:
Download files using TempDownloadLocation
This format so once the code within the "with" statement was done, the temporary folder gets cleaned up automatically.
Thank you!
If you're using ArcGIS Pro 2.8+ you could install geopandas (in a cloned env). You can read from a zipfile URL directly into a geodataframe, append more geodataframes, and then write out to file
import geopandas as gpd
a_url = 'https://github.com/Toblerity/Fiona/raw/master/tests/data/coutwildrnp.zip'
gdf = gpd.read_file(a_url)
another_url = 'https://github.com/Toblerity/Fiona/raw/master/tests/data/coutwildrnp.zip'
gdf.append(gpd.read_file(another_url))
gdf.to_file('test.shp')
Since I will be packaging this into a tool for other users to use, I decided to not go this route. I don't think I can get some non programming folk to install geopandas. Thank you though!