SlideShare a Scribd company logo
1 of 44
Handling Geospatial Data
INAFU6513 Lecture 8b
Lab 8: Your 5-7 things:
• Geospatial data
• Geospatial data tools
• Vector map data
• Raster map data
• Geospatial calculations
Geospatial Data
Geospatial Data
o Geographical: related to the Earth’s surface
o Spatial: about space (locations, distances etc)
o Data: yep, this is also data
o Usually handled by Geographical Information Systems (GIS) tools
o …many of which are written in Python…
Printed Maps
Georeferenced satellite and aerial data
Vector Map
Adding features to a vector map
Abstract Schematics
Schematics
Map Projections
Coordinate systems
• WGS84 (GIS)
• OSGB36 (UK)
• ED50 (Nato)
• Etc.
Mapping Tools
Tableau: Symbol Maps
Tableau: Choropleth maps
Geospatial data tools
• Google Maps
• OpenStreetMap
• QGIS
• CartoDB
• ArcGIS
• LeafletJS
• MapBox
Python libraries:
• GDAL toolset
• Shapely
• Fiona
• Basemap
QGIS
QGIS: reading shapefiles
QGIS: Tanzania Wards
QGIS: Looking at the dataset
QGIS: Attribute Table
QGIS: Reading Raster map data
QGIS: Getting Raster Map information
QGIS: Raster map histogram
Vector Map Data
Vector data formats
• Spreadsheet (.csv, .xls)
• Shapefile (.shp)
• Keyhole markup language (.kml, .kmz)
• Geojson and Topojson (.json)
• GPS exchange format (.gpx)
• OSM output files (.osm.bz2)
Shapefiles
• .shp: feature geometry (e.g. your dataset)
• .shx: shape index
• .dbf: shape attributes
• .prj: projection
• .shp.xml: metadata
The GDAL toolset
Example terminal-line tools:
• OGR2OGR: convert between vector formats
• GDALwarp: cookie-cut raster files
• gdal_polygonize: convert raster to vector
Python libraries:
• gdal, ogr2ogr etc
• fiona (“pythonic GDAL”)
Reading shapefiles: the Fiona library
from fiona import collection
with collection('example_data/TZwards/TZwards.shp', 'r') as input:
for f in input:
print(f)
Convert vector file formats: OGR2OGR
From the terminal window:
ogr2ogr f GeoJSON where "ADM0_A3 = 'YEM'" outfile.json
ne_10m_admin_1_states_provinces.shp
Raster Map Data
Why raster data?
Raster Data Formats
• GeoTiff (.tif)
• Jpeg (.jpg)
• NITF
• HTF5
Geotiff features
Reading raster map data with GDAL
import gdal
import numpy as np
dataset = gdal.Open(infile, GA_ReadOnly)
cols = dataset.RasterXSize
rows = dataset.RasterYSize
nbands = dataset.RasterCount
driver = dataset.GetDriver().LongName
geotransform = dataset.GetGeoTransform()
for b in range(1,nbands+1):
band = dataset.GetRasterBand(b)
bandtype = gdal.GetDataTypeName(band.DataType)
banddata = band.ReadAsArray(0,0,band.XSize, band.YSize).astype(np.float)
Raster + Vector: cookie-cut a raster map
From the command line, type
gdalwarp cutline yourshapefile.shp yourgeotiff.tif yourresult.tif
GIS data Calculations
Vector data calculations
• Point location (e.g. lat/long from address)
• Area and area overlap sizes (e.g. overlap between village and protected area)
• Belonging (e.g. finding which district a lat/long is in)
• Straight-line distance between points (e.g. great circles)
• Practical distance and time between points (e.g. using roads)
Geopy: get lat/ longs from addresses
from geopy.geocoders import Nominatim
from geopy.geocoders import GoogleV3
geolocator = Nominatim()
googlocator = GoogleV3()
address = '1600 Pennsylvania Ave NW, Washington, DC'
result = geolocator.geocode(address, timeout=10)
if result is None:
result = googlocator.geocode(address, timeout=10)
if result is None:
latlon = (0.0, 0.0)
else:
latlon = (float(result.latitude), float(result.longitude))
Geopy: Calculate distance
from geopy.distance import vincenty
dist = vincenty(loc1, loc2)
Fiona point-in-polygon: finding “belonging”
import fiona
Import shapely
mapdata = fiona.open(‘map_data/nyc_neighbourhoods_wgs84.shp’, 'r')
for f in mapdata:
props = f['properties']
geom = shapely.geometry.asShape(f['geometry'])
neighs[props['NTACode']] = geom
stationpt = Point(stationlon, stationlat)
for neigh, neighshape in neighs.iteritems():
if neighshape.contains(stationpt):
stationneigh = neigh
Basemap: Map visualisations in Python
%matplotlib inline
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
fig = plt.figure(figsize=(8, 8))
usmap = Basemap(projection='lcc', resolution=None,
width=8000000, height=8000000,lat_0=45, lon_0=-100,)
usmap.etopo(scale=0.5, alpha=0.5)
Exercises
If this interested you…
There’s more in workbooks 8.x

More Related Content

What's hot

