Doing Geospatial in Python
With a low barrier to entry and large ecosystem of tools and libraries, Python is the lingua franca for geospatial development. Whether you are doing data acquisition, processing, publishing, integration or analysis, there is no shortage of solid Python tools to assist in your daily workflows.
This workshop will provide an introduction to performing common GIS/geospatial tasks using Python geospatial tools such as OWSLib, Shapely, Fiona/Rasterio, and common geospatial libraries like GDAL, PROJ, pycsw, as well as other tools from the geopython toolchain. Manipulate vector/raster data using Shapely, Fiona and Rasterio. Publish data and metadata to OGC web services using pygeoapi, pygeometa, pycsw, and more. Visualize your data on a map using Jupyter and Folium. Plus a few extras in between!
The workshop is provided using the Jupyter Notebook environment with Python 3.
The workshop uses Jupyter Notebooks. Jupyter is an interactive development environment suitable for documenting and reproducing workflows using live code.
As the installation of all dependencies on all platforms (Windows, Mac, Linux) can be quite involved and complex this workshop provides all components within a Docker Image.
The core requirement is to have Docker and Docker Compose installed on the system. Once you have Docker and Docker Compose installed you will be able to install the workshop without any other dependencies.
Users may optionally install QGIS as a GIS data viewer. QGIS is a multiplatform open source desktop application for geospatial data.
The workshop provides various sample data to illustrate Python geospatial functionality which has been tested to cover the workshop requirements.
Having said this, please feel free to bring your own! Examples:
- data: basically anything that can be read with GDAL
- metadata: ISO, FGDC, Dublin Core or even pygeometa MCF files
Verifying your environment
Ensure Docker is running on your computer, then verify that the
docker-compose commands are working and available:
docker version docker-compose version
curl -O https://codeload.github.com/geopython/geopython-workshop/zip/master unzip master cd geopython-workshop-master/workshop # start the workshop ./geopython-workshop-ctl.sh start # check the URL+token ./geopython-workshop-ctl.sh url # open browser to resulting URL+token # or if on Linux/MacOS, run: # ./geopython-workshop-ctl.sh url | xargs open # stop workshop ./geopython-workshop-ctl.sh stop
If the above
.sh scripts do not work on your system you can execute
docker-compose directly via:
# in dir geopython-workshop-master/workshop docker-compose up -d docker logs geopython-workshop-jupyter # look for URL+Token and Copy/Paste in browser
Docker installed but problems installing/running the workshop? Below some tips:
curl may be on your system it may have problems with SSL (one user noted using OSGeo4W).
In that case you can copy/paste the download URL in your browser and download from there.
The workshop setup involves Docker Volume Mounting.
For Mac OS and Windows installs be sure to enable File/Drive Sharing within Docker Desktop
for the directory where you unzipped the workshop.
Go to the
Preferences/Settings | File Sharing... menu and make settings accordingly.
Running in VirtualBox
You may also run a VirtualBox VM with preferably Ubuntu, install Docker there and run the workshop. Even better if you use Vagrant to provision/manage your VM. You could even unpack the .zip file on your local machine and mount it within the VM, start the workshop there.
In any case, in order to access the services from your local machine, you need to do port mapping from ports within the VM to your local machine in order to access the workshop from your local browser. The following ports need to be mapped from the VirtualBox VM to your local system: 8888 (Jupyter), 5000 (pygeoapi) and 8001 (pycsw) .
You will possibly need to enable firewall access for these ports within your VM. Do this as follows:
sudo ufw allow 8888/tcp sudo ufw allow 5000/tcp sudo ufw allow 8001/tcp
Within VirtualBox menu you can then map these ports to the same ports on your local system, so the workshop is accessed with your local browser via http://127.0.0.1:8888?token=..., http://127.0.0.1:5000 etc.
Cannot Access URL
The workshop should run on http://127.0.0.1:8888?token="token" but in some cases this may not work. In that case you could also try http://0.0.0.0:8888?token="token".
No Docker Installed?
If you somehow were not able to install Docker: there is a Cloud version of the Jupyter-Notebook-part of the workshop via "Jupyter Binder".
With some limits (e.g. no local geo-services, no data publication), you may follow most of the workshop using a remote Docker instance within your browser via "Jupyter Binder". Click on the button below to launch the Workshop Binder Instance. Startup takes a while, be patient...
Additional notes for Binder session:
- session timeout is about 10 mins, if that happens, refreshing the page will not help, you need to start a new session using the button above
A Gitter channel exists for discussion and live support from the developers of the workshop.
Bugs and Issues
All bugs, enhancements and issues can be reported on GitHub.