A coding session about an intro to web architecture of web apps for geographic data: this session demonstrates the steps to deploy geo-web services and how to connect clients to the services.
Code snippets are availble in the session-notes.
- Explain the basics software architecture of web-based GIS applications and how do they compare with more generic web-based applications.
- Describe how the Server-Client model is used in web-based GIS applications and common toolchains.
- Implement a simple client to consume Geo-Web services (MWS, WMTS, and WFS) using Jupyter notebooks.
- Do some geeky things with Python and geodata.
Like many web-apps, geo-web apps follow the client-server model. The server exposes data services and the client connects to such services and provides an GUI inteface for the users. Geo Web-map servers implement standads for exposing services. Each service provides certain capabilities that the client can request. The most popular are the following:
- Web Map Service (WMS): for publishing maps as images.
- Web Feature Service (WFS): for publishing maps and attributes of geospatial data. It also provides capabilities to capture user's inputs to create or update data stored by the server.
- Web Map Tile Service (WMTS): for publishing maps or data layers using tiles for more eficient data transfer.
The figure below shows a general sofware architecture of a geo-web app using GeoServer on the server side and a Jupyter Notebooks on the client side. These two component interact via an API exposing WMS, WFS or WMTS.
- Geoserver: a server used for geospatial data. Java based.
- PostgreSQL + PostGIS: A relational database with goespatial capabilites.
- Python
- Jupyter Notebooks via Anaconda, and the following packages:
- ipywidgets, enables widgets in jupyter notebook for dynamic content
- ipyleaflet, enables the display of maps on jupyter notebooks using LeafLet. Leaflet is a JavaScript library for interactive maps.
- Linux Server, to deploy a geo-web server we need a dedicate machine for this task; for example a remote server in a cloud-based platform running Ubuntu Server 18.04. Note that people often use the term 'server' to refer to hardware or software, or the combination of hardware and software.
- Communication with a remote server is done using SSH(Secured Shell). On Linux this is done directly from a Terminal, on Windows, we need an SSH client, for example Bitvise.
- Download Geoserver; mind about the version.
$ wget https://sourceforge.net/projects/geoserver/files/GeoServer/2.18.0/geoserver-2.18.0-bin.zip
- If needed, install
unzip
, and unzip the file the preferred location. Geoserver recommends to use/usr/share/geoserver
$ sudo apt unzip
$ sudo unzip geoserver-2.18.0-bin.zip -d /usr/share/geoserver
- Add the location of GeoServer as an environment variable.
$ echo "export GEOSERVER_HOME=/usr/share/geoserver" >> ~/.profile
. ~/.profile
- Make your user the owner of the
geoserver
directory.
$ sudo chown -R <USER_NAME> /usr/share/geoserver/
- Start GeoServer. Go to
geserver/bin
and execute thestartup.sh
$ cd /usr/share/geoserver/bin
$ sh startup.sh
- In the browser go to
http://localhost:8080/geoserver
More on how to install and use Geoserver at https://docs.geoserver.org/latest/en/user/installation/linux.html
-
Install PostreSQL. Installing and manipulating PostgreSQL required a list of laborious steps, that are well documented around the Internet. For details check this blog-post
-
Installing PostGIS. PostGIS is an extension on top of PostgreSQL which enable handling geospatial data inside ProgreSQL. Again, there's a ton of documentation on several ways to do this, here's a way. Something important to remember is that even when you have installed PostGIS, you have to enable this extension when creating a database explicitly.
We will use jupyter as a friendly environment to build a GIS web-client that will retrieve data from Geoserver. In a real-world situation, you will use web frameworks such as DJango, Flask, ReAct, etc. to build a web client.
- On the Anaconda prompt install the
ipywidgets
andipyleaflet
packages to the base environment.
$ conda install -c conda-forge ipyleaflet ipywidgets
-c
:= channel
- Start Jupyter Notbook, create a new notebook and run the code below to verify that the packages can be loaded into the notebook.
from ipyleaflet import Map, Marker
center = (51.999285, 4.373791)
m = Map(center=center, zoom=14)
marker = Marker(location=center, draggable=True)
m.add_layer(marker)
display(m)
You should see a map appearing before your eyes, if it doesn't, look for help in StackOverflow