Processing Geospatial at Scale at LocationTech
Processing Geospatial at Scale at LocationTechProcessing Geospatial at Scale at LocationTech
Processing Geospatial at Scale at LocationTechRob Emanuele
 
RasterFrames: Enabling Global-Scale Geospatial Machine Learning
RasterFrames: Enabling Global-Scale Geospatial Machine LearningRasterFrames: Enabling Global-Scale Geospatial Machine Learning
RasterFrames: Enabling Global-Scale Geospatial Machine LearningAstraea, Inc.
 
Using Deep Learning to Derive 3D Cities from Satellite Imagery
Using Deep Learning to Derive 3D Cities from Satellite ImageryUsing Deep Learning to Derive 3D Cities from Satellite Imagery
Using Deep Learning to Derive 3D Cities from Satellite ImageryAstraea, Inc.
 
ePOM - Intro to Ocean Data Science - Raster and Vector Data Formats
ePOM - Intro to Ocean Data Science - Raster and Vector Data FormatsePOM - Intro to Ocean Data Science - Raster and Vector Data Formats
ePOM - Intro to Ocean Data Science - Raster and Vector Data FormatsGiuseppe Masetti
 
GIS fundamentals - raster
GIS fundamentals - rasterGIS fundamentals - raster
GIS fundamentals - rasterHans van der Kwast
 
FOSDEM 2015: Distributed Tile Processing with GeoTrellis and Spark
FOSDEM 2015: Distributed Tile Processing with GeoTrellis and SparkFOSDEM 2015: Distributed Tile Processing with GeoTrellis and Spark
FOSDEM 2015: Distributed Tile Processing with GeoTrellis and SparkRob Emanuele
 
EuroPython 2019: GeoSpatial Analysis using Python and JupyterHub
EuroPython 2019: GeoSpatial Analysis using Python and JupyterHubEuroPython 2019: GeoSpatial Analysis using Python and JupyterHub
EuroPython 2019: GeoSpatial Analysis using Python and JupyterHubMartin Christen
 
Plugins in QGIS and its uses
Plugins in QGIS and its usesPlugins in QGIS and its uses
Plugins in QGIS and its usesMayuresh Padalkar
 
Big Data and Geospatial with HPCC Systems
Big Data and Geospatial with HPCC SystemsBig Data and Geospatial with HPCC Systems
Big Data and Geospatial with HPCC SystemsHPCC Systems
 
QGIS training class 3
QGIS training class 3QGIS training class 3
QGIS training class 3Hiroaki Sengoku
 
Building maps for apps in the cloud - a Softlayer Use Case
Building maps for  apps in the cloud - a Softlayer Use CaseBuilding maps for  apps in the cloud - a Softlayer Use Case
Building maps for apps in the cloud - a Softlayer Use CaseTiman Rebel
 
Introduction to Digital Image Processing _ 2014
Introduction to Digital Image Processing _ 2014Introduction to Digital Image Processing _ 2014
Introduction to Digital Image Processing _ 2014Atiqa khan
 
GeoTuple a Framework for Web Based Geo-Analytics with R and PostGIS
GeoTuple a Framework for Web Based Geo-Analytics with R and PostGISGeoTuple a Framework for Web Based Geo-Analytics with R and PostGIS
GeoTuple a Framework for Web Based Geo-Analytics with R and PostGISRoland Hansson
 
