Geo+Python: A Shallow Dive into GIS Development


Enock Seth Nyamador @enock4seth

Open Source evangelist


CC-BY-SA 4.0

!

Neither GIS nor Python expert

Convincing enough

Lifegaurd is on leave

What?

- GIS Basics

- OSGeo, QGIS, PyQGIS

- OpenStreetMap, etc

- Py projects; GeoNode, etc

Why?

Everything that happens, happens somewhere

PS: Snakes undertand geography.

GIS

  • Geographic Information Systems
  • hardware, software and data capturing, managing, analysing and displaying spatial data
  • use methods for understanding, interpreting, and visualising relationships and patterns of geospatial data

Data Types

- Vector

- Raster

Vector

GeoPackage (gpkg), GeoJSON, PostGIS

  • SHPs

Raster

Geotiffs, DEM, Orthophotos, etc

Cordinate Reference System

Geospatial development tasks - Analysis

- Disaster Risk Management; Accra Floods

- How many hours do we waste in moving from Madina to Accra Central in a trotro?

- Accessbility, connectivity, etc

Data Sources

What kinds of GeoSpatial Data is available?

  • It depends!

Government

  • Local
  • State
  • Federal

Private

  • Energy
  • Technology
  • Transportation

The Crowd

OpenStreetMap

  • Online, Offline, Open Data -- XML
  • osm.org
  • Map the world from scratch
  • Save lives
  • Used by FB, Uber, Humanitarian Response and preparedness [Earthquake, flood, tsunami, etc] (OCHA, Red Cross, UNICEF), Mapbox, etc
  • Try it: OsmAnd OR MAPS.ME

Features (POIs) in OpenStreetMap

<?xml version="1.0" encoding="UTF-8"?>
<osm version="0.6" generator="CGImap 0.7.5 (21114 thorn-02.openstreetmap.org)" copyright="OpenStreetMap and contributors" attribution="http://www.openstreetmap.org/copyright" license="http://opendatacommons.org/licenses/odbl/1-0/">
 <way id="308668766" visible="true" version="14" changeset="72300285" timestamp="2019-07-16T11:27:32Z" user="Michael008" uid="7666560">
  ........
  <tag k="addr:city" v="Accra"/>
  <tag k="amenity" v="university"/>
  <tag k="contact:twitter" v="https://twitter.com/UnivofGhana"/>
  <tag k="contact:website" v="http://ug.edu.gh/"/>
  <tag k="description" v="University of Ghana is the first and largest universitiy and tertiary institution in Ghana."/>
  <tag k="name" v="University of Ghana"/>
  <tag k="opening_hours" v="24/7"/>
  <tag k="operator:type" v="public"/>
  <tag k="project:oif-dfen_carteinnov" v="yes"/>
  <tag k="short_name" v="UG, Legon"/>
  <tag k="source" v="local_knowledge;oif-dfen_carteinnov"/>
  <tag k="source:geometry" v="Bing"/>
  <tag k="start_date" v="1948"/>
  <tag k="wikidata" v="Q2303765"/>
  <tag k="wikipedia" v="en:University of Ghana"/>
 </way>
</osm>

Overpass API

- overpass-turbo.eu/

In [26]:
import requests

overpass_url = "http://overpass-api.de/api/interpreter"
overpass_query = """
    [out:json];
    area["ISO3166-1"="GH"][admin_level=2];
    (
    node["amenity"="school"](area);
    );
    out count;"""
response = requests.get(overpass_url, params={'data': overpass_query})
response.json()
Out[26]:
{'version': 0.6,
 'generator': 'Overpass API 0.7.55.7 8b86ff77',
 'osm3s': {'timestamp_osm_base': '2019-08-09T01:39:03Z',
  'timestamp_areas_base': '2019-08-09T00:37:02Z',
  'copyright': 'The data included in this document is from www.openstreetmap.org. The data is made available under ODbL.'},
 'elements': [{'type': 'count',
   'id': 0,
   'tags': {'nodes': '1425',
    'ways': '0',
    'relations': '0',
    'areas': '0',
    'total': '1425'}}]}
In [27]:
import osmnx as ox
import matplotlib.pyplot as plt
%matplotlib inline

# Specify the name that is used to seach for the data
place_name = "University of Ghana, Accra, Ghana"

# Fetch OSM street network from the location
graph = ox.graph_from_place(place_name)
type(graph)

# Plot the streets
fig, ax = ox.plot_graph(graph)

OSM in Africa

TL;DR

- 2019.stateofthemap.africa | 22-24 November 2019 | Grand-Bassam, Côte d'Ivoire

Ghana

GIS Applications

FOSS4G: OSGeo - QGIS, GDAL, GRASS, etc

  • Your Open Source geospatial compass

$$$: ESRI - ArcGIS

QGIS

  • the user friendly Open Source Geographic Information System
  • qgis.org
  • Python plugins

Tweet by @klaskarlsson

GeoNode

  • A web-based application and platform for developing geospatial information systems (GIS) and for deploying spatial data infrastructures (SDI).
  • Django
  • http://geonode.org/

Contributors

  • World Bank
  • GeoSoulutions
  • Terranodo
  • Boundless
  • .......

Some libraries

Reading and writing geospatial data

  • GDAL/OGR

Dealing with Projections

  • pyproj

Analysing and manipulating geospatial data

  • shapely

Visualalizing geospatial data

  • mapnik

- GIS is fun !

- There are many python geospatial libraries

- Python loves Geo and vice versa

- Geo Data Science

- Taking over !

- Go out, get XYZ. Create accessible Open Data :)

- No rocket science

Community of Practice

- *cons, Wikimania, PyCon, SOTM, FOSS4G, etc...

- Linux User Groups - Linux Accra, etc