diff options
| author | Daniel Wiesmann <daniel.wiesmann@gmail.com> | 2015-06-19 16:46:03 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-06-19 14:36:43 -0400 |
| commit | b769bbd4f6a3cd1bcd9ebf3559ec6ea0f9b50565 (patch) | |
| tree | 48cb987ced74d60f75fd86306edc2f87c764362f /docs/ref | |
| parent | d3d66d47222dd8765a20a15fdc754c0ed7635404 (diff) | |
Fixed #23804 -- Added RasterField for PostGIS.
Thanks to Tim Graham and Claude Paroz for the reviews and patches.
Diffstat (limited to 'docs/ref')
| -rw-r--r-- | docs/ref/contrib/gis/db-api.txt | 48 | ||||
| -rw-r--r-- | docs/ref/contrib/gis/gdal.txt | 2 | ||||
| -rw-r--r-- | docs/ref/contrib/gis/model-api.txt | 59 | ||||
| -rw-r--r-- | docs/ref/contrib/gis/tutorial.txt | 6 |
4 files changed, 96 insertions, 19 deletions
diff --git a/docs/ref/contrib/gis/db-api.txt b/docs/ref/contrib/gis/db-api.txt index b5d4c4e3ce..cecb02de6c 100644 --- a/docs/ref/contrib/gis/db-api.txt +++ b/docs/ref/contrib/gis/db-api.txt @@ -49,8 +49,14 @@ on a different spatial backend. lookups and the integrity of your data -- MyISAM tables do not support transactions or foreign key constraints. -Creating and Saving Geographic Models -===================================== +Raster Support +-------------- + +``RasterField`` is currently only implemented for the PostGIS backend. Spatial +queries (such as lookups and distance) are not yet available for raster fields. + +Creating and Saving Models with Geometry Fields +=============================================== Here is an example of how to create a geometry object (assuming the ``Zipcode`` model):: @@ -87,6 +93,42 @@ create a ``GEOSGeometry`` instance from the input. For more information creating :class:`~django.contrib.gis.geos.GEOSGeometry` objects, refer to the :ref:`GEOS tutorial <geos-tutorial>`. +.. _creating-and-saving-raster-models: + +Creating and Saving Models with Raster Fields +============================================= + +.. versionadded:: 1.9 + +When creating raster models, the raster field will implicitly convert the input +into a :class:`~django.contrib.gis.gdal.GDALRaster` using lazy-evaluation. +The raster field will therefore accept any input that is accepted by the +:class:`~django.contrib.gis.gdal.GDALRaster` constructor. + +Here is an example of how to create a raster object from a raster file +``volcano.tif`` (assuming the ``Elevation`` model):: + + >>> from elevation.models import Elevation + >>> dem = Elevation(name='Volcano', rast='/path/to/raster/volcano.tif') + >>> dem.save() + +:class:`~django.contrib.gis.gdal.GDALRaster` objects may also be used to save +raster models:: + + >>> from django.contrib.gis.gdal import GDALRaster + >>> rast = GDALRaster({'width': 10, 'height': 10, 'name': 'Canyon', 'srid': 4326, + ... 'scale': [0.1, -0.1]'bands': [{"data": range(100)}]} + >>> dem = Elevation(name='Canyon', rast=rast) + >>> dem.save() + +Note that this equivalent to:: + + >>> dem = Elevation.objects.create( + ... name='Canyon', + ... rast={'width': 10, 'height': 10, 'name': 'Canyon', 'srid': 4326, + ... 'scale': [0.1, -0.1]'bands': [{"data": range(100)}]} + ... ) + .. _spatial-lookups-intro: Spatial Lookups @@ -122,6 +164,7 @@ Distance Queries Introduction ------------ + Distance calculations with spatial data is tricky because, unfortunately, the Earth is not flat. Some distance queries with fields in a geographic coordinate system may have to be expressed differently because of @@ -132,6 +175,7 @@ in the :doc:`model-api` documentation for more details. Distance Lookups ---------------- + *Availability*: PostGIS, Oracle, SpatiaLite The following distance lookups are available: diff --git a/docs/ref/contrib/gis/gdal.txt b/docs/ref/contrib/gis/gdal.txt index 49e26f7a82..25f3ecb153 100644 --- a/docs/ref/contrib/gis/gdal.txt +++ b/docs/ref/contrib/gis/gdal.txt @@ -1123,7 +1123,7 @@ blue. can be created from different input sources (using the sample data from the GeoDjango tests, see also the :ref:`gdal_sample_data` section):: - >>> from django.contrib.gis.gdal.raster.source import GDALRaster + >>> from django.contrib.gis.gdal import GDALRaster >>> rst = GDALRaster('/path/to/your/raster.tif', write=False) >>> rst.name '/path/to/your/raster.tif' diff --git a/docs/ref/contrib/gis/model-api.txt b/docs/ref/contrib/gis/model-api.txt index 92f2efc8c8..8f386ef284 100644 --- a/docs/ref/contrib/gis/model-api.txt +++ b/docs/ref/contrib/gis/model-api.txt @@ -6,8 +6,8 @@ GeoDjango Model API :synopsis: GeoDjango model and field API. This document explores the details of the GeoDjango Model API. Throughout this -section, we'll be using the following geographic model of a `ZIP code`__ as our -example:: +section, we'll be using the following geographic model of a `ZIP code`__ and +of a `Digital Elevation Model`__ as our examples:: from django.contrib.gis.db import models @@ -16,13 +16,19 @@ example:: poly = models.PolygonField() objects = models.GeoManager() + class Elevation(models.Model): + name = models.CharField(max_length=100) + rast = models.RasterField() + __ http://en.wikipedia.org/wiki/ZIP_code +__ https://en.wikipedia.org/wiki/Digital_elevation_model -Geometry Field Types -==================== +Spatial Field Types +=================== -Each of the following geometry field types correspond with the -OpenGIS Simple Features specification [#fnogc]_. +Spatial fields consist of a series of geometry field types and one raster field +type. Each of the geometry field types correspond to the OpenGIS Simple +Features specification [#fnogc]_. There is no such standard for raster data. ``GeometryField`` ----------------- @@ -64,19 +70,31 @@ OpenGIS Simple Features specification [#fnogc]_. .. class:: GeometryCollectionField -.. _geometry-field-options: +``RasterField`` +--------------- -Geometry Field Options -====================== +.. versionadded:: 1.9 + +.. class:: RasterField + +``RasterField`` is currently only implemented for the PostGIS backend. + +Spatial Field Options +===================== + +.. versionchanged:: 1.9 + + The geometry field options ``srid`` and ``spatial_index`` are now shared by + ``GeometryField`` and ``RasterField`` through the ``BaseSpatialField``. In addition to the regular :ref:`common-model-field-options` available for -Django model fields, geometry fields have the following additional options. +Django model fields, spatial fields have the following additional options. All are optional. ``srid`` -------- -.. attribute:: GeometryField.srid +.. attribute:: BaseSpatialField.srid Sets the SRID [#fnogcsrid]_ (Spatial Reference System Identity) of the geometry field to the given value. Defaults to 4326 (also known as `WGS84`__, units are in degrees @@ -144,7 +162,7 @@ __ http://web.archive.org/web/20080302095452/http://welcome.warnercnr.colostate. ``spatial_index`` ----------------- -.. attribute:: GeometryField.spatial_index +.. attribute:: BaseSpatialField.spatial_index Defaults to ``True``. Creates a spatial index for the given geometry field. @@ -157,6 +175,14 @@ field. a variant of the R-Tree, while regular database indexes typically use B-Trees. +.. _geometry-field-options: + +Geometry Field Options +====================== + +There are additional options available for Geometry fields. All the following +options are optional. + ``dim`` ------- @@ -223,7 +249,14 @@ determining `when to use geography data type over geometry data type In order to conduct geographic queries, each geographic model requires a ``GeoManager`` model manager. This manager allows for the proper SQL construction for geographic queries; thus, without it, all geographic filters -will fail. It should also be noted that ``GeoManager`` is required even if the +will fail. + +.. note:: + + Geographic filtering support is limited to geometry fields. ``RasterField`` + does not currently allow spatial querying. + +It should also be noted that ``GeoManager`` is required even if the model does not have a geographic field itself, e.g., in the case of a ``ForeignKey`` relation to a model with a geographic field. For example, if we had an ``Address`` model with a ``ForeignKey`` to our ``Zipcode`` diff --git a/docs/ref/contrib/gis/tutorial.txt b/docs/ref/contrib/gis/tutorial.txt index 71e5304082..9abcd857ff 100644 --- a/docs/ref/contrib/gis/tutorial.txt +++ b/docs/ref/contrib/gis/tutorial.txt @@ -10,10 +10,10 @@ world-class geographic Web framework. GeoDjango strives to make it as simple as possible to create geographic Web applications, like location-based services. Its features include: -* Django model fields for `OGC`_ geometries. +* Django model fields for `OGC`_ geometries and raster data. * Extensions to Django's ORM for querying and manipulating spatial data. -* Loosely-coupled, high-level Python interfaces for GIS geometry operations and - data formats. +* Loosely-coupled, high-level Python interfaces for GIS geometry and raster + operations and data manipulation in different formats. * Editing geometry fields from the admin. This tutorial assumes familiarity with Django; thus, if you're brand new to |
