Contents

Background

Note: The content herein is a loosely structured collection of notes and links that we have found useful, not necessarily what will be supported in the future.

What's GIS?

​Series of blog posts giving intro to GIS; choice quote from ​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."

Has a Python interface. A SWIG interface is in development, but not yet stable (no access to full API).

​Geo::Coder::US An excellent Perl library for GeoCoding that powers ​Geocoder.us. Users can create their own Geographic databases using the Census Bureau's TIGER/Line data (see below).

​GeoRosetta, CC-BY-SA licensed, quality-controlled, collection of geocoding data. Not yet released to public(?).

​MapServer: University of Minnesota (UMN) "open source development environment for building spatially-enabled internet applications."

​MapNik: C++ and Python toolkit for developing mapping applications. Claimed benefits over MapServer: "It uses the AGG library and offers world class anti-aliasing rendering with subpixel accuracy for geographic data. It is written from scratch in modern C++ and doesn't suffer from design decisions made a decade ago." See​MapNik FAQ.

​Spatial Adapter for Rails: A plugin for Rails which manages the MySql Spatial and PostGIS geometric columns in a transparent way (that is like the other base data type columns). This might have some useful techniques for when we try to support other spatial extensions other than PostGIS.

Useful Data

​TIGER/Line: "The TIGER/Line files are extracts of selected geographic and cartographic information from the ​Census Bureau's TIGER® (Topologically Integrated Geographic Encoding and Referencing) database." This data is useful in creating your own geocoding database service. Currently 2006 First Edition is the latest, but second edition should be coming soon. Note: The Census Bureau will be ​providing SHP files in Fall, 2007.

FAQ

Place your questions here.

Q: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.)

My (JDunck) reading indicates yes. Given the same coordinate system (i.e. datum, origin, and axes), degrees are useful without conversion.

Implementation

Phase 1

Create Geometry-enabled fields and manager. Status: complete as of r4788.

PostGIS additions to the API may now be used. Geographic queries are done by calling geo_filter() and geo_exclude on geometry-enabled models. In the following example, the bbcontains lookup type is used which is the same as the PostGIS && operator. It looks to see if the bounding box of the polygon contains the specific point. The next example uses the PostGIS Contains() function, which calls GEOS library to test if the polygon actually contains the specific point, not just the bounding box.

Both geo_filter() and filter() may be used in the same query. For example, the following query set will only show school districts that have 'Houston' in their name and contain the given point within their polygon boundary:

Or combine both the bounding box routines (less accurate, fast) with the GEOS routines (most accurate, slower) to get a query that is both fast and accurate (this is not 'fast' in the current implementation, since geographic indices are not automatically created):

Installation

Installation of the GeoDjango module will also require the installation of existing open source geographic libraries and a spatial database (currently only PostGIS). This section will describe the installation process for these libraries. Initially, these instructions will pertain only to a Linux platform (particularly Debian or Ubuntu). Mac & Windows support will be considered later; however, these instructions will most likely work through the Mac shell. Don't hold your breath for Windows support.

GDAL

Latest GDAL version is 1.4.0. Configure with GEOS and Python support, then make and install:

$ ./configure --with-geos --with-python
$ make
# make install

Note: This is done without the 'next generation' SWIG Python bindings. I've had trouble getting them to work, and the rumor is this only works on Windows. The compilation flag to enable these is --with-ngpython, but our packages currently only use the old bindings.

Model API

Fields

The following geometry-enabled fields are available:

PointField

LineStringField (bug in current version has this as LineString, will be fixed)

Database API

Note: The following database lookup types can only be used with geo_filter(). All geographic queries are done with geo_filter() and geo_exclude(), thus separating the normal database API lookups from geographic-specific field queries. However chains containing both filter and geo_filter may still be used. Thus, geographic queries take the following form (assuming the Zip model used in the Model API section):