34
Introduction to GeoDjango David Wilson

Introduction to GeoDjango

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Introduction to GeoDjango

Introduction to GeoDjango

David Wilson

Page 2: Introduction to GeoDjango

An Outline:• Who am I? • What is GeoDjango?• A Tour of GeoDjango• Example: Colorado Geology

Page 3: Introduction to GeoDjango

Who Am I?

Page 4: Introduction to GeoDjango

Who Am I?

● Full time Java developer● Love Python and the web● Degree in Geophysics● Some GIS background, actively working to improve knowledge● Travel, weight lifting, cycling, and skiing

Page 5: Introduction to GeoDjango

What is GeoDjango?

Page 6: Introduction to GeoDjango

GeoDjango = spatial toolbox

Page 7: Introduction to GeoDjango

Spatial?

Page 8: Introduction to GeoDjango

Not Spatial

Page 9: Introduction to GeoDjango

Spatial!

Page 10: Introduction to GeoDjango

A Tour of GeoDjango

Page 11: Introduction to GeoDjango

Tour: Backends

Page 12: Introduction to GeoDjango

Tour: Backends

Use this one!

Page 13: Introduction to GeoDjango

Tour: Models

from django.contrib.gis.db import models

Page 14: Introduction to GeoDjango

Tour: Models

Page 15: Introduction to GeoDjango

Tour: Model Fields

● GeometryField● PointField● LineStringField● PolygonField● MultiPointField● MultiLineStringField● MultiPolygonField● GeometryCollectionField

Page 16: Introduction to GeoDjango

Tour: GeoManager

● Overrides model manager● Enables spatial queries ● Gotcha: required on models with no spatial fields that need to query related models spatially

Page 17: Introduction to GeoDjango

Tour: GeoQuerySet

● Many spatial queries, e.g.● contains● crosses● overlaps● intersects● Distance and area queries

● Gotcha: query availability varies based on backend

Page 18: Introduction to GeoDjango

Tour: GeoQuerySet

Use this one!

Page 19: Introduction to GeoDjango

Tour: GEOS API

• Geometry Engine – Open Source• Loosely coupled to GeoDjango• Allows for simple creation, manipulation, and transformation of geometries

Page 20: Introduction to GeoDjango

Tour: GDAL API

● Geospatial Data Abstraction Library● Reads spatial data:

● Shapefiles● KML● And many, many more!

● Easy to abstract data sources

Page 21: Introduction to GeoDjango

Tour: GeoIP

• Ctypes wrapper for MaxMind GeoIP• Requires appropriate local dataset• Allows server-side location• Generally not as accurate as HTML5 location API

Page 22: Introduction to GeoDjango

Tour: GeoAdmin

Page 23: Introduction to GeoDjango

Example: Colorado Geology

Page 24: Introduction to GeoDjango

Example: Objectives

• Find Colorado geology data• Import data• Query data (find rocks near you!)• Make a pretty map

Page 25: Introduction to GeoDjango

Example: Finding Data

Page 26: Introduction to GeoDjango

Example: Importing Data

Page 27: Introduction to GeoDjango

Example: Importing Data

Page 28: Introduction to GeoDjango

Example: View

Page 29: Introduction to GeoDjango

Example: JavaScript

Page 30: Introduction to GeoDjango

Example: More JavaScript

Page 31: Introduction to GeoDjango

Example: Demo

Page 32: Introduction to GeoDjango

Conclusions

Page 33: Introduction to GeoDjango

Conclusions

• Spatial toolbox• Use the parts you need• Built into the same Django you already own!

• Will need to understand GIS basics

• I hope to clean up this demo app and make a full tutorial

Page 34: Introduction to GeoDjango

Resources

Docs: https://docs.djangoproject.com/en/dev/ref/contrib/gis/

Vagrant image: https://github.com/david-wilson/vagrant-geodjango-base

USGS Colorado Geology Data:http://mrdata.usgs.gov/geology/state/state.php?state=CO

LeafletJS:http://leafletjs.com/

Contact Me:[email protected], @dwilson86, http://davidwilson.me