Slide 1

Slide 1 text

Spatial Thinking with Python Sangarshanan

Slide 2

Slide 2 text

{{ ME_IRL }} 2 sangarshanan sangarshanan Sangarshanan Recently graduated from VIT Vellore Working at Grofers Makes memes hanging upside down

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

The geostory begins

Slide 5

Slide 5 text

When you realize that John Snow was basically the first person to effectively make use of geospatial data everything

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

Location Intelligence 7 Intelligence you acquire from spatial thinking

Slide 8

Slide 8 text

When you realize that spatial data doesn’t get the attention it deserves

Slide 9

Slide 9 text

WHAT IS GEOSPATIAL DATA ?

Slide 10

Slide 10 text

Geospatial data is any data with a geographic component that can be layered onto a map 10

Slide 11

Slide 11 text

Types of these geographic components ?

Slide 12

Slide 12 text

12 Vector Points / Geometries /Shapes eg: Shapefiles, GEOJSON Raster Pixels with or without spatial metadata eg: GEOTIFF, TIFF

Slide 13

Slide 13 text

Raster Data

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

We can get our Raster’s degree now

Slide 16

Slide 16 text

We can get our Raster’s degree now - Monitoring and predicting natural phenomena like Hurricanes, Forest fires etc - Do tons of cool analysis over time like calculating the Affluence of the area, Extent of vegetation, Types of buildings, Road network, Population, Nightlights.

Slide 17

Slide 17 text

Well Known text Well known binary

Slide 18

Slide 18 text

Spatial Reference System Geographic coordinate systems Projected coordinate systems

Slide 19

Slide 19 text

SHP KML Carto KMZ Geojson GML KML Geotiff CSV GPX ESRI GeoRSS GSC SHP Sentinel 2

Slide 20

Slide 20 text

Read/ Write/ Analyze

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

GDAL / OGR Geospatial Data Abstraction Library YEAR 1998 154 raster and 93 vector geospatial data formats

Slide 23

Slide 23 text

ogr2ogr can convert data in PostGIS to KML ogrinfo lists information about the data

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

Vector Data OGR's neat and nimble API for Python programmers Geographic data to pandas objects Geometry Engine – Open Source

Slide 26

Slide 26 text

OSR Projections / Rtree Pythonic cartographic projections and coordinate transformations library Advanced spatial indexing features Fiona ,Shapely, Geopandas

Slide 27

Slide 27 text

Indexing Geospatial Data Suppose you want to find all the geospatial points in a given radius Are you gonna iterate ? HELL NAHHH Use Spatial indices provided by the spatial extensions of traditional databases like postgres ( Postgis uses Rtrees )

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

Hexagonal grid indexing (Uber H3)

Slide 35

Slide 35 text

Raster Data Rasterio reads and writes raster formats and provides a Python API based on N-D arrays.

Slide 36

Slide 36 text

There are also packages than combine these existing packages that are actually wrappers on already existing packages

Slide 37

Slide 37 text

Vector data Raster data

Slide 38

Slide 38 text

OSMNX (0SM + Networkx) Work with road network data from osm using networkx Analyze and visualize street networks, routing , travel times etc

Slide 39

Slide 39 text

Visualize

Slide 40

Slide 40 text

When you plot and visualize all your spatial layers on a basemap

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

You need to know javascript to create such cool maps

Slide 43

Slide 43 text

Just Plot em Matplotlib (for everything) Leaflet / Openlayers / Mapbox Plotly + Mapbox / Mapboxgl

Slide 44

Slide 44 text

Geometry + Matplotlib = Descartes Enables plotting of shapely geometries as matplotlib paths/ patches.

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

Me after running import tensorflow as tf

Slide 48

Slide 48 text

PySAL: Python Spatial Analysis Library Spatially constrained Clustering Spatio-temporal data analysis Spatial regression and Statistical modeling

Slide 49

Slide 49 text

It’s Code Time https://github.com/Sangarshanan/talks/blob/master/spatial-thinking- with-python/spatial_thinking.ipynb

Slide 50

Slide 50 text

https://github.com/Sangarshanan/talks/tree/master/spatial-thinking-with-python

Slide 51

Slide 51 text

What’s the POINT(12.22,73.32) ?

Slide 52

Slide 52 text

Marketing

Slide 53

Slide 53 text

GEO - Marketing

Slide 54

Slide 54 text

No content

Slide 55

Slide 55 text

PennyWISE Decision Making

Slide 56

Slide 56 text

GEO - Surge

Slide 57

Slide 57 text

That was UnUbercool

Slide 58

Slide 58 text

No content

Slide 59

Slide 59 text

Blogs I stole from - https://blog.mapbox.com/a-dive-into-spatial-search-algorithms-ebd0c5e39d2a - https://github.com/pcjericks/py-gdalogr-cookbook - https://medium.com/locale-ai - https://geoffboeing.com/ - https://towardsdatascience.com/geospatial-indexing-with-ubers-h3-766399b690c - https://medium.com/@chrieke/essential-geospatial-python-libraries-5d82fcc38731 - https://pysal.readthedocs.io/en/latest/

Slide 60

Slide 60 text

Hey You…. Yes you :) You’re Breathtaking