[portland] Meeting notes: January 12, 2009 -- Geohash, PostGIS, GeoDjango
igal at pragmaticraft.com
Wed Jan 13 18:57:57 CET 2010
Please post any corrections or additions.
"The __future__ module" by Jason Kirtland -- @cheeseinspector,
* The "__future__" module lets you use features of Python
interpreters from within some older Python interpreters.
* Future features include: using the Python 2.6 "with" statement in
Python 2.5, making "print" a function in Python 2.6 like in 3.0, etc.
* Full set of future features and their documentation:
"Geohash" by Michel Pelletier -- http://idealist.org/
* Geohash is an algorithm for producing a short code ("hash") that
refers to a geographical location. The longer the hash, the more
precise the latitude/longitude encoded in it. A unique property of
the Geohash is that you can remove characters off the right side
of the string and it'll still be valid, although less precise.
* Overview of Geohash: http://en.wikipedia.org/wiki/Geohash
* Site for finding Geohashes: http://geohash.org/
* Example of how trimming a Geohash string degrades accuracy:
* Geohash is included in PostGIS
* There are many python implementations, the python-geohash with a C
extension is fast and actively maintained:
"PostGIS" by Webb Sprague
* PostGIS adds support for geographic objects to PostgreSQL databases.
* Overview of PostGIS: http://en.wikipedia.org/wiki/PostGIS
* Site for PostGIS distribution: http://postgis.refractions.net/
* Manual for PostGIS:
* In PostGIS, geography is stored as geometric types: "point" has
latitude/longitude, "line" which has two points, "polygon" has a
series of connected lines, etc. These are stored in PostgreSQL as
* You can run database queries to find centroids of a polygon, get
distances between objects, select items within a polygon, select
items a certain distance from a point, get the Geohash for a
geometric object, etc.
* Performance is an important issue because some operations can be
quite expensive. Ways to address this include adding indexes,
creating lower-resolution copies of complex geometric shapes that
are quicker to run queries on, storing pre-calculated data, etc.
"GeoDjango" by Tim Welch -- @t_doubleuu, http://tdubya.net/
* These notes provide additional content to the slides that Tim
posted, you should probably read both:
* Tim Welch works on open source Python GIS projects like:
o Open OceanMap, "a data collection tool used to effectively
collect local expert knowledge in support of marine spatial
o MarineMap, "a web-based decision support tool for open and
participatory spatial planning in the marine environment.":
* GeoDjango is a geospatial extension for the Django web framework.
o Site: http://geodjango.org/
o Documentation: http://geodjango.org/docs/
o Tutorial, highly recommended:
* GeoDjango works best with PostGIS (PostgreSQL), but will also work
with SpatiaLite (SQLite), Oracle Spatial (Oracle), and MySQL.
* GeoDjango provides geometry fields for use in Django models:
PointField, LineStringField, PolygonField, MultiPolygonField, etc.
* GeoManager allows Django models to perform spatial queries:
o Relationship: contains, covers, crosses, intersects,
o Measurement: area, length, perimeter, distance
o Geometry: difference, intersection, union
o Serialization: GeoJSON, KML, SVG, GeoRSS
* The "django.contrib.gis.geos" module provides Python classes for
representing geometric types like Point and Polygon. These classes
include useful methods like calculating area of a polygon,
creating a polygon that's the difference between other polygons,
etc. These classes provide a way to specify the spatial reference
system (SRID) and transform between them, e.g., go from
latitude/longitude to x/y meters from a particular place.
* You can get the PostgreSQL INSERT statement to add PostGIS support
for a particular SRID from: http://spatialreference.org/
* In Django, you'll need to tell settings.py to use the
"django.contrib.gis.db.backends.postgis" engine for the database
and include "django.contrib.gis" in the INSTALLED_APPS.
* The GeoDjango "ogrinspect" Django manage.py subcommand can read a
dataset and generate the code for a Django model with all its
* The GeoDjango admin interface "admin.OSMGeoAdmin" can let you view
and edit your mapping data visually on the web and overlay it on
the Open Street Map data set.
rich web mapping: http://www.geoext.org/
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Portland