Changes between Version 92 and Version 93 of GeoDjango
- Timestamp:
- Aug 4, 2007, 2:29:45 PM (17 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
GeoDjango
v92 v93 1 1 = !GeoDjango = 2 2 3 [[TOC(GeoDjangoBackground, GeoDjango, GeoDjangoModelAPI, GeoDjangoDatabaseAPI )]]3 [[TOC(GeoDjangoBackground, GeoDjango, GeoDjangoModelAPI, GeoDjangoDatabaseAPI, GEOSGeometry)]] 4 4 The [http://code.djangoproject.com/browser/django/branches/gis GIS] branch intends to be a world-class geographic web framework. Our goal is to make it as easy as possible to build GIS web applications and harness the power of spatially enabled data. 5 5 … … 10 10 * [wiki:GeoDjangoModelAPI Model API] 11 11 * [wiki:GeoDjangoDatabaseAPI Database API] 12 * [wiki:GEOSGeometry GEOS Geometries] (in progress). 12 13 13 14 == Roadmap == … … 55 56 * [http://www.mapnik.org/ Mapnik] is modern, but very early on in development and ''completely'' lacks documentation. However, the code is elegant and clean, and it was designed for integration with Python -- we're leaning towards this right now. 56 57 * [http://mapserver.gis.umn.edu/ Mapserver] has been around for a while, strong backing in the community (e.g. native support in [http://qgis.org/ QGIS]). Even with documentation, the code looks less inviting than Mapnik (all in C); also has archaic text-based configuration files (pre-dating markup languages). 57 * GEOS58 * '''Update:''' As of r5008, GeoDjango has its own GEOS interface (via {{{ctypes}}})59 * GEOS is no longer maintained by Sean Gillies. ''See'' Sean Gillies, ''[http://zcologia.com/news/150/geometries-for-python/ Geometries for Python]'' (blog post explaining rationale for abandoning GEOS support); ''see also'' Sean's message on the [http://geos.refractions.net/pipermail/geos-devel/2007-March/002851.html GEOS-Devel Mailing List] (Mar. 5, 2007).60 58 * WMS Server 61 59 * I'm not satisfied with any of the current WMS/WFS implementations. One implemented in Django would be desirable, e.g., {{{django.contrib.gis.wms}}}. Thoughts anyone? (OWSLib looks good, see below) … … 68 66 * Utilities 69 67 * Database representation ideas 70 * GEOS support, [http://zcologia.com/news/ Sean Gill es] (of PCL) was the maintainer of the old SWIG bindings, and is working on [http://trac.gispython.org/projects/PCL/wiki/ShapeLy ShapeLy], a GeoDjango-inspired GEOS ctypes interface.68 * GEOS support, [http://zcologia.com/news/ Sean Gillies] (of PCL) was the maintainer of the old SWIG bindings, and is working on [http://trac.gispython.org/projects/PCL/wiki/ShapeLy ShapeLy], a GeoDjango-inspired GEOS ctypes interface. 71 69 * [http://code.google.com/p/django-coordinatesfield/ CoordinatesField]. 72 70 * Jannis Leidel has already come up with a way to manipulate points in the admin interface, BSD licensed. … … 94 92 95 93 === Geographic Models === 96 Here is an example of how the model API currently works (assume this example is in geo _app/models.py):94 Here is an example of how the model API currently works (assume this example is in geoapp/models.py): 97 95 {{{ 98 96 #!python … … 116 114 117 115 === Using syncdb === 118 Use the {{{manage.py}}} to invoke {{{syncdb}}} like you normally would: 116 Both {{{manage.py}}} commands {{{sqlall}}} and {{{syncdb}}} work on geographic models: 117 {{{ 118 $ python manage.py sqlall geoapp 119 }}} 119 120 {{{ 120 121 #!sql 121 $ python manage.py sqlall geo_app122 122 BEGIN; 123 CREATE TABLE "geo _app_school" (123 CREATE TABLE "geoapp_school" ( 124 124 "id" serial NOT NULL PRIMARY KEY, 125 125 "name" varchar(35) NOT NULL 126 ); 127 CREATE TABLE "geo_app_district" ( 126 ) 127 ; 128 CREATE TABLE "geoapp_district" ( 128 129 "id" serial NOT NULL PRIMARY KEY, 129 130 "name" varchar(35) NOT NULL, 130 131 "num" integer NOT NULL 131 ); 132 SELECT AddGeometryColumn('geo_app_school', 'point', 4326, 'POINT', 2); 133 CREATE INDEX "geo_app_school_point_id" ON "geo_app_school" USING GIST ( "point" GIST_GEOMETRY_OPS ); 134 SELECT AddGeometryColumn('geo_app_district', 'poly', 4326, 'POLYGON', 2); 135 CREATE INDEX "geo_app_district_poly_id" ON "geo_app_district" USING GIST ( "poly" GIST_GEOMETRY_OPS ); 132 ) 133 ; 134 SELECT AddGeometryColumn('geoapp_school', 'point', 4326, 'POINT', 2); 135 ALTER TABLE "geoapp_school" ALTER "point" SET NOT NULL; 136 CREATE INDEX "geoapp_school_point_id" ON "geoapp_school" USING GIST ( "point" GIST_GEOMETRY_OPS ); 137 SELECT AddGeometryColumn('geoapp_district', 'poly', 4326, 'POLYGON', 2); 138 ALTER TABLE "geoapp_district" ALTER "poly" SET NOT NULL; 139 CREATE INDEX "geoapp_district_poly_id" ON "geoapp_district" USING GIST ( "poly" GIST_GEOMETRY_OPS ); 136 140 COMMIT; 137 $ python manage.py syncdb geo_app 138 141 }}} 142 {{{ 143 $ python manage.py syncdb geoapp 139 144 }}} 140 145 … … 146 151 {{{ 147 152 #!python 148 >>> from geo _app.models import District, School153 >>> from geoapp.models import District, School 149 154 >>> qs1 = District.objects.filter(poly__bbcontains='POINT(-95.362293 29.756539)') 150 155 >>> qs2 = District.objects.filter(poly__contains='POINT(-95.362293 29.756539)') … … 161 166 #!python 162 167 >>> qs = District.objects.filter(poly__bbcontains='POINT(-95.362293 29.756539)').filter(poly__contains='POINT(-95.362293 29.756539)') 168 }}} 169 170 === Lazy-Geometries === 171 Geographic fields on models are proxies to [wiki:GEOSGeometry GEOS Geometry] objects, allowing for many interesting possibilities: 172 {{{ 173 #!python 174 >>> from django.contrib.gis.geos import fromstr 175 >>> pnt = fromstr('POINT(-95.362293 29.756539)', srid=4326) 176 >>> hisd = District.objects.get(name='Houston ISD') 177 >>> hisd.poly.contains(pnt) 178 True 179 >>> hisd.poly.within(pnt) 180 False 163 181 }}} 164 182 … … 171 189 * ''Recommended:'' Python 2.5 is recommended because the {{{ctypes}}} module comes included. [http://www.python.org/download/releases/2.5.1/ Python 2.5.1] is the current latest. 172 190 * '''PostgreSQL''' 173 * ''Recommended:'' PostgreSQL 8. X174 * We are currently using v8.1 of PostgreSQL, and know of no problems with 8.2191 * ''Recommended:'' PostgreSQL 8.x. If installing binary packages, please install the development package as well for headers required in PostGIS compilation. 192 * We are currently developing using both v8.1 and v8.2 of PostgreSQL. 175 193 * On Ubuntu Feisty, you'll need the apt packages {{{postgresql-server-dev-8.x}}} (the development headers are needed for PostGIS compilation) and {{{postgresql-8.x}}}. 194 * '''psycopg2''' 195 * [http://initd.org/tracker/psycopg/wiki/PsycopgTwo psycopg2] is a Python database adapter for PostgreSQL. Latest version is [http://initd.org/pub/software/psycopg/psycopg2-2.0.6.tar.gz 2.0.6]. 176 196 177 197 === Django === … … 183 203 184 204 === GEOS === 185 * Latest [http://geos.refractions.net/ GEOS] version is 3.0.0RC4186 * '''Update:''' As of r5008, you do ''not'' need to enable the Python bindings because GeoDjango has its own GEOS {{{ctypes}}} wrapper.205 * We have been developing using [http://geos.refractions.net/ GEOS] 3.0.0RC4, and have not tested or plan on supporting GEOS 2.x. 206 * GeoDjango has its own GEOS {{{ctypes}}} wrapper; you do ''not'' need to enable the existing GEOS Python bindings. 187 207 * {{{ctypes}}} comes standard with Python 2.5. If you run Python 2.4, {{{ctypes}}} may be [http://sourceforge.net/project/showfiles.php?group_id=71702&package_id=71318 downloaded here] 188 208 * Configure, make, and install. … … 194 214 195 215 === PROJ.4 === 196 * Latest [http://proj.maptools.org/ PROJ.4] version is 4.5.0 216 * Latest [http://proj.maptools.org/ PROJ.4] version is 4.5.0. We have no reason to believe that previous versions (''e.g.'', 4.4.x, 4.3.x) will not work. 197 217 * First, download the PROJ [ftp://ftp.remotesensing.org/proj/proj-datumgrid-1.3.tar.gz datum shifting files]. These will come in handy for coordinate transformations when other programs (like Mapserver or Mapnik) are not able to cope with EPSG transformations (I learned the hard way). Untar/unzip these in the {{{nad}}} subdirectory of the PROJ source. For example, if PROJ was unzipped in a directory named {{{proj}}}, then untar these files in {{{proj/nad}}}. Do this '''before''' you do the configure/make/install dance. 198 218 * ''See'' [http://remotesensing.org/proj/faq.html PROJ FAQ]; ''see also'' [http://mapserver.gis.umn.edu/data2/wilma/mapserver-users/0301/msg00541.html Frank Warmerdam's reply to a Mapserver question]. … … 205 225 206 226 === PostGIS === 207 * Latest [http://postgis.refractions.net/download/ PostGIS] version is 1.2.1 227 * '''Required''': PostGIS v1.1.0 and above. 228 * '''Recommended''': Postgis v1.2.1 [http://postgis.refractions.net/download/ PostGIS] and greater. 208 229 * First build & install PostGIS. 209 230 {{{ … … 231 252 232 253 === GDAL === 233 * ''Highly Recommended'': Some features (e.g. a large number of {{{SpatialRefSys}}} model routines) require GDAL, but it is not necessary for core functionality (e.g. spatial queries). 254 * ''Highly Recommended'': Some features (e.g. a large number of {{{SpatialRefSys}}} model routines) require GDAL, but it is not necessary for core functionality (e.g. spatial queries). 234 255 * GDAL/OGR includes useful for coordinate transformations and reading/writing ''both'' vector (e.g. SHP) and raster (e.g. GeoTIFF) geographic data. 235 256 * For example, the following command will convert your SHP file into [http://en.wikipedia.org/wiki/WGS84 WGS84] (standard lat/lon). Then you can import directly into your database using {{{shp2pgsql}}} (utility from PostGIS):