Regularised Cross-Modal Hashing (SIGIR'15 Poster)
Regularised Cross-Modal Hashing (SIGIR'15 Poster)Regularised Cross-Modal Hashing (SIGIR'15 Poster)
Regularised Cross-Modal Hashing (SIGIR'15 Poster)Sean Moran
 
Os Racicot
Os RacicotOs Racicot
Os Racicotoscon2007
 
Introduction of open source gis
Introduction of open source gisIntroduction of open source gis
Introduction of open source gisHiroaki Sengoku
 
Amin tayyebi: Big Data and Land Use Change Science
Amin tayyebi: Big Data and Land Use Change ScienceAmin tayyebi: Big Data and Land Use Change Science
Amin tayyebi: Big Data and Land Use Change Scienceknowdiff
 

What's hot (20)

Processing Geospatial at Scale at LocationTech
Processing Geospatial at Scale at LocationTechProcessing Geospatial at Scale at LocationTech
Processing Geospatial at Scale at LocationTech
 
RasterFrames: Enabling Global-Scale Geospatial Machine Learning
RasterFrames: Enabling Global-Scale Geospatial Machine LearningRasterFrames: Enabling Global-Scale Geospatial Machine Learning
RasterFrames: Enabling Global-Scale Geospatial Machine Learning
 
Using Deep Learning to Derive 3D Cities from Satellite Imagery
Using Deep Learning to Derive 3D Cities from Satellite ImageryUsing Deep Learning to Derive 3D Cities from Satellite Imagery
Using Deep Learning to Derive 3D Cities from Satellite Imagery
 
ePOM - Intro to Ocean Data Science - Raster and Vector Data Formats
ePOM - Intro to Ocean Data Science - Raster and Vector Data FormatsePOM - Intro to Ocean Data Science - Raster and Vector Data Formats
ePOM - Intro to Ocean Data Science - Raster and Vector Data Formats
 
GIS fundamentals - raster
GIS fundamentals - rasterGIS fundamentals - raster
GIS fundamentals - raster
 
FOSDEM 2015: Distributed Tile Processing with GeoTrellis and Spark
FOSDEM 2015: Distributed Tile Processing with GeoTrellis and SparkFOSDEM 2015: Distributed Tile Processing with GeoTrellis and Spark
FOSDEM 2015: Distributed Tile Processing with GeoTrellis and Spark
 
EuroPython 2019: GeoSpatial Analysis using Python and JupyterHub
EuroPython 2019: GeoSpatial Analysis using Python and JupyterHubEuroPython 2019: GeoSpatial Analysis using Python and JupyterHub
EuroPython 2019: GeoSpatial Analysis using Python and JupyterHub
 
GIS
GISGIS
GIS
 
Plugins in QGIS and its uses
Plugins in QGIS and its usesPlugins in QGIS and its uses
Plugins in QGIS and its uses
 
Big Data and Geospatial with HPCC Systems
Big Data and Geospatial with HPCC SystemsBig Data and Geospatial with HPCC Systems
Big Data and Geospatial with HPCC Systems
 
QGIS training class 3
QGIS training class 3QGIS training class 3
QGIS training class 3
 
Building maps for apps in the cloud - a Softlayer Use Case
Building maps for  apps in the cloud - a Softlayer Use CaseBuilding maps for  apps in the cloud - a Softlayer Use Case
Building maps for apps in the cloud - a Softlayer Use Case
 
Introduction to Digital Image Processing _ 2014
Introduction to Digital Image Processing _ 2014Introduction to Digital Image Processing _ 2014
Introduction to Digital Image Processing _ 2014
 
GeoTuple a Framework for Web Based Geo-Analytics with R and PostGIS
GeoTuple a Framework for Web Based Geo-Analytics with R and PostGISGeoTuple a Framework for Web Based Geo-Analytics with R and PostGIS
GeoTuple a Framework for Web Based Geo-Analytics with R and PostGIS
 
Diaz Collect Earth remote sensing activity data Nov 10 2014
Diaz Collect Earth remote sensing activity data Nov 10 2014Diaz Collect Earth remote sensing activity data Nov 10 2014
Diaz Collect Earth remote sensing activity data Nov 10 2014
 
QGIS - Free alternative to ArcMap
QGIS - Free alternative to ArcMapQGIS - Free alternative to ArcMap
QGIS - Free alternative to ArcMap
 
Regularised Cross-Modal Hashing (SIGIR'15 Poster)
Regularised Cross-Modal Hashing (SIGIR'15 Poster)Regularised Cross-Modal Hashing (SIGIR'15 Poster)
Regularised Cross-Modal Hashing (SIGIR'15 Poster)
 
Os Racicot
Os RacicotOs Racicot
Os Racicot
 
Introduction of open source gis
Introduction of open source gisIntroduction of open source gis
Introduction of open source gis
 
Amin tayyebi: Big Data and Land Use Change Science
Amin tayyebi: Big Data and Land Use Change ScienceAmin tayyebi: Big Data and Land Use Change Science
Amin tayyebi: Big Data and Land Use Change Science
 

Similar to Session 08 geospatial data

LS1.pptx
LS1.pptxLS1.pptx
LS1.pptxAbishekR29
 
Gis fandamentals -1
Gis fandamentals -1Gis fandamentals -1
Gis fandamentals -1RJRANJEET1
 
gislec1.ppt
gislec1.pptgislec1.ppt
gislec1.pptfelip19
 
Introduction to Geographic Information Systems (GIS).pptx
Introduction to Geographic Information Systems (GIS).pptxIntroduction to Geographic Information Systems (GIS).pptx
Introduction to Geographic Information Systems (GIS).pptxUniversity of Colombo
 
Introduction to arc gis
Introduction to arc gisIntroduction to arc gis
Introduction to arc gisMohamed Hamed
 
Gis and Ruby 101 at Ruby Conf Kenya 2017 by Kamal Ogudah
Gis and Ruby 101 at Ruby Conf Kenya 2017 by Kamal OgudahGis and Ruby 101 at Ruby Conf Kenya 2017 by Kamal Ogudah
Gis and Ruby 101 at Ruby Conf Kenya 2017 by Kamal OgudahMichael Kimathi
 
What is Geography Information Systems (GIS)
What is Geography Information Systems (GIS)What is Geography Information Systems (GIS)
What is Geography Information Systems (GIS)John Lanser
 
Getting started with GIS
Getting started with GISGetting started with GIS
Getting started with GISEsri India
 
Introduction and Application of GIS
Introduction and Application of GISIntroduction and Application of GIS
Introduction and Application of GISSatish Taji
 
Play with Vector and Make Map
Play with Vector and Make MapPlay with Vector and Make Map
Play with Vector and Make MapNopphawanTamkuan
 
Geographic Information System unit 1
Geographic Information System   unit 1Geographic Information System   unit 1
Geographic Information System unit 1sridevi5983
 
Fundamentals of GIS
Fundamentals of GISFundamentals of GIS
Fundamentals of GISRajalakshmiS34
 
Exploratory Analysis Part1 Coursera DataScience Specialisation
Exploratory Analysis Part1 Coursera DataScience SpecialisationExploratory Analysis Part1 Coursera DataScience Specialisation
Exploratory Analysis Part1 Coursera DataScience SpecialisationWesley Goi
 
Geographic information system(GIS) and its applications in agriculture
Geographic information system(GIS) and its applications in agricultureGeographic information system(GIS) and its applications in agriculture
Geographic information system(GIS) and its applications in agricultureKiranmai nalla
 
MODS_Training_January_2015.pptx
MODS_Training_January_2015.pptxMODS_Training_January_2015.pptx
MODS_Training_January_2015.pptxSMFORHADTASFI
 

Similar to Session 08 geospatial data (20)

Gislec1
Gislec1Gislec1
Gislec1
 
LS1.pptx
LS1.pptxLS1.pptx
LS1.pptx
 
Gis fandamentals -1
Gis fandamentals -1Gis fandamentals -1
Gis fandamentals -1
 
gislec1.ppt
gislec1.pptgislec1.ppt
gislec1.ppt
 
Introduction to Geographic Information Systems (GIS).pptx
Introduction to Geographic Information Systems (GIS).pptxIntroduction to Geographic Information Systems (GIS).pptx
Introduction to Geographic Information Systems (GIS).pptx
 
Introduction to arc gis
Introduction to arc gisIntroduction to arc gis
Introduction to arc gis
 
Data_Sources
Data_SourcesData_Sources
Data_Sources
 
Gis and Ruby 101 at Ruby Conf Kenya 2017 by Kamal Ogudah
Gis and Ruby 101 at Ruby Conf Kenya 2017 by Kamal OgudahGis and Ruby 101 at Ruby Conf Kenya 2017 by Kamal Ogudah
Gis and Ruby 101 at Ruby Conf Kenya 2017 by Kamal Ogudah
 
What is Geography Information Systems (GIS)
What is Geography Information Systems (GIS)What is Geography Information Systems (GIS)
What is Geography Information Systems (GIS)
 
Getting started with GIS
Getting started with GISGetting started with GIS
Getting started with GIS
 
Introduction and Application of GIS
Introduction and Application of GISIntroduction and Application of GIS
Introduction and Application of GIS
 
Play with Vector and Make Map
Play with Vector and Make MapPlay with Vector and Make Map
Play with Vector and Make Map
 
Geographic Information System unit 1
Geographic Information System   unit 1Geographic Information System   unit 1
Geographic Information System unit 1
 
Fundamentals of GIS
Fundamentals of GISFundamentals of GIS
Fundamentals of GIS
 
Exploratory Analysis Part1 Coursera DataScience Specialisation
Exploratory Analysis Part1 Coursera DataScience SpecialisationExploratory Analysis Part1 Coursera DataScience Specialisation
Exploratory Analysis Part1 Coursera DataScience Specialisation
 
Geographic information system(GIS) and its applications in agriculture
Geographic information system(GIS) and its applications in agricultureGeographic information system(GIS) and its applications in agriculture
Geographic information system(GIS) and its applications in agriculture
 
MODS_Training_January_2015.pptx
MODS_Training_January_2015.pptxMODS_Training_January_2015.pptx
MODS_Training_January_2015.pptx
 
Mobile LBS
Mobile LBSMobile LBS
Mobile LBS
 
GIS and Its Components.pptx
GIS and Its Components.pptxGIS and Its Components.pptx
GIS and Its Components.pptx
 
Introduction To GIS
Introduction To GISIntroduction To GIS
Introduction To GIS
 

More from bodaceacat

CansecWest2019: Infosec Frameworks for Misinformation
CansecWest2019: Infosec Frameworks for MisinformationCansecWest2019: Infosec Frameworks for Misinformation
CansecWest2019: Infosec Frameworks for Misinformationbodaceacat
 
2019 11 terp_breuer_disclosure_master
2019 11 terp_breuer_disclosure_master2019 11 terp_breuer_disclosure_master
2019 11 terp_breuer_disclosure_masterbodaceacat
 
Terp breuer misinfosecframeworks_cansecwest2019
Terp breuer misinfosecframeworks_cansecwest2019Terp breuer misinfosecframeworks_cansecwest2019
Terp breuer misinfosecframeworks_cansecwest2019bodaceacat
 
Misinfosec frameworks Cansecwest 2019
Misinfosec frameworks Cansecwest 2019Misinfosec frameworks Cansecwest 2019
Misinfosec frameworks Cansecwest 2019bodaceacat
 
Sjterp ds_of_misinfo_feb_2019
Sjterp ds_of_misinfo_feb_2019Sjterp ds_of_misinfo_feb_2019
Sjterp ds_of_misinfo_feb_2019bodaceacat
 
Practical Influence Operations, presentation at Sofwerx Dec 2018
Practical Influence Operations, presentation at Sofwerx Dec 2018Practical Influence Operations, presentation at Sofwerx Dec 2018
Practical Influence Operations, presentation at Sofwerx Dec 2018bodaceacat
 
Session 10 handling bigger data
Session 10 handling bigger dataSession 10 handling bigger data
Session 10 handling bigger databodaceacat
 
Session 09 learning relationships.pptx
Session 09 learning relationships.pptxSession 09 learning relationships.pptx
Session 09 learning relationships.pptxbodaceacat
 
Session 07 text data.pptx
Session 07 text data.pptxSession 07 text data.pptx
Session 07 text data.pptxbodaceacat
 
Session 06 machine learning.pptx
Session 06 machine learning.pptxSession 06 machine learning.pptx
Session 06 machine learning.pptxbodaceacat
 
Session 05 cleaning and exploring
Session 05 cleaning and exploringSession 05 cleaning and exploring
Session 05 cleaning and exploringbodaceacat
 
Session 04 communicating results
Session 04 communicating resultsSession 04 communicating results
Session 04 communicating resultsbodaceacat
 
Session 03 acquiring data
Session 03 acquiring dataSession 03 acquiring data
Session 03 acquiring databodaceacat
 
Session 02 python basics
Session 02 python basicsSession 02 python basics
Session 02 python basicsbodaceacat
 
Session 01 designing and scoping a data science project
Session 01 designing and scoping a data science projectSession 01 designing and scoping a data science project
Session 01 designing and scoping a data science projectbodaceacat
 
Gp technologybuilds july2011
Gp technologybuilds july2011Gp technologybuilds july2011
Gp technologybuilds july2011bodaceacat
 
Gp technologybuilds july2011
Gp technologybuilds july2011Gp technologybuilds july2011
Gp technologybuilds july2011bodaceacat
 
Ardrone represent
Ardrone representArdrone represent
Ardrone representbodaceacat
 
Global pulse app connection manager
Global pulse app connection managerGlobal pulse app connection manager
Global pulse app connection managerbodaceacat
 
Un Pulse Camp - Humanitarian Innovation
Un Pulse Camp - Humanitarian InnovationUn Pulse Camp - Humanitarian Innovation
Un Pulse Camp - Humanitarian Innovationbodaceacat
 

More from bodaceacat (20)

CansecWest2019: Infosec Frameworks for Misinformation
CansecWest2019: Infosec Frameworks for MisinformationCansecWest2019: Infosec Frameworks for Misinformation
CansecWest2019: Infosec Frameworks for Misinformation
 
2019 11 terp_breuer_disclosure_master
2019 11 terp_breuer_disclosure_master2019 11 terp_breuer_disclosure_master
2019 11 terp_breuer_disclosure_master
 
Terp breuer misinfosecframeworks_cansecwest2019
Terp breuer misinfosecframeworks_cansecwest2019Terp breuer misinfosecframeworks_cansecwest2019
Terp breuer misinfosecframeworks_cansecwest2019
 
Misinfosec frameworks Cansecwest 2019
Misinfosec frameworks Cansecwest 2019Misinfosec frameworks Cansecwest 2019
Misinfosec frameworks Cansecwest 2019
 
Sjterp ds_of_misinfo_feb_2019
Sjterp ds_of_misinfo_feb_2019Sjterp ds_of_misinfo_feb_2019
Sjterp ds_of_misinfo_feb_2019
 
Practical Influence Operations, presentation at Sofwerx Dec 2018
Practical Influence Operations, presentation at Sofwerx Dec 2018Practical Influence Operations, presentation at Sofwerx Dec 2018
Practical Influence Operations, presentation at Sofwerx Dec 2018
 
Session 10 handling bigger data
Session 10 handling bigger dataSession 10 handling bigger data
Session 10 handling bigger data
 
Session 09 learning relationships.pptx
Session 09 learning relationships.pptxSession 09 learning relationships.pptx
Session 09 learning relationships.pptx
 
Session 07 text data.pptx
Session 07 text data.pptxSession 07 text data.pptx
Session 07 text data.pptx
 
Session 06 machine learning.pptx
Session 06 machine learning.pptxSession 06 machine learning.pptx
Session 06 machine learning.pptx
 
Session 05 cleaning and exploring
Session 05 cleaning and exploringSession 05 cleaning and exploring
Session 05 cleaning and exploring
 
Session 04 communicating results
Session 04 communicating resultsSession 04 communicating results
Session 04 communicating results
 
Session 03 acquiring data
Session 03 acquiring dataSession 03 acquiring data
Session 03 acquiring data
 
Session 02 python basics
Session 02 python basicsSession 02 python basics
Session 02 python basics
 
Session 01 designing and scoping a data science project
Session 01 designing and scoping a data science projectSession 01 designing and scoping a data science project
Session 01 designing and scoping a data science project
 
Gp technologybuilds july2011
Gp technologybuilds july2011Gp technologybuilds july2011
Gp technologybuilds july2011
 
Gp technologybuilds july2011
Gp technologybuilds july2011Gp technologybuilds july2011
Gp technologybuilds july2011
 
Ardrone represent
Ardrone representArdrone represent
Ardrone represent
 
Global pulse app connection manager
Global pulse app connection managerGlobal pulse app connection manager
Global pulse app connection manager
 
Un Pulse Camp - Humanitarian Innovation
Un Pulse Camp - Humanitarian InnovationUn Pulse Camp - Humanitarian Innovation
Un Pulse Camp - Humanitarian Innovation
 

Recently uploaded

Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxolyaivanovalion
 
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfAccredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfadriantubila
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxolyaivanovalion
 
Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz1
 
Zuja dropshipping via API with DroFx.pptx
Zuja dropshipping via API with DroFx.pptxZuja dropshipping via API with DroFx.pptx
Zuja dropshipping via API with DroFx.pptxolyaivanovalion
 
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% SecureCall me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% SecurePooja Nehwal
 
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...Pooja Nehwal
 
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfMarket Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfRachmat Ramadhan H
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionfulawalesam
 
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779Delhi Call girls
 
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightCheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightDelhi Call girls
 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAroojKhan71
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusTimothy Spann
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfMarinCaroMartnezBerg
 
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...amitlee9823
 
Carero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxCarero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxolyaivanovalion
 
Halmar dropshipping via API with DroFx
Halmar  dropshipping  via API with DroFxHalmar  dropshipping  via API with DroFx
Halmar dropshipping via API with DroFxolyaivanovalion
 
Capstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics ProgramCapstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics ProgramMoniSankarHazra
 

Recently uploaded (20)

Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptx
 
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfAccredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptx
 
Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signals
 
Zuja dropshipping via API with DroFx.pptx
Zuja dropshipping via API with DroFx.pptxZuja dropshipping via API with DroFx.pptx
Zuja dropshipping via API with DroFx.pptx
 
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% SecureCall me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
 
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
 
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfMarket Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interaction
 
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
 
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
 
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightCheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and Milvus
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdf
 
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
 
Carero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxCarero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptx
 
Halmar dropshipping via API with DroFx
Halmar  dropshipping  via API with DroFxHalmar  dropshipping  via API with DroFx
Halmar dropshipping via API with DroFx
 
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in  KishangarhDelhi 99530 vip 56974 Genuine Escort Service Call Girls in  Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
 
Capstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics ProgramCapstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics Program
 

Session 08 geospatial data

  • 2. Lab 8: Your 5-7 things: • Geospatial data • Geospatial data tools • Vector map data • Raster map data • Geospatial calculations
  • 4. Geospatial Data o Geographical: related to the Earth’s surface o Spatial: about space (locations, distances etc) o Data: yep, this is also data o Usually handled by Geographical Information Systems (GIS) tools o …many of which are written in Python…
  • 8. Adding features to a vector map
  • 12. Coordinate systems • WGS84 (GIS) • OSGB36 (UK) • ED50 (Nato) • Etc.
  • 16. Geospatial data tools • Google Maps • OpenStreetMap • QGIS • CartoDB • ArcGIS • LeafletJS • MapBox Python libraries: • GDAL toolset • Shapely • Fiona • Basemap
  • 17. QGIS
  • 20. QGIS: Looking at the dataset
  • 23. QGIS: Getting Raster Map information
  • 24. QGIS: Raster map histogram
  • 26. Vector data formats • Spreadsheet (.csv, .xls) • Shapefile (.shp) • Keyhole markup language (.kml, .kmz) • Geojson and Topojson (.json) • GPS exchange format (.gpx) • OSM output files (.osm.bz2)
  • 27. Shapefiles • .shp: feature geometry (e.g. your dataset) • .shx: shape index • .dbf: shape attributes • .prj: projection • .shp.xml: metadata
  • 28. The GDAL toolset Example terminal-line tools: • OGR2OGR: convert between vector formats • GDALwarp: cookie-cut raster files • gdal_polygonize: convert raster to vector Python libraries: • gdal, ogr2ogr etc • fiona (“pythonic GDAL”)
  • 29. Reading shapefiles: the Fiona library from fiona import collection with collection('example_data/TZwards/TZwards.shp', 'r') as input: for f in input: print(f)
  • 30. Convert vector file formats: OGR2OGR From the terminal window: ogr2ogr f GeoJSON where "ADM0_A3 = 'YEM'" outfile.json ne_10m_admin_1_states_provinces.shp
  • 33. Raster Data Formats • GeoTiff (.tif) • Jpeg (.jpg) • NITF • HTF5
  • 35. Reading raster map data with GDAL import gdal import numpy as np dataset = gdal.Open(infile, GA_ReadOnly) cols = dataset.RasterXSize rows = dataset.RasterYSize nbands = dataset.RasterCount driver = dataset.GetDriver().LongName geotransform = dataset.GetGeoTransform() for b in range(1,nbands+1): band = dataset.GetRasterBand(b) bandtype = gdal.GetDataTypeName(band.DataType) banddata = band.ReadAsArray(0,0,band.XSize, band.YSize).astype(np.float)
  • 36. Raster + Vector: cookie-cut a raster map From the command line, type gdalwarp cutline yourshapefile.shp yourgeotiff.tif yourresult.tif
  • 38. Vector data calculations • Point location (e.g. lat/long from address) • Area and area overlap sizes (e.g. overlap between village and protected area) • Belonging (e.g. finding which district a lat/long is in) • Straight-line distance between points (e.g. great circles) • Practical distance and time between points (e.g. using roads)
  • 39. Geopy: get lat/ longs from addresses from geopy.geocoders import Nominatim from geopy.geocoders import GoogleV3 geolocator = Nominatim() googlocator = GoogleV3() address = '1600 Pennsylvania Ave NW, Washington, DC' result = geolocator.geocode(address, timeout=10) if result is None: result = googlocator.geocode(address, timeout=10) if result is None: latlon = (0.0, 0.0) else: latlon = (float(result.latitude), float(result.longitude))
  • 40. Geopy: Calculate distance from geopy.distance import vincenty dist = vincenty(loc1, loc2)
  • 41. Fiona point-in-polygon: finding “belonging” import fiona Import shapely mapdata = fiona.open(‘map_data/nyc_neighbourhoods_wgs84.shp’, 'r') for f in mapdata: props = f['properties'] geom = shapely.geometry.asShape(f['geometry']) neighs[props['NTACode']] = geom stationpt = Point(stationlon, stationlat) for neigh, neighshape in neighs.iteritems(): if neighshape.contains(stationpt): stationneigh = neigh
  • 42. Basemap: Map visualisations in Python %matplotlib inline import matplotlib.pyplot as plt from mpl_toolkits.basemap import Basemap fig = plt.figure(figsize=(8, 8)) usmap = Basemap(projection='lcc', resolution=None, width=8000000, height=8000000,lat_0=45, lon_0=-100,) usmap.etopo(scale=0.5, alpha=0.5)
  • 44. If this interested you… There’s more in workbooks 8.x

Editor's Notes

  1. Note that spatial data doesn’t have to be geographical: it could be at much smaller (e.g. building) or larger (e.g. universe) level. There’s an estimate floating around GIS circles that at least 80% of data has a geospatial component.
  2. Printed maps are images depicting an area, that are often carefully created by hand (yes, there are people who spend hours working how to get those labels in just the right places). Road maps are a great example of the art of making map data easily readable by humans. Note, for instance, how the label “Tioga State Forest” has been carefully placed around the roads in the bottom left corner of this map. The University of Texas has a great raster map collection online, e.g. the Libya image is at http://www.lib.utexas.edu/maps/libya.html Road map is from http://www.austinques.com/znz-9683-poxq.htm For many places, the only detailed maps available are still printed maps. Many of the older maps were created by surveyors triangulating (as in forming triangles out of survey points and using the angles between them to estimate new distances) their way across countries, marking heights and features of interest. More recently, maps have been created using satellite-based positions, either from georeferenced satellite images (e.g. the satellite images have been stretched to match the lat-longs on an area, then roads etc have been traced onto the map) or by geographers using hand-held GPS units to mark the locations of places and features of interest.
  3. Left: An example of an aerial map. This image is from https://www.flickr.com/photos/jeffreywarren/4774701213/ - Jeff is part of PublicLab, a group that amongst other great citizen science projects, creates aerial maps using balloons, kites, ordinary cameras and rubber bands. You’re probably already aware of the satellite images in e.g. Google Maps, Bing maps etc. If you look closely, the PublicLab balloon maps are included in GoogleMaps etc too. Right: NASA satellite data for Tanzania, showing trees. NASA openly releases a *lot* of satellite data for the earth, at many different wavelengths, only one of which is visible light. The tree data is from a satellite that measures differences in height at the earth’s surface using radar; this was originally intended to measure polar ice depths, but turned out to be useful for measuring tree heights too. Other satellite data includes infrared, other radars (including wavelengths tuned to water frequencies), visible light, at intervals ranging from hourly. More at https://earthdata.nasa.gov
  4. Vector maps represent the world as a series of labelled points (e.g. the labelled subway stations in this map), lines (e.g. the roads in this map), and polygons (e.g. the building outlines in this map). Vector maps are easier to update and use than printed maps; most of the major vector maps (e.g. OpenStreetMap, GoogleMaps) also have APIs that you can use to find map features, feature locations and details.
  5. Some maps are community-based. For example, anyone can add or edit features on OpenStreetMap. Here, I’m using the ID editor to add buildings to an OpenStreetMap, as part of Humanitarian OpenStreetMap task http://tasks.hotosm.org/project/1686#task/48. HOT OSM puts out requests for editing (and verifying) help like this on the HOT tasking manager, http://tasks.hotosm.org.
  6. Some geospatial data images don’t map their features to the underlying lat/longs. The classic geospatial schematic is the London Underground map, shown here, which was created (using an electronics diagram as a template) to be easy to use by people looking for where they should change between underground lines to get between two points. Plotting the London Underground map so it’s realistic about lat/longs produces something a lot messier and harder for most people to read.
  7. You can add your own datapoints to both maps and schematics. Here’s the New York subway map, with the nearest good coffee shop (subjective!) to each subway station. Image: http://www.businessinsider.com/nyc-best-coffee-shops-by-subway-stop-2014-2
  8. Maps, like datasets, are intensely political, and when you look at a map, you need to ask similar questions to when you look at a dataset: who created this, what did they create it for, what were their biases, what was important to them. One of the things you need to be aware of is map projections: “projection” because you’re trying to represent all or part of an oblate spheroid (squished ball) as a flat image. Here are two maps of the world, from http://geoawesomeness.com/map-distortions/ The one on the left uses the Mercator projection: designed for sailors, so when they wanted to sail between two points on the world, they could read the angle (direction) they needed to sail in from the map. This is great for sailors, but terrible for geopolitics: it shows the USA as much larger than Africa, South America and Australia, all of which, in reality, are huge. The map on the right uses the Gall-Peters projection: this would be terrible for sailors, but does a much better job at showing the relative area size of each continent. Note incidentally that both maps are north-up and centred on the UK, which splits the Pacific Ocean in two.
  9. Projections also matter on a smaller scale. When you’re dealing with map data, you also need to know the coordinate system it’s in. Maps, and the coordinate systems they’re in, are created by fitting a flat plane to the world in one of 3 ways (it helps at this point to think about how you’d wrap a ball using a sheet of paper): a tangent plane that touches the world at a specific location on earth, a cylinder wrapped around the world, or a cone wrapped around part of the world, with its point at a specific location on earth. Each of these will produce different lat/long numbers for the same point on the earth’s surface – which means that, in most GPS coordinate systems, the Greenwich Meridian (the 0 line from north pole to south pole) is about 100m to the West. To make this even more complicated, parts of the Earth are also moving (blame the tectonic plates…). QGIS can convert between coordinate systems, if you’re combining GIS data from different ones. Image from http://www.movable-type.co.uk/scripts/latlong-convert-coords.html More: https://en.wikipedia.org/wiki/Geographic_coordinate_system
  10. And we’re done with map views… except we’re not, because Tableau only contains country outlines and USA outline data. If we want to cover other places in the world, we’re going to need another tool.
  11. QGIS is a map data viewer, but it’s Python-based, and also has GIS data tools hidden inside it.
  12. File used here is TZwards.shp
  13. This uses data file Tzwards.shp
  14. Right-click on the name of the layer (e.g. TzWards), then select “open attribute table”
  15. Here’s your dataset. You can also change what’s displayed using the “Properties” option, and save this layer to a different data format (e.g. CSV).
  16. File is TreeCover_250m_MODIS_Tanzania_2010.tif
  17. Shapefiles are very common vector map formats. KMZ files are zipped versions of KML files. OpenStreetMap uses GPX as its internal data representation. Geojson and Topojson are commonly used in D3 GIS code.
  18. For most tools, you’ll only need the .shp and .shx file. For some tools, you need the .shp, .shx and .dbf. More about all those files: https://en.wikipedia.org/wiki/Shapefile
  19. List of GDAL tools at http://www.gdal.org/gdal_utilities.html. Get these from http://www.gdal.org, unless you’re a mac user, in which case try http://www.kyngchaos.com/software/archive#gdal
  20. Fiona needs both the .shp and .shx file. You’ll recognise the output as a dictionary. Intro to Fiona and Shapely: http://www.macwright.org/2012/10/31/gis-with-python-shapely-fiona.html
  21. OGR2OGR is part of the GDAL toolset. This code filters and converts a shapefile to geojson. Ne_10m_admin_1_states_provinces.shp is a shapefile from the NaturalEarth.com shapefile collection: this file has all the provinces (states) in all the countries in the world in it. You can also do this in Python, e.g. import ogr2ogr ogr2ogr.main([‘’,'­f','GeoJSON','test2.json',‘TZwards.shp'])” The Ogr2ogr formats list is: http://www.gdal.org/ogr_formats.html
  22. Most of the time, you’ll see tif and jpg images. If you’re handling satellite data, NITF and HTF5 are common. More at https://www.bluemarblegeo.com/products/global-mapper-formats-raster.php Most raster data files have “bands” in them: often 1 band (e.g. those tree heights), but sometimes 3 (red/green/blue) or more (e.g. monthly rainfall numbers).
  23. If you zoom into a Geotiff file, you’ll see something like this. Lots of pixels, with a greyscale (usually between 0 and 127) value for each pixel. This is just like an image file – and you can using image processing code on geotiff files too.
  24. You need: A shapefile with the outline in it: both the .shp and .shx files a Geotiff (or other) file that needs cookie­cutting, IN THE SAME COORDINATE SYSTEM as the shapefile. The result is in file yourresult.tif. The GDAL library has cookie­cutters as part of its Gdalwarp library. Shapefile restriction applies to other tech too, e.g. Arcview won’t display a shape if you don’t give it .shp, .shx and .dbf files. where yourshapefile.shp is the shapefile you’re using as an outline, and yourgeotiff.tif is the file that you want to cookie­cut. You can also cookie-cut with QGIS: see http://www.qgistutorials.com/en/docs/raster_mosaicing_and_clipping.html
  25. You can also use postcodes, e.g. Country = ‘US’ Postcode = ‘20500’ result = googlocator.geocode(‘’, components={'postal_code': postcode, 'country': country}, timeout=10)
  26. Great circle distances: map straight lines aren’t shortest paths Nautical miles aren’t land miles – and aren’t constant lengths
  27. This is an extract from a larger file: it won’t run on its own (you need the station lat/longs, in stationlat and stationlon).
  28. You can also do choropleths in Python: http://matplotlib.org/basemap/api/basemap_api.html#mpl_toolkits.basemap.Basemap.contour