Hi everyone!
I built a small Python package with the vision of making it easier for cartographic file management in FireWxPy 2.0 (I’ll do a post on here regarding FireWxPy after I release 2.0) and I think others may find this useful to use in their projects.
Client Module
The client module hosts the client functions get_shapefiles() and get_geojson() that download shapefiles/GEOJSON file from a user-defined URL address into a folder locally on your PC.
The user must specify the path and filename and the file is saved to {path}/{filename}.
This client is also helpful for those using shapeography in automated scripts. If the user keeps the optional argument refresh=True - The directory hosting the shapefiles/GEOJSON file will be refreshed as the old files will be deleted and new files downloaded. This can be helpful in automation due to periodic shapefile updates on the server-side as it ensures that the user will always have the most recent and up to date shapefiles/GEOJSON file.
This client supports users on a VPN/PROXY connection.
**Proxy Example**
proxies=None ---> proxies={
'http':'http://your-proxy-address:port',
'https':'http://your-proxy-address:port'
}
shapeography.client.get_shapefiles(url, path, filename, proxies=proxies)
Unzip Module
The unzip module hosts the function that unzips the shapefiles/GEOJSON file if the file(s) need to be unzipped.
In nearly all cases, shapefile components are within a zipfile server-side so needing to unzip is very common.
The function extract_files() unzips the shapefiles/GEOJSON into a user-specified extraction folder that is automatically generated.
Supports the following file extentions: .zip, .gz, .tar, .tar.gz
Geometry Module
The geometry module hosts functions that extract data from these shapefiles/GEOJSON file and make it significantly easier to work with this data in Python.
The current functions are:
cartopy_shapefeature()- Returns a cartopy.shapefeature from the data inside the shapefile/GEOJSON.get_geometries()- Returns a gpd.GeoDataFrame of the geometry data of the shapefile/GEOJSON in the coordinate reference system (CRS) specified by the user. (Default CRS = ‘EPSG:4326’ →ccrs.PlateCarree())geodataframe()- Returns gpd.GeoDataFrame hosting all the data in the shapefile/GEOJSON in the coordinate reference system (CRS) specified by the user. (Default CRS = ‘EPSG:4326’ →ccrs.PlateCarree())
Jupyter Lab Examples
How To Install
Copy and paste either command into your terminal or anaconda prompt:
Install via Anaconda
conda install shapeography
Install via pip
pip install shapeography
How To Update To The Latest Version
Copy and paste either command into your terminal or anaconda prompt:
Update via Anaconda
This is for users who initially installed shapeography through Anaconda
conda update shapeography
Update via pip
This is for users who initially installed shapeography through pip
pip install --upgrade shapeography
Citations
- cartopy: Phil Elson, Elliott Sales de Andrade, Greg Lucas, Ryan May, Richard Hattersley, Ed Campbell, Andrew Dawson, Bill Little, Stephane Raynaud, scmc72, Alan D. Snow, Ruth Comer, Kevin Donkers, Byron Blay, Peter Killick, Nat Wilson, Patrick Peglar, lgolston, lbdreyer, … Chris Havlin. (2023). SciTools/cartopy: v0.22.0 (v0.22.0). Zenodo. SciTools/cartopy: v0.22.0
- geopandas: Kelsey Jordahl, Joris Van den Bossche, Martin Fleischmann, Jacob Wasserman, James McBride, Jeffrey Gerard, … François Leblanc. (2020, July 15). geopandas/geopandas: v0.8.1 (Version v0.8.1). Zenodo. geopandas/geopandas: v0.8.1
- requests: K. Reitz, “Requests: HTTP for Humans”. Available: https://requests.readthedocs.io/.
I hope this finds you well.
Regards,
Eric J. Drewitz


