Version 31 (modified by 18 years ago) ( diff ) | ,
---|
The gis branch intends to add a contrib app implementing geographic support.
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."
- More on map projections, including why people can't agree on just one (utf-8).
- geodesy the field of science for this stuff.
Useful code
- PostGIS, the OpenGIS SQL Types (pdf) implementation for Postgresql
- GEOS, low-level C++ port of Jave Topology Suite, used by PostGIS
- PyGEOS, now outdated due to PCL, below, and shedloads more stuff on "python, geospatial, and the web"
- Python Cartographic Library - actively maintained, huge GIS package, GPL.
- There are direct SWIG Python bindings in GEOS 3.0.0RC1 and above. In other words, the entire GEOS API may be called directly from Python.
- GeoTypes is a type (and conversion) library for PostGIS via psycopg.
- Geopy
- Calculates distances using (very accurate) Vincenty, and uses the WGS 84 datum by default.
- Has utility functions for unit of measurement (UOM) conversions (e.g. meters -> kilometers, kilometers -> miles, etc.)
- Excellent GeoCoding capabilites. Has interfaces for Google, Yahoo, Microsoft Live, MediaWiki, and Geocoder.us.
- GDAL/OGR, a library for fiddling with raster geo images.
- 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.
- Ruby on Rails
- IvyGIS: Google-maps type displays with RoR and UMN's MapServer
- 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." Currently 2006 First Edition is the latest, but second edition should be coming soon.
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.)
- My (JDunck) reading indicates yes. Given the same coordinate system (i.e. datum, origin, and axes), degrees are useful without conversion.
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 0.7 supports both psycopg1 and psycopg2. 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.OG*:
from django.db import models from django.contrib.gis import db as gis_db class School(meta.Model): name = ... objects = gis_db.Manager() Assume a location column has already been added to the DB, e.g. select addgeometrycolumn('','schools_school','location',-1, 'POINT', 2); Then this would work: from django.contrib.gis.geometry import Point x = Point(-95.36819458007812, 30.2184318620219) School.objects.geo_near('location', point=x, radius=1.0) This could construct a LinearRing approximating the circle around x and issue something like: poly = "POLYGON (...points from curve approximation...)" _where.append(""" where schools_school.location && %s and within(schools_school.location, %s) """) _params.append(poly, poly)
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)