The [http://code.djangoproject.com/browser/django/branches/gis gis] branch intends to add a contrib app implementing geographic support. = What's GIS? = * [http://cfis.savagexi.com/articles/category/gis Series of blog posts] giving intro to GIS; choice quote from [http://cfis.savagexi.com/articles/2006/04/20/on-coordinate-systems#comments an early post]: "If you feel like ending a conversation with a developer then simply bring up the topic of character encodings ... [o]r ... coordinate systems. ... So in the spirit of Tim Bray's and Joel Spolsky's wonderful writeups of character encodings, I thought I'd put together a basic survival guide to coordinate systems over my next few posts and then tie it back to Google Maps." * More on [http://en.wikipedia.org/wiki/Map_projection map projections], including why people can't agree on just one (utf-8). * [http://en.wikipedia.org/wiki/Geodesy geodesy] the field of science for this stuff. = Useful code = * [http://postgis.refractions.net/ PostGIS], the [http://www.opengis.org/docs/99-049.pdf OpenGIS SQL Types (pdf)] implementation for Postgresql * [http://geos.refractions.net/ GEOS], low-level C++ port of [http://www.jump-project.org/project.php?PID=JTS Jave Topology Suite], used by PostGIS * [http://zcologia.com/news/14/python-geos-module/ PyGEOS, now outdated due to PCL, below], and shedloads more stuff on "python, geospatial, and the web" * [http://gispython.org/ Python Cartographic Library] - [http://trac.gispython.org/projects/PCL actively maintained], huge GIS package, GPL. * [http://www.initd.org/tracker/psycopg/wiki/GeoTypes GeoTypes] is a type (and conversion) library for PostGIS via psycopg. * [http://exogen.case.edu/projects/geopy/ Geopy] calcs distances using (very accurate) [http://www.movable-type.co.uk/scripts/LatLongVincenty.html Vincenty], and uses the [http://en.wikipedia.org/wiki/World_Geodetic_System WGS 84] datum by default. Also has utility functions for UOM conversions. * [http://www.gdal.org/ GDAL/OGR], a library for fiddling with raster geo images. = Questions = * When dealing with points (say, degrees) from, do they need to be converted to be useful on the back-end data, assuming -that- data is in degrees? Is it enough to have the same datum and origin? (Reading the intro above is likely to answer the question.) = Implementation = == Phase 1 == Assume existing data and columns, and that the UOM given is same as backing data. Support a custom manager (and queryset) to support lookups. === GeoTypes === GeoTypes supports only psycopg1, which is dead. Porting it to Psycopg2 doesn't look too terrible. Upside is conversion from type params to SQL. Simplifies (avoids?) QuerySet modification. Maintainer of GeoTypes has been responsive as of Feb 26 2007 on the psycopg mailing list. Example code, where point and box are types from GeoTypes: {{{ Schools.objects.geo_near(point=x, radius=1.0) Schools.objects.geo_within(bound_box=box) }}} === Geos === I'm not sure how we can use GEOS without also doing something like GeoTypes down in the QuerySet. Ideas? == Phase 2 == === Field Types === * To allow update through ORM, new fieldtypes would be needed. === GIS utilities === wrapper for geos, have the ability to do something like {{{ from django.contrib.gis import area area(bbox.geom) }}}