mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Refs #36485 -- Rewrapped docs to 79 columns line length.
Lines in the docs files were manually adjusted to conform to the 79 columns limit per line (plus newline), improving readability and consistency across the content.
This commit is contained in:
@@ -68,7 +68,8 @@ of using ``ogrinspect`` :ref:`in the tutorial <ogrinspect-intro>`.
|
||||
|
||||
.. django-admin-option:: --no-imports
|
||||
|
||||
Suppresses the ``from django.contrib.gis.db import models`` import statement.
|
||||
Suppresses the ``from django.contrib.gis.db import models`` import
|
||||
statement.
|
||||
|
||||
.. django-admin-option:: --null NULL
|
||||
|
||||
|
||||
@@ -45,7 +45,8 @@ model):
|
||||
>>> z = Zipcode(code=77096, poly="POLYGON(( 10 10, 10 20, 20 20, 20 15, 10 10))")
|
||||
>>> z.save()
|
||||
|
||||
:class:`~django.contrib.gis.geos.GEOSGeometry` objects may also be used to save geometric models:
|
||||
:class:`~django.contrib.gis.geos.GEOSGeometry` objects may also be used to save
|
||||
geometric models:
|
||||
|
||||
.. code-block:: pycon
|
||||
|
||||
@@ -72,8 +73,8 @@ transform procedure:
|
||||
... ) # printing the last SQL statement executed (requires DEBUG=True)
|
||||
INSERT INTO "geoapp_zipcode" ("code", "poly") VALUES (78212, ST_Transform(ST_GeomFromWKB('\\001 ... ', 3084), 4326))
|
||||
|
||||
Thus, geometry parameters may be passed in using the ``GEOSGeometry`` object, WKT
|
||||
(Well Known Text [#fnwkt]_), HEXEWKB (PostGIS specific -- a WKB geometry in
|
||||
Thus, geometry parameters may be passed in using the ``GEOSGeometry`` object,
|
||||
WKT (Well Known Text [#fnwkt]_), HEXEWKB (PostGIS specific -- a WKB geometry in
|
||||
hexadecimal [#fnewkb]_), and GeoJSON (see :rfc:`7946`). Essentially, if the
|
||||
input is not a ``GEOSGeometry`` object, the geometry field will attempt to
|
||||
create a ``GEOSGeometry`` instance from the input.
|
||||
@@ -169,10 +170,10 @@ For example:
|
||||
>>> qs = Zipcode.objects.filter(poly__contains=pnt)
|
||||
>>> qs = Elevation.objects.filter(poly__contains=rst)
|
||||
|
||||
In this case, ``poly`` is the geographic field, :lookup:`contains <gis-contains>`
|
||||
is the spatial lookup type, ``pnt`` is the parameter (which may be a
|
||||
:class:`~django.contrib.gis.geos.GEOSGeometry` object or a string of
|
||||
GeoJSON , WKT, or HEXEWKB), and ``rst`` is a
|
||||
In this case, ``poly`` is the geographic field,
|
||||
:lookup:`contains <gis-contains>` is the spatial lookup type, ``pnt`` is the
|
||||
parameter (which may be a :class:`~django.contrib.gis.geos.GEOSGeometry` object
|
||||
or a string of GeoJSON , WKT, or HEXEWKB), and ``rst`` is a
|
||||
:class:`~django.contrib.gis.gdal.GDALRaster` object.
|
||||
|
||||
.. _spatial-lookup-raster:
|
||||
@@ -181,9 +182,9 @@ Raster Lookups
|
||||
--------------
|
||||
|
||||
The raster lookup syntax is similar to the syntax for geometries. The only
|
||||
difference is that a band index can be specified as additional input. If no band
|
||||
index is specified, the first band is used by default (index ``0``). In that
|
||||
case the syntax is identical to the syntax for geometry lookups.
|
||||
difference is that a band index can be specified as additional input. If no
|
||||
band index is specified, the first band is used by default (index ``0``). In
|
||||
that case the syntax is identical to the syntax for geometry lookups.
|
||||
|
||||
To specify the band index, an additional parameter can be specified on both
|
||||
sides of the lookup. On the left hand side, the double underscore syntax is
|
||||
@@ -215,10 +216,11 @@ hand side, ``geom`` is a geometry input and ``rst`` is a
|
||||
:class:`~django.contrib.gis.gdal.GDALRaster` object. The band index defaults to
|
||||
``0`` in the first two queries and is set to ``1`` on the others.
|
||||
|
||||
While all spatial lookups can be used with raster objects on both sides, not all
|
||||
underlying operators natively accept raster input. For cases where the operator
|
||||
expects geometry input, the raster is automatically converted to a geometry.
|
||||
It's important to keep this in mind when interpreting the lookup results.
|
||||
While all spatial lookups can be used with raster objects on both sides, not
|
||||
all underlying operators natively accept raster input. For cases where the
|
||||
operator expects geometry input, the raster is automatically converted to a
|
||||
geometry. It's important to keep this in mind when interpreting the lookup
|
||||
results.
|
||||
|
||||
The type of raster support is listed for all lookups in the :ref:`compatibility
|
||||
table <spatial-lookup-compatibility>`. Lookups involving rasters are currently
|
||||
@@ -261,7 +263,8 @@ The following distance lookups are available:
|
||||
Distance lookups take a tuple parameter comprising:
|
||||
|
||||
#. A geometry or raster to base calculations from; and
|
||||
#. A number or :class:`~django.contrib.gis.measure.Distance` object containing the distance.
|
||||
#. A number or :class:`~django.contrib.gis.measure.Distance` object containing
|
||||
the distance.
|
||||
|
||||
If a :class:`~django.contrib.gis.measure.Distance` object is used,
|
||||
it may be expressed in any units (the SQL generated will use units
|
||||
@@ -271,16 +274,16 @@ to be in the units of the field.
|
||||
.. note::
|
||||
|
||||
In PostGIS, ``ST_Distance_Sphere`` does *not* limit the geometry types
|
||||
geographic distance queries are performed with. [#fndistsphere15]_ However,
|
||||
these queries may take a long time, as great-circle distances must be
|
||||
calculated on the fly for *every* row in the query. This is because the
|
||||
geographic distance queries are performed with. [#fndistsphere15]_
|
||||
However, these queries may take a long time, as great-circle distances must
|
||||
be calculated on the fly for *every* row in the query. This is because the
|
||||
spatial index on traditional geometry fields cannot be used.
|
||||
|
||||
For much better performance on WGS84 distance queries, consider using
|
||||
:ref:`geography columns <geography-type>` in your database instead because
|
||||
they are able to use their spatial index in distance queries.
|
||||
You can tell GeoDjango to use a geography column by setting ``geography=True``
|
||||
in your field definition.
|
||||
You can tell GeoDjango to use a geography column by setting
|
||||
``geography=True`` in your field definition.
|
||||
|
||||
For example, let's say we have a ``SouthTexasCity`` model (from the
|
||||
:source:`GeoDjango distance tests <tests/gis_tests/distapp/models.py>` ) on a
|
||||
|
||||
@@ -5,10 +5,10 @@ Geographic Feeds
|
||||
.. module:: django.contrib.gis.feeds
|
||||
:synopsis: GeoDjango's framework for generating spatial feeds.
|
||||
|
||||
GeoDjango has its own :class:`Feed` subclass that may embed location information
|
||||
in RSS/Atom feeds formatted according to either the `Simple GeoRSS`__ or
|
||||
`W3C Geo`_ standards. Because GeoDjango's syndication API is a superset of
|
||||
Django's, please consult :doc:`Django's syndication documentation
|
||||
GeoDjango has its own :class:`Feed` subclass that may embed location
|
||||
information in RSS/Atom feeds formatted according to either the `Simple
|
||||
GeoRSS`__ or `W3C Geo`_ standards. Because GeoDjango's syndication API is a
|
||||
superset of Django's, please consult :doc:`Django's syndication documentation
|
||||
</ref/contrib/syndication>` for details on general usage.
|
||||
|
||||
.. _W3C Geo: https://www.w3.org/2003/01/geo/
|
||||
|
||||
@@ -5,8 +5,8 @@ GeoDjango Forms API
|
||||
.. module:: django.contrib.gis.forms
|
||||
:synopsis: GeoDjango forms API.
|
||||
|
||||
GeoDjango provides some specialized form fields and widgets in order to visually
|
||||
display and edit geolocalized data on a map. By default, they use
|
||||
GeoDjango provides some specialized form fields and widgets in order to
|
||||
visually display and edit geolocalized data on a map. By default, they use
|
||||
`OpenLayers`_-powered maps, with a base WMS layer provided by `NASA`_.
|
||||
|
||||
.. _OpenLayers: https://openlayers.org/
|
||||
|
||||
@@ -29,7 +29,7 @@ Measurements
|
||||
.. class:: Area(expression, **extra)
|
||||
|
||||
*Availability*: MariaDB, `MySQL
|
||||
<https://dev.mysql.com/doc/refman/en/gis-polygon-property-functions.html#function_st-area>`_,
|
||||
<https://dev.mysql.com/doc/refman/en/gis-polygon-property-functions.html#function_st-area>`__,
|
||||
Oracle, `PostGIS <https://postgis.net/docs/ST_Area.html>`__, SpatiaLite
|
||||
|
||||
Accepts a single geographic field or expression and returns the area of the
|
||||
@@ -48,8 +48,8 @@ geographic SRSes.
|
||||
`PostGIS <https://postgis.net/docs/ST_Distance.html>`__, Oracle, SpatiaLite
|
||||
|
||||
Accepts two geographic fields or expressions and returns the distance between
|
||||
them, as a :class:`~django.contrib.gis.measure.Distance` object. On MySQL, a raw
|
||||
float value is returned when the coordinates are geodetic.
|
||||
them, as a :class:`~django.contrib.gis.measure.Distance` object. On MySQL, a
|
||||
raw float value is returned when the coordinates are geodetic.
|
||||
|
||||
On backends that support distance calculation on geodetic coordinates, the
|
||||
proper backend function is automatically chosen depending on the SRID value of
|
||||
@@ -81,18 +81,19 @@ queryset is calculated:
|
||||
.. note::
|
||||
|
||||
Because the ``distance`` attribute is a
|
||||
:class:`~django.contrib.gis.measure.Distance` object, you can easily express
|
||||
the value in the units of your choice. For example, ``city.distance.mi`` is
|
||||
the distance value in miles and ``city.distance.km`` is the distance value
|
||||
in kilometers. See :doc:`measure` for usage details and the list of
|
||||
:ref:`supported_units`.
|
||||
:class:`~django.contrib.gis.measure.Distance` object, you can easily
|
||||
express the value in the units of your choice. For example,
|
||||
``city.distance.mi`` is the distance value in miles and
|
||||
``city.distance.km`` is the distance value in kilometers. See
|
||||
:doc:`measure` for usage details and the list of :ref:`supported_units`.
|
||||
|
||||
``GeometryDistance``
|
||||
--------------------
|
||||
|
||||
.. class:: GeometryDistance(expr1, expr2, **extra)
|
||||
|
||||
*Availability*: `PostGIS <https://postgis.net/docs/geometry_distance_knn.html>`__
|
||||
*Availability*: `PostGIS
|
||||
<https://postgis.net/docs/geometry_distance_knn.html>`__
|
||||
|
||||
Accepts two geographic fields or expressions and returns the distance between
|
||||
them. When used in an :meth:`~django.db.models.query.QuerySet.order_by` clause,
|
||||
@@ -126,8 +127,8 @@ MySQL doesn't support length calculations on geographic SRSes.
|
||||
*Availability*: `PostGIS <https://postgis.net/docs/ST_Perimeter.html>`__,
|
||||
Oracle, SpatiaLite
|
||||
|
||||
Accepts a single geographic field or expression and returns the perimeter of the
|
||||
geometry field as a :class:`~django.contrib.gis.measure.Distance` object.
|
||||
Accepts a single geographic field or expression and returns the perimeter of
|
||||
the geometry field as a :class:`~django.contrib.gis.measure.Distance` object.
|
||||
|
||||
Relationships
|
||||
=============
|
||||
@@ -150,8 +151,9 @@ south = ``π``; west = ``3π/2``.
|
||||
|
||||
.. class:: BoundingCircle(expression, num_seg=48, **extra)
|
||||
|
||||
*Availability*: `PostGIS <https://postgis.net/docs/ST_MinimumBoundingCircle.html>`__,
|
||||
`Oracle <https://docs.oracle.com/en/database/oracle/oracle-database/21/spatl/
|
||||
*Availability*: `PostGIS
|
||||
<https://postgis.net/docs/ST_MinimumBoundingCircle.html>`__, `Oracle
|
||||
<https://docs.oracle.com/en/database/oracle/oracle-database/21/spatl/
|
||||
SDO_GEOM-reference.html#GUID-82A61626-BB64-4793-B53D-A0DBEC91831A>`_,
|
||||
SpatiaLite 5.1+
|
||||
|
||||
@@ -205,8 +207,8 @@ representing the bounding box of the geometry.
|
||||
*Availability*: `PostGIS <https://postgis.net/docs/ST_LineLocatePoint.html>`__,
|
||||
SpatiaLite
|
||||
|
||||
Returns a float between 0 and 1 representing the location of the closest point on
|
||||
``linestring`` to the given ``point``, as a fraction of the 2D line length.
|
||||
Returns a float between 0 and 1 representing the location of the closest point
|
||||
on ``linestring`` to the given ``point``, as a fraction of the 2D line length.
|
||||
|
||||
``PointOnSurface``
|
||||
------------------
|
||||
@@ -216,8 +218,9 @@ Returns a float between 0 and 1 representing the location of the closest point o
|
||||
*Availability*: `PostGIS <https://postgis.net/docs/ST_PointOnSurface.html>`__,
|
||||
MariaDB, Oracle, SpatiaLite
|
||||
|
||||
Accepts a single geographic field or expression and returns a ``Point`` geometry
|
||||
guaranteed to lie on the surface of the field; otherwise returns ``None``.
|
||||
Accepts a single geographic field or expression and returns a ``Point``
|
||||
geometry guaranteed to lie on the surface of the field; otherwise returns
|
||||
``None``.
|
||||
|
||||
Operations
|
||||
==========
|
||||
@@ -334,7 +337,8 @@ parameter.
|
||||
|
||||
.. class:: Scale(expression, x, y, z=0.0, **extra)
|
||||
|
||||
*Availability*: `PostGIS <https://postgis.net/docs/ST_Scale.html>`__, SpatiaLite
|
||||
*Availability*: `PostGIS <https://postgis.net/docs/ST_Scale.html>`__,
|
||||
SpatiaLite
|
||||
|
||||
Accepts a single geographic field or expression and returns a geometry with
|
||||
scaled coordinates by multiplying them with the ``x``, ``y``, and optionally
|
||||
@@ -469,8 +473,8 @@ Keyword Argument Description
|
||||
*Availability*: Oracle, `PostGIS <https://postgis.net/docs/ST_AsGML.html>`__,
|
||||
SpatiaLite
|
||||
|
||||
Accepts a single geographic field or expression and returns a `Geographic Markup
|
||||
Language (GML)`__ representation of the geometry.
|
||||
Accepts a single geographic field or expression and returns a `Geographic
|
||||
Markup Language (GML)`__ representation of the geometry.
|
||||
|
||||
Example:
|
||||
|
||||
@@ -498,7 +502,8 @@ __ https://en.wikipedia.org/wiki/Geography_Markup_Language
|
||||
|
||||
.. class:: AsKML(expression, precision=8, **extra)
|
||||
|
||||
*Availability*: `PostGIS <https://postgis.net/docs/ST_AsKML.html>`__, SpatiaLite
|
||||
*Availability*: `PostGIS <https://postgis.net/docs/ST_AsKML.html>`__,
|
||||
SpatiaLite
|
||||
|
||||
Accepts a single geographic field or expression and returns a `Keyhole Markup
|
||||
Language (KML)`__ representation of the geometry.
|
||||
@@ -527,7 +532,8 @@ __ https://developers.google.com/kml/documentation/
|
||||
|
||||
.. class:: AsSVG(expression, relative=False, precision=8, **extra)
|
||||
|
||||
*Availability*: `PostGIS <https://postgis.net/docs/ST_AsSVG.html>`__, SpatiaLite
|
||||
*Availability*: `PostGIS <https://postgis.net/docs/ST_AsSVG.html>`__,
|
||||
SpatiaLite
|
||||
|
||||
Accepts a single geographic field or expression and returns a `Scalable Vector
|
||||
Graphics (SVG)`__ representation of the geometry.
|
||||
@@ -668,8 +674,8 @@ Accepts a single geographic field or expression and returns the memory size
|
||||
SpatiaLite
|
||||
|
||||
Accepts a single geographic field or expression and returns the number of
|
||||
geometries if the geometry field is a collection (e.g., a ``GEOMETRYCOLLECTION``
|
||||
or ``MULTI*`` field). Returns 1 for single geometries.
|
||||
geometries if the geometry field is a collection (e.g., a
|
||||
``GEOMETRYCOLLECTION`` or ``MULTI*`` field). Returns 1 for single geometries.
|
||||
|
||||
On MySQL, returns ``None`` for single geometries.
|
||||
|
||||
@@ -682,7 +688,7 @@ On MySQL, returns ``None`` for single geometries.
|
||||
<https://dev.mysql.com/doc/refman/en/gis-linestring-property-functions.html#function_st-numpoints>`__,
|
||||
`PostGIS <https://postgis.net/docs/ST_NPoints.html>`__, Oracle, SpatiaLite
|
||||
|
||||
Accepts a single geographic field or expression and returns the number of points
|
||||
in a geometry.
|
||||
Accepts a single geographic field or expression and returns the number of
|
||||
points in a geometry.
|
||||
|
||||
On MySQL, returns ``None`` for any non-``LINESTRING`` geometry.
|
||||
|
||||
@@ -299,11 +299,11 @@ __ https://gdal.org/drivers/vector/
|
||||
``Feature`` wraps an OGR feature. You never create a ``Feature`` object
|
||||
directly. Instead, you retrieve them from a :class:`Layer` object. Each
|
||||
feature consists of a geometry and a set of fields containing additional
|
||||
properties. The geometry of a field is accessible via its ``geom`` property,
|
||||
which returns an :class:`OGRGeometry` object. A ``Feature`` behaves like a
|
||||
standard Python container for its fields, which it returns as :class:`Field`
|
||||
objects: you can access a field directly by its index or name, or you can
|
||||
iterate over a feature's fields, e.g. in a ``for`` loop.
|
||||
properties. The geometry of a field is accessible via its ``geom``
|
||||
property, which returns an :class:`OGRGeometry` object. A ``Feature``
|
||||
behaves like a standard Python container for its fields, which it returns
|
||||
as :class:`Field` objects: you can access a field directly by its index or
|
||||
name, or you can iterate over a feature's fields, e.g. in a ``for`` loop.
|
||||
|
||||
.. attribute:: geom
|
||||
|
||||
@@ -537,9 +537,9 @@ coordinate transformation:
|
||||
.. method:: __getitem__()
|
||||
|
||||
Returns the point at the specified index for a :class:`LineString`, the
|
||||
interior ring at the specified index for a :class:`Polygon`, or the geometry
|
||||
at the specified index in a :class:`GeometryCollection`. Not applicable to
|
||||
other geometry types.
|
||||
interior ring at the specified index for a :class:`Polygon`, or the
|
||||
geometry at the specified index in a :class:`GeometryCollection`. Not
|
||||
applicable to other geometry types.
|
||||
|
||||
.. attribute:: dimension
|
||||
|
||||
@@ -1273,28 +1273,28 @@ Raster Data Objects
|
||||
----------------
|
||||
|
||||
:class:`GDALRaster` is a wrapper for the GDAL raster source object that
|
||||
supports reading data from a variety of GDAL-supported geospatial file
|
||||
formats and data sources using a consistent interface. Each
|
||||
data source is represented by a :class:`GDALRaster` object which contains
|
||||
one or more layers of data named bands. Each band, represented by a
|
||||
:class:`GDALBand` object, contains georeferenced image data. For example, an RGB
|
||||
image is represented as three bands: one for red, one for green, and one for
|
||||
blue.
|
||||
supports reading data from a variety of GDAL-supported geospatial file formats
|
||||
and data sources using a consistent interface. Each data source is represented
|
||||
by a :class:`GDALRaster` object which contains one or more layers of data named
|
||||
bands. Each band, represented by a :class:`GDALBand` object, contains
|
||||
georeferenced image data. For example, an RGB image is represented as three
|
||||
bands: one for red, one for green, and one for blue.
|
||||
|
||||
.. note::
|
||||
|
||||
For raster data there is no difference between a raster instance and its
|
||||
data source. Unlike for the Geometry objects, :class:`GDALRaster` objects are
|
||||
always a data source. Temporary rasters can be instantiated in memory
|
||||
using the corresponding driver, but they will be of the same class as file-based
|
||||
raster sources.
|
||||
data source. Unlike for the Geometry objects, :class:`GDALRaster` objects
|
||||
are always a data source. Temporary rasters can be instantiated in memory
|
||||
using the corresponding driver, but they will be of the same class as
|
||||
file-based raster sources.
|
||||
|
||||
.. class:: GDALRaster(ds_input, write=False)
|
||||
|
||||
The constructor for ``GDALRaster`` accepts two parameters. The first
|
||||
parameter defines the raster source, and the second parameter defines if a
|
||||
raster should be opened in write mode. For newly-created rasters, the second
|
||||
parameter is ignored and the new raster is always created in write mode.
|
||||
raster should be opened in write mode. For newly-created rasters, the
|
||||
second parameter is ignored and the new raster is always created in write
|
||||
mode.
|
||||
|
||||
The first parameter can take three forms: a string or
|
||||
:class:`~pathlib.Path` representing a file path (filesystem or GDAL virtual
|
||||
@@ -1358,8 +1358,8 @@ blue.
|
||||
|
||||
.. attribute:: name
|
||||
|
||||
The name of the source which is equivalent to the input file path or the name
|
||||
provided upon instantiation.
|
||||
The name of the source which is equivalent to the input file path or
|
||||
the name provided upon instantiation.
|
||||
|
||||
.. code-block:: pycon
|
||||
|
||||
@@ -1368,11 +1368,12 @@ blue.
|
||||
|
||||
.. attribute:: driver
|
||||
|
||||
The name of the GDAL driver used to handle the input file. For ``GDALRaster``\s created
|
||||
from a file, the driver type is detected automatically. The creation of rasters from
|
||||
scratch is an in-memory raster by default (``'MEM'``), but can be
|
||||
altered as needed. For instance, use ``GTiff`` for a ``GeoTiff`` file.
|
||||
For a list of file types, see also the `GDAL Raster Formats`__ list.
|
||||
The name of the GDAL driver used to handle the input file. For
|
||||
``GDALRaster``\s created from a file, the driver type is detected
|
||||
automatically. The creation of rasters from scratch is an in-memory
|
||||
raster by default (``'MEM'``), but can be altered as needed. For
|
||||
instance, use ``GTiff`` for a ``GeoTiff`` file. For a list of file
|
||||
types, see also the `GDAL Raster Formats`__ list.
|
||||
|
||||
__ https://gdal.org/drivers/raster/
|
||||
|
||||
@@ -1572,10 +1573,11 @@ blue.
|
||||
for file-based rasters the warp function will create a new raster on
|
||||
disk.
|
||||
|
||||
The only parameter that is set differently from the source raster is the
|
||||
name. The default value of the raster name is the name of the source
|
||||
raster appended with ``'_copy' + source_driver_name``. For file-based
|
||||
rasters it is recommended to provide the file path of the target raster.
|
||||
The only parameter that is set differently from the source raster is
|
||||
the name. The default value of the raster name is the name of the
|
||||
source raster appended with ``'_copy' + source_driver_name``. For
|
||||
file-based rasters it is recommended to provide the file path of the
|
||||
target raster.
|
||||
|
||||
The resampling algorithm used for warping can be specified with the
|
||||
``resampling`` argument. The default is ``NearestNeighbor``, and the
|
||||
@@ -1714,7 +1716,8 @@ blue.
|
||||
|
||||
.. attribute:: pixel_count
|
||||
|
||||
The total number of pixels in this band. Is equal to ``width * height``.
|
||||
The total number of pixels in this band. Is equal to ``width *
|
||||
height``.
|
||||
|
||||
.. method:: statistics(refresh=False, approximate=False)
|
||||
|
||||
@@ -1764,8 +1767,8 @@ blue.
|
||||
.. attribute:: nodata_value
|
||||
|
||||
The "no data" value for a band is generally a special marker value used
|
||||
to mark pixels that are not valid data. Such pixels should generally not
|
||||
be displayed, nor contribute to analysis operations.
|
||||
to mark pixels that are not valid data. Such pixels should generally
|
||||
not be displayed, nor contribute to analysis operations.
|
||||
|
||||
To delete an existing "no data" value, set this property to ``None``.
|
||||
|
||||
@@ -1780,31 +1783,32 @@ blue.
|
||||
|
||||
The color interpretation for the band, as an integer between 0and 16.
|
||||
If ``as_string`` is ``True``, the data type is returned as a string
|
||||
with the following possible values:
|
||||
``GCI_Undefined``, ``GCI_GrayIndex``, ``GCI_PaletteIndex``,
|
||||
``GCI_RedBand``, ``GCI_GreenBand``, ``GCI_BlueBand``, ``GCI_AlphaBand``,
|
||||
with the following possible values: ``GCI_Undefined``,
|
||||
``GCI_GrayIndex``, ``GCI_PaletteIndex``, ``GCI_RedBand``,
|
||||
``GCI_GreenBand``, ``GCI_BlueBand``, ``GCI_AlphaBand``,
|
||||
``GCI_HueBand``, ``GCI_SaturationBand``, ``GCI_LightnessBand``,
|
||||
``GCI_CyanBand``, ``GCI_MagentaBand``, ``GCI_YellowBand``,
|
||||
``GCI_BlackBand``, ``GCI_YCbCr_YBand``, ``GCI_YCbCr_CbBand``, and
|
||||
``GCI_YCbCr_CrBand``. ``GCI_YCbCr_CrBand`` also represents ``GCI_Max``
|
||||
because both correspond to the integer 16, but only ``GCI_YCbCr_CrBand``
|
||||
is returned as a string.
|
||||
because both correspond to the integer 16, but only
|
||||
``GCI_YCbCr_CrBand`` is returned as a string.
|
||||
|
||||
.. method:: data(data=None, offset=None, size=None, shape=None)
|
||||
|
||||
The accessor to the pixel values of the ``GDALBand``. Returns the complete
|
||||
data array if no parameters are provided. A subset of the pixel array can
|
||||
be requested by specifying an offset and block size as tuples.
|
||||
The accessor to the pixel values of the ``GDALBand``. Returns the
|
||||
complete data array if no parameters are provided. A subset of the
|
||||
pixel array can be requested by specifying an offset and block size as
|
||||
tuples.
|
||||
|
||||
If NumPy is available, the data is returned as NumPy array. For performance
|
||||
reasons, it is highly recommended to use NumPy.
|
||||
If NumPy is available, the data is returned as NumPy array. For
|
||||
performance reasons, it is highly recommended to use NumPy.
|
||||
|
||||
Data is written to the ``GDALBand`` if the ``data`` parameter is provided.
|
||||
The input can be of one of the following types - packed string, buffer, list,
|
||||
array, and NumPy array. The number of items in the input should normally
|
||||
correspond to the total number of pixels in the band, or to the number
|
||||
of pixels for a specific block of pixel values if the ``offset`` and
|
||||
``size`` parameters are provided.
|
||||
Data is written to the ``GDALBand`` if the ``data`` parameter is
|
||||
provided. The input can be of one of the following types - packed
|
||||
string, buffer, list, array, and NumPy array. The number of items in
|
||||
the input should normally correspond to the total number of pixels in
|
||||
the band, or to the number of pixels for a specific block of pixel
|
||||
values if the ``offset`` and ``size`` parameters are provided.
|
||||
|
||||
If the number of items in the input is different from the target pixel
|
||||
block, the ``shape`` parameter must be specified. The shape is a tuple
|
||||
@@ -1927,8 +1931,8 @@ Key Default Usage
|
||||
.. object:: datatype
|
||||
|
||||
Integer representing the data type for all the bands. Defaults to ``6``
|
||||
(Float32). All bands of a new raster are required to have the same datatype.
|
||||
The value mapping is:
|
||||
(Float32). All bands of a new raster are required to have the same
|
||||
datatype. The value mapping is:
|
||||
|
||||
===== =============== ===================================
|
||||
Value GDAL Pixel Type Description
|
||||
|
||||
@@ -27,7 +27,8 @@ converted to a geometry where necessary using the `ST_Polygon
|
||||
<https://postgis.net/docs/RT_ST_Polygon.html>`_ function. See also the
|
||||
:ref:`introduction to raster lookups <spatial-lookup-raster>`.
|
||||
|
||||
The database operators used by the lookups can be divided into three categories:
|
||||
The database operators used by the lookups can be divided into three
|
||||
categories:
|
||||
|
||||
- Native raster support ``N``: the operator accepts rasters natively on both
|
||||
sides of the lookup, and raster input can be mixed with geometry inputs.
|
||||
@@ -65,8 +66,9 @@ Spatial lookups with rasters are only supported for PostGIS backends
|
||||
``bbcontains``
|
||||
--------------
|
||||
|
||||
*Availability*: `PostGIS <https://postgis.net/docs/ST_Geometry_Contain.html>`__,
|
||||
MariaDB, MySQL, SpatiaLite, PGRaster (Native)
|
||||
*Availability*: `PostGIS
|
||||
<https://postgis.net/docs/ST_Geometry_Contain.html>`__, MariaDB, MySQL,
|
||||
SpatiaLite, PGRaster (Native)
|
||||
|
||||
Tests if the geometry or raster field's bounding box completely contains the
|
||||
lookup geometry's bounding box.
|
||||
@@ -113,8 +115,9 @@ SpatiaLite ``MbrOverlaps(poly, geom)``
|
||||
``contained``
|
||||
-------------
|
||||
|
||||
*Availability*: `PostGIS <https://postgis.net/docs/ST_Geometry_Contained.html>`__,
|
||||
MariaDB, MySQL, SpatiaLite, PGRaster (Native)
|
||||
*Availability*: `PostGIS
|
||||
<https://postgis.net/docs/ST_Geometry_Contained.html>`__, MariaDB, MySQL,
|
||||
SpatiaLite, PGRaster (Native)
|
||||
|
||||
Tests if the geometry field's bounding box is completely contained by the
|
||||
lookup geometry's bounding box.
|
||||
@@ -161,8 +164,8 @@ SpatiaLite ``Contains(poly, geom)``
|
||||
``contains_properly``
|
||||
---------------------
|
||||
|
||||
*Availability*: `PostGIS <https://postgis.net/docs/ST_ContainsProperly.html>`__,
|
||||
PGRaster (Bilateral)
|
||||
*Availability*: `PostGIS
|
||||
<https://postgis.net/docs/ST_ContainsProperly.html>`__, PGRaster (Bilateral)
|
||||
|
||||
Returns true if the lookup geometry intersects the interior of the
|
||||
geometry field, but not the boundary (or exterior).
|
||||
@@ -453,9 +456,10 @@ SpatiaLite ``Overlaps(poly, geom)``
|
||||
*Availability*: `PostGIS <https://postgis.net/docs/ST_Relate.html>`__,
|
||||
MariaDB, Oracle, SpatiaLite, PGRaster (Conversion)
|
||||
|
||||
Tests if the geometry field is spatially related to the lookup geometry by
|
||||
the values given in the given pattern. This lookup requires a tuple parameter,
|
||||
``(geom, pattern)``; the form of ``pattern`` will depend on the spatial backend:
|
||||
Tests if the geometry field is spatially related to the lookup geometry by the
|
||||
values given in the given pattern. This lookup requires a tuple parameter,
|
||||
``(geom, pattern)``; the form of ``pattern`` will depend on the spatial
|
||||
backend:
|
||||
|
||||
MariaDB, PostGIS, and SpatiaLite
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@@ -612,11 +616,11 @@ PostGIS equivalent:
|
||||
``overlaps_left``
|
||||
-----------------
|
||||
|
||||
*Availability*: `PostGIS <https://postgis.net/docs/ST_Geometry_Overleft.html>`__,
|
||||
PGRaster (Bilateral)
|
||||
*Availability*: `PostGIS
|
||||
<https://postgis.net/docs/ST_Geometry_Overleft.html>`__, PGRaster (Bilateral)
|
||||
|
||||
Tests if the geometry field's bounding box overlaps or is to the left of the lookup
|
||||
geometry's bounding box.
|
||||
Tests if the geometry field's bounding box overlaps or is to the left of the
|
||||
lookup geometry's bounding box.
|
||||
|
||||
Example::
|
||||
|
||||
@@ -634,11 +638,11 @@ PostGIS equivalent:
|
||||
``overlaps_right``
|
||||
------------------
|
||||
|
||||
*Availability*: `PostGIS <https://postgis.net/docs/ST_Geometry_Overright.html>`__,
|
||||
PGRaster (Bilateral)
|
||||
*Availability*: `PostGIS
|
||||
<https://postgis.net/docs/ST_Geometry_Overright.html>`__, PGRaster (Bilateral)
|
||||
|
||||
Tests if the geometry field's bounding box overlaps or is to the right of the lookup
|
||||
geometry's bounding box.
|
||||
Tests if the geometry field's bounding box overlaps or is to the right of the
|
||||
lookup geometry's bounding box.
|
||||
|
||||
Example::
|
||||
|
||||
@@ -655,8 +659,8 @@ PostGIS equivalent:
|
||||
``overlaps_above``
|
||||
------------------
|
||||
|
||||
*Availability*: `PostGIS <https://postgis.net/docs/ST_Geometry_Overabove.html>`__,
|
||||
PGRaster (Conversion)
|
||||
*Availability*: `PostGIS
|
||||
<https://postgis.net/docs/ST_Geometry_Overabove.html>`__, PGRaster (Conversion)
|
||||
|
||||
Tests if the geometry field's bounding box overlaps or is above the lookup
|
||||
geometry's bounding box.
|
||||
@@ -676,8 +680,8 @@ PostGIS equivalent:
|
||||
``overlaps_below``
|
||||
------------------
|
||||
|
||||
*Availability*: `PostGIS <https://postgis.net/docs/ST_Geometry_Overbelow.html>`__,
|
||||
PGRaster (Conversion)
|
||||
*Availability*: `PostGIS
|
||||
<https://postgis.net/docs/ST_Geometry_Overbelow.html>`__, PGRaster (Conversion)
|
||||
|
||||
Tests if the geometry field's bounding box overlaps or is below the lookup
|
||||
geometry's bounding box.
|
||||
@@ -918,11 +922,11 @@ Example:
|
||||
*Availability*: `PostGIS <https://postgis.net/docs/ST_Collect.html>`__,
|
||||
MariaDB, MySQL, SpatiaLite
|
||||
|
||||
Returns a ``GEOMETRYCOLLECTION`` or a ``MULTI`` geometry object from the geometry
|
||||
column. This is analogous to a simplified version of the :class:`Union`
|
||||
aggregate, except it can be several orders of magnitude faster than performing
|
||||
a union because it rolls up geometries into a collection or multi object, not
|
||||
caring about dissolving boundaries.
|
||||
Returns a ``GEOMETRYCOLLECTION`` or a ``MULTI`` geometry object from the
|
||||
geometry column. This is analogous to a simplified version of the
|
||||
:class:`Union` aggregate, except it can be several orders of magnitude faster
|
||||
than performing a union because it rolls up geometries into a collection or
|
||||
multi object, not caring about dissolving boundaries.
|
||||
|
||||
.. versionchanged:: 6.0
|
||||
|
||||
@@ -955,8 +959,8 @@ Example:
|
||||
*Availability*: `PostGIS <https://postgis.net/docs/ST_3DExtent.html>`__
|
||||
|
||||
Returns the 3D extent of all ``geo_field`` in the ``QuerySet`` as a 6-tuple,
|
||||
comprising the lower left coordinate and upper right coordinate (each with x, y,
|
||||
and z coordinates).
|
||||
comprising the lower left coordinate and upper right coordinate (each with x,
|
||||
y, and z coordinates).
|
||||
|
||||
Example:
|
||||
|
||||
|
||||
@@ -101,10 +101,10 @@ Finally, there is the :func:`fromfile` factory method which returns a
|
||||
|
||||
You find many ``TypeError`` or ``AttributeError`` exceptions filling your
|
||||
web server's log files. This generally means that you are creating GEOS
|
||||
objects at the top level of some of your Python modules. Then, due to a race
|
||||
condition in the garbage collector, your module is garbage collected before
|
||||
the GEOS object. To prevent this, create :class:`GEOSGeometry` objects
|
||||
inside the local scope of your functions/methods.
|
||||
objects at the top level of some of your Python modules. Then, due to a
|
||||
race condition in the garbage collector, your module is garbage collected
|
||||
before the GEOS object. To prevent this, create :class:`GEOSGeometry`
|
||||
objects inside the local scope of your functions/methods.
|
||||
|
||||
Geometries are Pythonic
|
||||
-----------------------
|
||||
@@ -439,8 +439,8 @@ return a boolean.
|
||||
|
||||
.. method:: GEOSGeometry.contains(other)
|
||||
|
||||
Returns ``True`` if :meth:`other.within(this) <GEOSGeometry.within>` returns
|
||||
``True``.
|
||||
Returns ``True`` if :meth:`other.within(this) <GEOSGeometry.within>`
|
||||
returns ``True``.
|
||||
|
||||
.. method:: GEOSGeometry.covers(other)
|
||||
|
||||
@@ -456,8 +456,8 @@ return a boolean.
|
||||
|
||||
This predicate is similar to :meth:`GEOSGeometry.contains`, but is more
|
||||
inclusive (i.e. returns ``True`` for more cases). In particular, unlike
|
||||
:meth:`~GEOSGeometry.contains` it does not distinguish between points in the
|
||||
boundary and in the interior of geometries. For most situations,
|
||||
:meth:`~GEOSGeometry.contains` it does not distinguish between points in
|
||||
the boundary and in the interior of geometries. For most situations,
|
||||
``covers()`` should be preferred to :meth:`~GEOSGeometry.contains`. As an
|
||||
added benefit, ``covers()`` is more amenable to optimization and hence
|
||||
should outperform :meth:`~GEOSGeometry.contains`.
|
||||
@@ -507,9 +507,9 @@ return a boolean.
|
||||
|
||||
.. method:: GEOSGeometry.relate_pattern(other, pattern)
|
||||
|
||||
Returns ``True`` if the elements in the DE-9IM intersection matrix
|
||||
for this geometry and the other matches the given ``pattern`` --
|
||||
a string of nine characters from the alphabet: {``T``, ``F``, ``*``, ``0``}.
|
||||
Returns ``True`` if the elements in the DE-9IM intersection matrix for this
|
||||
geometry and the other matches the given ``pattern`` -- a string of nine
|
||||
characters from the alphabet: {``T``, ``F``, ``*``, ``0``}.
|
||||
|
||||
.. method:: GEOSGeometry.touches(other)
|
||||
|
||||
@@ -548,9 +548,9 @@ Topological Methods
|
||||
.. method:: GEOSGeometry.interpolate_normalized(distance)
|
||||
|
||||
Given a distance (float), returns the point (or closest point) within the
|
||||
geometry (:class:`LineString` or :class:`MultiLineString`) at that distance.
|
||||
The normalized version takes the distance as a float between 0 (origin) and
|
||||
1 (endpoint).
|
||||
geometry (:class:`LineString` or :class:`MultiLineString`) at that
|
||||
distance. The normalized version takes the distance as a float between 0
|
||||
(origin) and 1 (endpoint).
|
||||
|
||||
Reverse of :meth:`GEOSGeometry.project`.
|
||||
|
||||
@@ -583,10 +583,10 @@ Topological Methods
|
||||
|
||||
By default, this function does not preserve topology. For example,
|
||||
:class:`Polygon` objects can be split, be collapsed into lines, or
|
||||
disappear. :class:`Polygon` holes can be created or disappear, and lines may
|
||||
cross. By specifying ``preserve_topology=True``, the result will have the
|
||||
same dimension and number of components as the input; this is significantly
|
||||
slower, however.
|
||||
disappear. :class:`Polygon` holes can be created or disappear, and lines
|
||||
may cross. By specifying ``preserve_topology=True``, the result will have
|
||||
the same dimension and number of components as the input; this is
|
||||
significantly slower, however.
|
||||
|
||||
.. method:: GEOSGeometry.sym_difference(other)
|
||||
|
||||
@@ -633,13 +633,13 @@ Topological Properties
|
||||
|
||||
The result obeys the following contract:
|
||||
|
||||
* Unioning a set of :class:`LineString`\s has the effect of fully noding and
|
||||
dissolving the linework.
|
||||
* Unioning a set of :class:`LineString`\s has the effect of fully noding
|
||||
and dissolving the linework.
|
||||
|
||||
* Unioning a set of :class:`Polygon`\s will always return a :class:`Polygon`
|
||||
or :class:`MultiPolygon` geometry (unlike :meth:`GEOSGeometry.union`,
|
||||
which may return geometries of lower dimension if a topology collapse
|
||||
occurs).
|
||||
* Unioning a set of :class:`Polygon`\s will always return a
|
||||
:class:`Polygon` or :class:`MultiPolygon` geometry (unlike
|
||||
:meth:`GEOSGeometry.union`, which may return geometries of lower
|
||||
dimension if a topology collapse occurs).
|
||||
|
||||
Other Properties & Methods
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@@ -655,7 +655,8 @@ Other Properties & Methods
|
||||
|
||||
.. method:: GEOSGeometry.clone()
|
||||
|
||||
This method returns a :class:`GEOSGeometry` that is a clone of the original.
|
||||
This method returns a :class:`GEOSGeometry` that is a clone of the
|
||||
original.
|
||||
|
||||
.. method:: GEOSGeometry.distance(geom)
|
||||
|
||||
@@ -678,8 +679,8 @@ Other Properties & Methods
|
||||
|
||||
Returns a GEOS ``PreparedGeometry`` for the contents of this geometry.
|
||||
``PreparedGeometry`` objects are optimized for the contains, intersects,
|
||||
covers, crosses, disjoint, overlaps, touches and within operations. Refer to
|
||||
the :ref:`prepared-geometries` documentation for more information.
|
||||
covers, crosses, disjoint, overlaps, touches and within operations. Refer
|
||||
to the :ref:`prepared-geometries` documentation for more information.
|
||||
|
||||
.. attribute:: GEOSGeometry.srs
|
||||
|
||||
@@ -810,8 +811,8 @@ Other Properties & Methods
|
||||
|
||||
``Polygon`` objects may be instantiated by passing in parameters that
|
||||
represent the rings of the polygon. The parameters must either be
|
||||
:class:`LinearRing` instances, or a sequence that may be used to construct a
|
||||
:class:`LinearRing`:
|
||||
:class:`LinearRing` instances, or a sequence that may be used to construct
|
||||
a :class:`LinearRing`:
|
||||
|
||||
.. code-block:: pycon
|
||||
|
||||
@@ -973,7 +974,8 @@ Geometry Factories
|
||||
|
||||
:param file_h: input file that contains spatial data
|
||||
:type file_h: a Python ``file`` object or a string path to the file
|
||||
:rtype: a :class:`GEOSGeometry` corresponding to the spatial data in the file
|
||||
:rtype: a :class:`GEOSGeometry` corresponding to the spatial data in the
|
||||
file
|
||||
|
||||
Example:
|
||||
|
||||
@@ -988,7 +990,8 @@ Geometry Factories
|
||||
:type string: str
|
||||
:param srid: spatial reference identifier
|
||||
:type srid: int
|
||||
:rtype: a :class:`GEOSGeometry` corresponding to the spatial data in the string
|
||||
:rtype: a :class:`GEOSGeometry` corresponding to the spatial data in the
|
||||
string
|
||||
|
||||
``fromstr(string, srid)`` is equivalent to
|
||||
:class:`GEOSGeometry(string, srid) <GEOSGeometry>`.
|
||||
@@ -1144,8 +1147,8 @@ include the SRID value (in other words, EWKB).
|
||||
.. class:: WKTWriter(dim=2, trim=False, precision=None)
|
||||
|
||||
This class allows outputting the WKT representation of a geometry. See the
|
||||
:attr:`WKBWriter.outdim`, :attr:`trim`, and :attr:`precision` attributes for
|
||||
details about the constructor arguments.
|
||||
:attr:`WKBWriter.outdim`, :attr:`trim`, and :attr:`precision` attributes
|
||||
for details about the constructor arguments.
|
||||
|
||||
.. method:: WKTWriter.write(geom)
|
||||
|
||||
|
||||
@@ -145,10 +145,11 @@ When GeoDjango can't find GEOS, this error is raised:
|
||||
|
||||
ImportError: Could not find the GEOS library (tried "geos_c"). Try setting GEOS_LIBRARY_PATH in your settings.
|
||||
|
||||
The most common solution is to properly configure your :ref:`libsettings` *or* set
|
||||
:ref:`geoslibrarypath` in your settings.
|
||||
The most common solution is to properly configure your :ref:`libsettings` *or*
|
||||
set :ref:`geoslibrarypath` in your settings.
|
||||
|
||||
If using a binary package of GEOS (e.g., on Ubuntu), you may need to :ref:`binutils`.
|
||||
If using a binary package of GEOS (e.g., on Ubuntu), you may need to
|
||||
:ref:`binutils`.
|
||||
|
||||
.. _geoslibrarypath:
|
||||
|
||||
@@ -169,7 +170,8 @@ GEOS C library. For example:
|
||||
The setting must be the *full* path to the **C** shared library; in
|
||||
other words you want to use ``libgeos_c.so``, not ``libgeos.so``.
|
||||
|
||||
See also :ref:`My logs are filled with GEOS-related errors <geos-exceptions-in-logfile>`.
|
||||
See also :ref:`My logs are filled with GEOS-related errors
|
||||
<geos-exceptions-in-logfile>`.
|
||||
|
||||
.. _proj4:
|
||||
|
||||
@@ -192,8 +194,8 @@ PROJ < 7.x) [#]_:
|
||||
|
||||
$ wget https://download.osgeo.org/proj/proj-data-X.Y.tar.gz
|
||||
|
||||
Next, untar the source code archive, and extract the datum shifting files in the
|
||||
``data`` subdirectory. This must be done *prior* to configuration:
|
||||
Next, untar the source code archive, and extract the datum shifting files in
|
||||
the ``data`` subdirectory. This must be done *prior* to configuration:
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
|
||||
@@ -19,11 +19,12 @@ instructions are available for:
|
||||
|
||||
.. admonition:: Use the Source
|
||||
|
||||
Because GeoDjango takes advantage of the latest in the open source geospatial
|
||||
software technology, recent versions of the libraries are necessary.
|
||||
If binary packages aren't available for your platform, installation from
|
||||
source may be required. When compiling the libraries from source, please
|
||||
follow the directions closely, especially if you're a beginner.
|
||||
Because GeoDjango takes advantage of the latest in the open source
|
||||
geospatial software technology, recent versions of the libraries are
|
||||
necessary. If binary packages aren't available for your platform,
|
||||
installation from source may be required. When compiling the libraries from
|
||||
source, please follow the directions closely, especially if you're a
|
||||
beginner.
|
||||
|
||||
Requirements
|
||||
============
|
||||
@@ -99,7 +100,8 @@ Add ``django.contrib.gis`` to :setting:`INSTALLED_APPS`
|
||||
Like other Django contrib applications, you will *only* need to add
|
||||
:mod:`django.contrib.gis` to :setting:`INSTALLED_APPS` in your settings.
|
||||
This is so that the ``gis`` templates can be located -- if not done, then
|
||||
features such as the geographic admin or KML sitemaps will not function properly.
|
||||
features such as the geographic admin or KML sitemaps will not function
|
||||
properly.
|
||||
|
||||
Troubleshooting
|
||||
===============
|
||||
@@ -145,10 +147,11 @@ could place the following in their bash profile:
|
||||
Setting system library path
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
On GNU/Linux systems, there is typically a file in ``/etc/ld.so.conf``, which may include
|
||||
additional paths from files in another directory, such as ``/etc/ld.so.conf.d``.
|
||||
As the root user, add the custom library path (like ``/usr/local/lib``) on a
|
||||
new line in ``ld.so.conf``. This is *one* example of how to do so:
|
||||
On GNU/Linux systems, there is typically a file in ``/etc/ld.so.conf``, which
|
||||
may include additional paths from files in another directory, such as
|
||||
``/etc/ld.so.conf.d``. As the root user, add the custom library path (like
|
||||
``/usr/local/lib``) on a new line in ``ld.so.conf``. This is *one* example of
|
||||
how to do so:
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
@@ -174,10 +177,11 @@ module) to discover libraries. The ``find_library`` routine uses a program
|
||||
called ``objdump`` (part of the ``binutils`` package) to verify a shared
|
||||
library on GNU/Linux systems. Thus, if ``binutils`` is not installed on your
|
||||
Linux system then Python's ctypes may not be able to find your library even if
|
||||
your library path is set correctly and geospatial libraries were built perfectly.
|
||||
your library path is set correctly and geospatial libraries were built
|
||||
perfectly.
|
||||
|
||||
The ``binutils`` package may be installed on Debian and Ubuntu systems using the
|
||||
following command:
|
||||
The ``binutils`` package may be installed on Debian and Ubuntu systems using
|
||||
the following command:
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
@@ -279,9 +283,10 @@ __ https://brew.sh/
|
||||
Fink
|
||||
^^^^
|
||||
|
||||
`Kurt Schwehr`__ has been gracious enough to create GeoDjango packages for users
|
||||
of the `Fink`__ package system. `Different packages are available`__ (starting
|
||||
with ``django-gis``), depending on which version of Python you want to use.
|
||||
`Kurt Schwehr`__ has been gracious enough to create GeoDjango packages for
|
||||
users of the `Fink`__ package system. `Different packages are available`__
|
||||
(starting with ``django-gis``), depending on which version of Python you want
|
||||
to use.
|
||||
|
||||
__ https://schwehr.blogspot.com/
|
||||
__ https://www.finkproject.org/
|
||||
|
||||
@@ -39,8 +39,8 @@ command line interface and enter the following query:
|
||||
|
||||
sqlite> CREATE VIRTUAL TABLE testrtree USING rtree(id,minX,maxX,minY,maxY);
|
||||
|
||||
If you obtain an error, you will have to recompile SQLite from source. Otherwise,
|
||||
skip this section.
|
||||
If you obtain an error, you will have to recompile SQLite from source.
|
||||
Otherwise, skip this section.
|
||||
|
||||
To install from sources, download the latest amalgamation source archive from
|
||||
the `SQLite download page`__, and extract:
|
||||
@@ -51,8 +51,9 @@ the `SQLite download page`__, and extract:
|
||||
$ unzip sqlite-amalgamation-XXX0000.zip
|
||||
$ cd sqlite-amalgamation-XXX0000
|
||||
|
||||
Next, run the ``configure`` script -- however the ``CFLAGS`` environment variable
|
||||
needs to be customized so that SQLite knows to build the R*Tree module:
|
||||
Next, run the ``configure`` script -- however the ``CFLAGS`` environment
|
||||
variable needs to be customized so that SQLite knows to build the R*Tree
|
||||
module:
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
|
||||
@@ -21,12 +21,12 @@ then inserting into a GeoDjango model.
|
||||
|
||||
.. warning ::
|
||||
|
||||
GIS data sources, like shapefiles, may be very large. If you find
|
||||
that :class:`LayerMapping` is using too much memory, set
|
||||
:setting:`DEBUG` to ``False`` in your settings. When :setting:`DEBUG`
|
||||
is set to ``True``, Django :ref:`automatically logs <faq-see-raw-sql-queries>`
|
||||
*every* SQL query -- and when SQL statements contain geometries, this may
|
||||
consume more memory than is typical.
|
||||
GIS data sources, like shapefiles, may be very large. If you find that
|
||||
:class:`LayerMapping` is using too much memory, set :setting:`DEBUG` to
|
||||
``False`` in your settings. When :setting:`DEBUG` is set to ``True``,
|
||||
Django :ref:`automatically logs <faq-see-raw-sql-queries>` *every* SQL
|
||||
query -- and when SQL statements contain geometries, this may consume more
|
||||
memory than is typical.
|
||||
|
||||
Example
|
||||
=======
|
||||
@@ -52,7 +52,8 @@ Example
|
||||
PRIMEM["Greenwich",0],
|
||||
UNIT["Degree",0.017453292519943295]]
|
||||
|
||||
#. Now we define our corresponding Django model (make sure to use :djadmin:`migrate`)::
|
||||
#. Now we define our corresponding Django model (make sure to use
|
||||
:djadmin:`migrate`)::
|
||||
|
||||
from django.contrib.gis.db import models
|
||||
|
||||
|
||||
@@ -206,6 +206,7 @@ Measurement API
|
||||
Alias for :class:`Area` class.
|
||||
|
||||
.. rubric:: Footnotes
|
||||
.. [#] `Robert Coup <https://koordinates.com/>`_ is the initial author of the measure objects,
|
||||
and was inspired by Brian Beck's work in `geopy <https://github.com/geopy/geopy/>`_
|
||||
and Geoff Biggs' PhD work on dimensioned units for robotics.
|
||||
.. [#] `Robert Coup <https://koordinates.com/>`_ is the initial author of the
|
||||
measure objects, and was inspired by Brian Beck's work in `geopy
|
||||
<https://github.com/geopy/geopy/>`_ and Geoff Biggs' PhD work on
|
||||
dimensioned units for robotics.
|
||||
|
||||
@@ -108,9 +108,9 @@ All are optional.
|
||||
|
||||
.. 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
|
||||
of longitude and latitude).
|
||||
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 of longitude and latitude).
|
||||
|
||||
__ https://en.wikipedia.org/wiki/WGS84
|
||||
|
||||
@@ -121,12 +121,12 @@ Selecting an SRID
|
||||
|
||||
Choosing an appropriate SRID for your model is an important decision that the
|
||||
developer should consider carefully. The SRID is an integer specifier that
|
||||
corresponds to the projection system that will be used to interpret the data
|
||||
in the spatial database. [#fnsrid]_ Projection systems give the context to the
|
||||
corresponds to the projection system that will be used to interpret the data in
|
||||
the spatial database. [#fnsrid]_ Projection systems give the context to the
|
||||
coordinates that specify a location. Although the details of `geodesy`__ are
|
||||
beyond the scope of this documentation, the general problem is that the earth
|
||||
is spherical and representations of the earth (e.g., paper maps, web maps)
|
||||
are not.
|
||||
is spherical and representations of the earth (e.g., paper maps, web maps) are
|
||||
not.
|
||||
|
||||
Most people are familiar with using latitude and longitude to reference a
|
||||
location on the earth's surface. However, latitude and longitude are angles,
|
||||
@@ -139,7 +139,7 @@ Thus, additional computation is required to obtain distances in planar units
|
||||
(e.g., kilometers and miles). Using a geographic coordinate system may
|
||||
introduce complications for the developer later on. For example, SpatiaLite
|
||||
does not have the capability to perform distance calculations between
|
||||
geometries using geographic coordinate systems, e.g. constructing a query to
|
||||
geometries using geographic coordinate systems, e.g. constructing a query to
|
||||
find all points within 5 miles of a county boundary stored as WGS84. [#fndist]_
|
||||
|
||||
Portions of the earth's surface may projected onto a two-dimensional, or
|
||||
@@ -263,7 +263,7 @@ geography column to a geometry type in the query::
|
||||
|
||||
For more information, the PostGIS documentation contains a helpful section on
|
||||
determining `when to use geography data type over geometry data type
|
||||
<https://postgis.net/docs/using_postgis_dbmanagement.html#PostGIS_GeographyVSGeometry>`_.
|
||||
<https://postgis.net/docs/using_postgis_dbmanagement.html#PostGIS_GeographyVSGeometry>`__.
|
||||
|
||||
.. rubric:: Footnotes
|
||||
.. [#fnogc] OpenGIS Consortium, Inc., `Simple Feature Specification For SQL <https://www.ogc.org/standard/sfs/>`_.
|
||||
|
||||
@@ -13,8 +13,8 @@ __ https://geojson.org/
|
||||
The ``geojson`` serializer is not meant for round-tripping data, as it has no
|
||||
deserializer equivalent. For example, you cannot use :djadmin:`loaddata` to
|
||||
reload the output produced by this serializer. If you plan to reload the
|
||||
outputted data, use the plain :ref:`json serializer <serialization-formats-json>`
|
||||
instead.
|
||||
outputted data, use the plain :ref:`json serializer
|
||||
<serialization-formats-json>` instead.
|
||||
|
||||
In addition to the options of the ``json`` serializer, the ``geojson``
|
||||
serializer accepts the following additional option when it is called by
|
||||
@@ -23,7 +23,8 @@ serializer accepts the following additional option when it is called by
|
||||
* ``geometry_field``: A string containing the name of a geometry field to use
|
||||
for the ``geometry`` key of the GeoJSON feature. This is only needed when you
|
||||
have a model with more than one geometry field and you don't want to use the
|
||||
first defined geometry field (by default, the first geometry field is picked).
|
||||
first defined geometry field (by default, the first geometry field is
|
||||
picked).
|
||||
|
||||
* ``id_field``: A string containing the name of a field to use for the ``id``
|
||||
key of the GeoJSON feature. By default, the primary key of objects is used.
|
||||
|
||||
@@ -15,7 +15,8 @@ Settings
|
||||
|
||||
.. note::
|
||||
|
||||
The settings below have sensible defaults, and shouldn't require manual setting.
|
||||
The settings below have sensible defaults, and shouldn't require manual
|
||||
setting.
|
||||
|
||||
.. setting:: POSTGIS_VERSION
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@ Introduction
|
||||
============
|
||||
|
||||
GeoDjango is an included contrib module for Django that turns it into a
|
||||
world-class geographic web framework. GeoDjango strives to make it as simple
|
||||
as possible to create geographic web applications, like location-based services.
|
||||
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 and raster data.
|
||||
@@ -310,8 +310,8 @@ database via GeoDjango models using the :doc:`layermapping`.
|
||||
There are many different ways to import data into a spatial database --
|
||||
besides the tools included within GeoDjango, you may also use the following:
|
||||
|
||||
* `ogr2ogr`_: A command-line utility included with GDAL that
|
||||
can import many vector data formats into PostGIS, MySQL, and Oracle databases.
|
||||
* `ogr2ogr`_: A command-line utility included with GDAL that can import many
|
||||
vector data formats into PostGIS, MySQL, and Oracle databases.
|
||||
* `shp2pgsql`_: This utility included with PostGIS imports ESRI shapefiles into
|
||||
PostGIS.
|
||||
|
||||
@@ -375,12 +375,12 @@ You can see the layer's geometry type and how many features it contains:
|
||||
.. note::
|
||||
|
||||
Unfortunately, the shapefile data format does not allow for greater
|
||||
specificity with regards to geometry types. This shapefile, like
|
||||
many others, actually includes ``MultiPolygon`` geometries, not Polygons.
|
||||
It's important to use a more general field type in models: a
|
||||
GeoDjango ``MultiPolygonField`` will accept a ``Polygon`` geometry, but a
|
||||
``PolygonField`` will not accept a ``MultiPolygon`` type geometry. This
|
||||
is why the ``WorldBorder`` model defined above uses a ``MultiPolygonField``.
|
||||
specificity with regards to geometry types. This shapefile, like many
|
||||
others, actually includes ``MultiPolygon`` geometries, not Polygons. It's
|
||||
important to use a more general field type in models: a GeoDjango
|
||||
``MultiPolygonField`` will accept a ``Polygon`` geometry, but a
|
||||
``PolygonField`` will not accept a ``MultiPolygon`` type geometry. This is
|
||||
why the ``WorldBorder`` model defined above uses a ``MultiPolygonField``.
|
||||
|
||||
The :class:`~django.contrib.gis.gdal.Layer` may also have a spatial reference
|
||||
system associated with it. If it does, the ``srs`` attribute will return a
|
||||
@@ -412,18 +412,22 @@ units of degrees.
|
||||
In addition, shapefiles also support attribute fields that may contain
|
||||
additional data. Here are the fields on the World Borders layer:
|
||||
|
||||
.. code-block:: pycon
|
||||
|
||||
>>> print(lyr.fields)
|
||||
['FIPS', 'ISO2', 'ISO3', 'UN', 'NAME', 'AREA', 'POP2005', 'REGION', 'SUBREGION', 'LON', 'LAT']
|
||||
|
||||
The following code will let you examine the OGR types (e.g. integer or
|
||||
string) associated with each of the fields:
|
||||
|
||||
.. code-block:: pycon
|
||||
|
||||
>>> [fld.__name__ for fld in lyr.field_types]
|
||||
['OFTString', 'OFTString', 'OFTString', 'OFTInteger', 'OFTString', 'OFTInteger', 'OFTInteger64', 'OFTInteger', 'OFTInteger', 'OFTReal', 'OFTReal']
|
||||
|
||||
You can iterate over each feature in the layer and extract information from both
|
||||
the feature's geometry (accessed via the ``geom`` attribute) as well as the
|
||||
feature's attribute fields (whose **values** are accessed via ``get()``
|
||||
You can iterate over each feature in the layer and extract information from
|
||||
both the feature's geometry (accessed via the ``geom`` attribute) as well as
|
||||
the feature's attribute fields (whose **values** are accessed via ``get()``
|
||||
method):
|
||||
|
||||
.. code-block:: pycon
|
||||
@@ -769,7 +773,8 @@ application with the following code::
|
||||
|
||||
admin.site.register(WorldBorder, admin.ModelAdmin)
|
||||
|
||||
Next, edit your ``urls.py`` in the ``geodjango`` application folder as follows::
|
||||
Next, edit your ``urls.py`` in the ``geodjango`` application folder as
|
||||
follows::
|
||||
|
||||
from django.contrib import admin
|
||||
from django.urls import include, path
|
||||
|
||||
Reference in New Issue
Block a user