mirror of
https://github.com/django/django.git
synced 2025-03-12 10:22:37 +00:00
Fixed #25974 -- Switched GIS docs to 4 spaces indentation.
This commit is contained in:
parent
dbaa1a6b59
commit
23e1ad537a
@ -26,10 +26,10 @@ API Reference
|
||||
|
||||
.. class:: Feed
|
||||
|
||||
In addition to methods provided by
|
||||
the :class:`django.contrib.syndication.views.Feed`
|
||||
base class, GeoDjango's ``Feed`` class provides
|
||||
the following overrides. Note that these overrides may be done in multiple ways::
|
||||
In addition to methods provided by the
|
||||
:class:`django.contrib.syndication.views.Feed` base class, GeoDjango's
|
||||
``Feed`` class provides the following overrides. Note that these overrides
|
||||
may be done in multiple ways::
|
||||
|
||||
from django.contrib.gis.feeds import Feed
|
||||
|
||||
@ -56,8 +56,8 @@ API Reference
|
||||
.. method:: geometry(obj)
|
||||
|
||||
Takes the object returned by ``get_object()`` and returns the *feed's*
|
||||
geometry. Typically this is a ``GEOSGeometry`` instance, or can be a
|
||||
tuple to represent a point or a box. For example::
|
||||
geometry. Typically this is a ``GEOSGeometry`` instance, or can be a tuple
|
||||
to represent a point or a box. For example::
|
||||
|
||||
class ZipcodeFeed(Feed):
|
||||
|
||||
@ -67,9 +67,9 @@ API Reference
|
||||
|
||||
.. method:: item_geometry(item)
|
||||
|
||||
Set this to return the geometry for each *item* in the feed. This
|
||||
can be a ``GEOSGeometry`` instance, or a tuple that represents a
|
||||
point coordinate or bounding box. For example::
|
||||
Set this to return the geometry for each *item* in the feed. This can be a
|
||||
``GEOSGeometry`` instance, or a tuple that represents a point coordinate or
|
||||
bounding box. For example::
|
||||
|
||||
class ZipcodeFeed(Feed):
|
||||
|
||||
|
@ -18,8 +18,8 @@ to raster (image) data.
|
||||
|
||||
.. note::
|
||||
|
||||
Although the module is named ``gdal``, GeoDjango only supports
|
||||
some of the capabilities of OGR and GDAL's raster features at this time.
|
||||
Although the module is named ``gdal``, GeoDjango only supports some of the
|
||||
capabilities of OGR and GDAL's raster features at this time.
|
||||
|
||||
__ http://www.gdal.org/
|
||||
__ http://www.gdal.org/ogr_arch.html
|
||||
@ -61,22 +61,20 @@ each feature in that layer.
|
||||
.. class:: DataSource(ds_input, encoding='utf-8')
|
||||
|
||||
The constructor for ``DataSource`` only requires one parameter: the path of
|
||||
the file you want to read. However, OGR
|
||||
also supports a variety of more complex data sources, including
|
||||
databases, that may be accessed by passing a special name string instead
|
||||
of a path. For more information, see the `OGR Vector Formats`__
|
||||
documentation. The :attr:`name` property of a ``DataSource``
|
||||
instance gives the OGR name of the underlying data source that it is
|
||||
using.
|
||||
the file you want to read. However, OGR also supports a variety of more
|
||||
complex data sources, including databases, that may be accessed by passing
|
||||
a special name string instead of a path. For more information, see the
|
||||
`OGR Vector Formats`__ documentation. The :attr:`name` property of a
|
||||
``DataSource`` instance gives the OGR name of the underlying data source
|
||||
that it is using.
|
||||
|
||||
The optional ``encoding`` parameter allows you to
|
||||
specify a non-standard encoding of the strings in the source. This is
|
||||
typically useful when you obtain ``DjangoUnicodeDecodeError`` exceptions
|
||||
while reading field values.
|
||||
The optional ``encoding`` parameter allows you to specify a non-standard
|
||||
encoding of the strings in the source. This is typically useful when you
|
||||
obtain ``DjangoUnicodeDecodeError`` exceptions while reading field values.
|
||||
|
||||
Once you've created your ``DataSource``, you can find out how many
|
||||
layers of data it contains by accessing the :attr:`layer_count` property,
|
||||
or (equivalently) by using the ``len()`` function. For information on
|
||||
Once you've created your ``DataSource``, you can find out how many layers
|
||||
of data it contains by accessing the :attr:`layer_count` property, or
|
||||
(equivalently) by using the ``len()`` function. For information on
|
||||
accessing the layers of data themselves, see the next section::
|
||||
|
||||
>>> from django.contrib.gis.gdal import DataSource
|
||||
@ -101,18 +99,17 @@ __ http://www.gdal.org/ogr_formats.html
|
||||
|
||||
.. class:: Layer
|
||||
|
||||
``Layer`` is a wrapper for a layer of data in a ``DataSource`` object.
|
||||
You never create a ``Layer`` object directly. Instead, you retrieve
|
||||
them from a :class:`DataSource` object, which is essentially a standard
|
||||
Python container of ``Layer`` objects. For example, you can access a
|
||||
specific layer by its index (e.g. ``ds[0]`` to access the first
|
||||
layer), or you can iterate over all the layers in the container in a
|
||||
``for`` loop. The ``Layer`` itself acts as a container for geometric
|
||||
features.
|
||||
``Layer`` is a wrapper for a layer of data in a ``DataSource`` object. You
|
||||
never create a ``Layer`` object directly. Instead, you retrieve them from
|
||||
a :class:`DataSource` object, which is essentially a standard Python
|
||||
container of ``Layer`` objects. For example, you can access a specific
|
||||
layer by its index (e.g. ``ds[0]`` to access the first layer), or you can
|
||||
iterate over all the layers in the container in a ``for`` loop. The
|
||||
``Layer`` itself acts as a container for geometric features.
|
||||
|
||||
Typically, all the features in a given layer have the same geometry type.
|
||||
The :attr:`geom_type` property of a layer is an :class:`OGRGeomType`
|
||||
that identifies the feature type. We can use it to print out some basic
|
||||
The :attr:`geom_type` property of a layer is an :class:`OGRGeomType` that
|
||||
identifies the feature type. We can use it to print out some basic
|
||||
information about each layer in a :class:`DataSource`::
|
||||
|
||||
>>> for layer in ds:
|
||||
@ -143,8 +140,7 @@ __ http://www.gdal.org/ogr_formats.html
|
||||
|
||||
.. attribute:: geom_type
|
||||
|
||||
Returns the geometry type of the layer, as an :class:`OGRGeomType`
|
||||
object::
|
||||
Returns the geometry type of the layer, as an :class:`OGRGeomType` object::
|
||||
|
||||
>>> layer.geom_type.name
|
||||
'Point'
|
||||
@ -166,41 +162,39 @@ __ http://www.gdal.org/ogr_formats.html
|
||||
|
||||
.. attribute field_types
|
||||
|
||||
Returns a list of the data types of each of the fields in this layer.
|
||||
These are subclasses of ``Field``, discussed below::
|
||||
Returns a list of the data types of each of the fields in this layer. These
|
||||
are subclasses of ``Field``, discussed below::
|
||||
|
||||
>>> [ft.__name__ for ft in layer.field_types]
|
||||
['OFTString', 'OFTReal', 'OFTReal', 'OFTDate']
|
||||
|
||||
.. attribute:: field_widths
|
||||
|
||||
Returns a list of the maximum field widths for each of the fields in
|
||||
this layer::
|
||||
Returns a list of the maximum field widths for each of the fields in this
|
||||
layer::
|
||||
|
||||
>>> layer.field_widths
|
||||
[80, 11, 24, 10]
|
||||
|
||||
.. attribute:: field_precisions
|
||||
|
||||
Returns a list of the numeric precisions for each of the fields in
|
||||
this layer. This is meaningless (and set to zero) for non-numeric
|
||||
fields::
|
||||
Returns a list of the numeric precisions for each of the fields in this
|
||||
layer. This is meaningless (and set to zero) for non-numeric fields::
|
||||
|
||||
>>> layer.field_precisions
|
||||
[0, 0, 15, 0]
|
||||
|
||||
.. attribute:: extent
|
||||
|
||||
Returns the spatial extent of this layer, as an :class:`Envelope`
|
||||
object::
|
||||
Returns the spatial extent of this layer, as an :class:`Envelope` object::
|
||||
|
||||
>>> layer.extent.tuple
|
||||
(-104.609252, 29.763374, -95.23506, 38.971823)
|
||||
|
||||
.. attribute:: srs
|
||||
|
||||
Property that returns the :class:`SpatialReference` associated
|
||||
with this layer::
|
||||
Property that returns the :class:`SpatialReference` associated with this
|
||||
layer::
|
||||
|
||||
>>> print(layer.srs)
|
||||
GEOGCS["GCS_WGS_1984",
|
||||
@ -216,9 +210,9 @@ __ http://www.gdal.org/ogr_formats.html
|
||||
|
||||
Property that may be used to retrieve or set a spatial filter for this
|
||||
layer. A spatial filter can only be set with an :class:`OGRGeometry`
|
||||
instance, a 4-tuple extent, or ``None``. When set with something
|
||||
other than ``None``, only features that intersect the filter will be
|
||||
returned when iterating over the layer::
|
||||
instance, a 4-tuple extent, or ``None``. When set with something other than
|
||||
``None``, only features that intersect the filter will be returned when
|
||||
iterating over the layer::
|
||||
|
||||
>>> print(layer.spatial_filter)
|
||||
None
|
||||
@ -246,9 +240,9 @@ __ http://www.gdal.org/ogr_formats.html
|
||||
|
||||
.. method:: get_geoms(geos=False)
|
||||
|
||||
A method that returns a list containing the geometry of each feature
|
||||
in the layer. If the optional argument ``geos`` is set to ``True``
|
||||
then the geometries are converted to :class:`~django.contrib.gis.geos.GEOSGeometry`
|
||||
A method that returns a list containing the geometry of each feature in the
|
||||
layer. If the optional argument ``geos`` is set to ``True`` then the
|
||||
geometries are converted to :class:`~django.contrib.gis.geos.GEOSGeometry`
|
||||
objects. Otherwise, they are returned as :class:`OGRGeometry` objects::
|
||||
|
||||
>>> [pt.tuple for pt in layer.get_geoms()]
|
||||
@ -256,9 +250,9 @@ __ http://www.gdal.org/ogr_formats.html
|
||||
|
||||
.. method:: test_capability(capability)
|
||||
|
||||
Returns a boolean indicating whether this layer supports the
|
||||
given capability (a string). Examples of valid capability strings
|
||||
include: ``'RandomRead'``, ``'SequentialWrite'``, ``'RandomWrite'``,
|
||||
Returns a boolean indicating whether this layer supports the given
|
||||
capability (a string). Examples of valid capability strings include:
|
||||
``'RandomRead'``, ``'SequentialWrite'``, ``'RandomWrite'``,
|
||||
``'FastSpatialFilter'``, ``'FastFeatureCount'``, ``'FastGetExtent'``,
|
||||
``'CreateField'``, ``'Transactions'``, ``'DeleteFeature'``, and
|
||||
``'FastSetNextByIndex'``.
|
||||
@ -268,15 +262,14 @@ __ http://www.gdal.org/ogr_formats.html
|
||||
|
||||
.. class:: Feature
|
||||
|
||||
|
||||
``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.
|
||||
``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.
|
||||
|
||||
.. attribute:: geom
|
||||
|
||||
@ -296,22 +289,22 @@ __ http://www.gdal.org/ogr_formats.html
|
||||
.. attribute:: geom_type
|
||||
|
||||
Returns the type of geometry for this feature, as an :class:`OGRGeomType`
|
||||
object. This will be the same for all features in a given layer, and
|
||||
is equivalent to the :attr:`Layer.geom_type` property of the
|
||||
:class:`Layer` object the feature came from.
|
||||
object. This will be the same for all features in a given layer and is
|
||||
equivalent to the :attr:`Layer.geom_type` property of the :class:`Layer`
|
||||
object the feature came from.
|
||||
|
||||
.. attribute:: num_fields
|
||||
|
||||
Returns the number of fields of data associated with the feature.
|
||||
This will be the same for all features in a given layer, and is
|
||||
equivalent to the :attr:`Layer.num_fields` property of the
|
||||
:class:`Layer` object the feature came from.
|
||||
Returns the number of fields of data associated with the feature. This will
|
||||
be the same for all features in a given layer and is equivalent to the
|
||||
:attr:`Layer.num_fields` property of the :class:`Layer` object the feature
|
||||
came from.
|
||||
|
||||
.. attribute:: fields
|
||||
|
||||
Returns a list of the names of the fields of data associated with the
|
||||
feature. This will be the same for all features in a given layer, and
|
||||
is equivalent to the :attr:`Layer.fields` property of the :class:`Layer`
|
||||
feature. This will be the same for all features in a given layer and is
|
||||
equivalent to the :attr:`Layer.fields` property of the :class:`Layer`
|
||||
object the feature came from.
|
||||
|
||||
.. attribute:: fid
|
||||
@ -323,16 +316,16 @@ __ http://www.gdal.org/ogr_formats.html
|
||||
|
||||
.. attribute:: layer_name
|
||||
|
||||
Returns the name of the :class:`Layer` that the feature came from.
|
||||
This will be the same for all features in a given layer::
|
||||
Returns the name of the :class:`Layer` that the feature came from. This
|
||||
will be the same for all features in a given layer::
|
||||
|
||||
>>> city.layer_name
|
||||
'cities'
|
||||
|
||||
.. attribute:: index
|
||||
|
||||
A method that returns the index of the given field name. This will be
|
||||
the same for all features in a given layer::
|
||||
A method that returns the index of the given field name. This will be the
|
||||
same for all features in a given layer::
|
||||
|
||||
>>> city.index('Population')
|
||||
1
|
||||
@ -351,9 +344,8 @@ __ http://www.gdal.org/ogr_formats.html
|
||||
|
||||
.. attribute:: type
|
||||
|
||||
Returns the OGR type of this field, as an integer. The
|
||||
``FIELD_CLASSES`` dictionary maps these values onto
|
||||
subclasses of ``Field``::
|
||||
Returns the OGR type of this field, as an integer. The ``FIELD_CLASSES``
|
||||
dictionary maps these values onto subclasses of ``Field``::
|
||||
|
||||
>>> city['Density'].type
|
||||
2
|
||||
@ -367,9 +359,9 @@ __ http://www.gdal.org/ogr_formats.html
|
||||
|
||||
.. attribute:: value
|
||||
|
||||
Returns the value of this field. The ``Field`` class itself
|
||||
returns the value as a string, but each subclass returns the
|
||||
value in the most appropriate form::
|
||||
Returns the value of this field. The ``Field`` class itself returns the
|
||||
value as a string, but each subclass returns the value in the most
|
||||
appropriate form::
|
||||
|
||||
>>> city['Population'].value
|
||||
102121
|
||||
@ -383,8 +375,8 @@ __ http://www.gdal.org/ogr_formats.html
|
||||
|
||||
.. attribute:: precision
|
||||
|
||||
Returns the numeric precision of this field. This is meaningless (and
|
||||
set to zero) for non-numeric fields::
|
||||
Returns the numeric precision of this field. This is meaningless (and set
|
||||
to zero) for non-numeric fields::
|
||||
|
||||
>>> city['Density'].precision
|
||||
15
|
||||
@ -422,13 +414,13 @@ __ http://www.gdal.org/ogr_formats.html
|
||||
|
||||
.. class:: Driver(dr_input)
|
||||
|
||||
The ``Driver`` class is used internally to wrap an OGR :class:`DataSource` driver.
|
||||
The ``Driver`` class is used internally to wrap an OGR :class:`DataSource`
|
||||
driver.
|
||||
|
||||
.. attribute:: driver_count
|
||||
|
||||
Returns the number of OGR vector drivers currently registered.
|
||||
|
||||
|
||||
OGR Geometries
|
||||
==============
|
||||
|
||||
@ -436,24 +428,23 @@ OGR Geometries
|
||||
---------------
|
||||
|
||||
:class:`OGRGeometry` objects share similar functionality with
|
||||
:class:`~django.contrib.gis.geos.GEOSGeometry` objects, and are thin
|
||||
wrappers around OGR's internal geometry representation. Thus,
|
||||
they allow for more efficient access to data when using :class:`DataSource`.
|
||||
Unlike its GEOS counterpart, :class:`OGRGeometry` supports spatial reference
|
||||
systems and coordinate transformation::
|
||||
:class:`~django.contrib.gis.geos.GEOSGeometry` objects and are thin wrappers
|
||||
around OGR's internal geometry representation. Thus, they allow for more
|
||||
efficient access to data when using :class:`DataSource`. Unlike its GEOS
|
||||
counterpart, :class:`OGRGeometry` supports spatial reference systems and
|
||||
coordinate transformation::
|
||||
|
||||
>>> from django.contrib.gis.gdal import OGRGeometry
|
||||
>>> polygon = OGRGeometry('POLYGON((0 0, 5 0, 5 5, 0 5))')
|
||||
|
||||
.. class:: OGRGeometry(geom_input, srs=None)
|
||||
|
||||
This object is a wrapper for the `OGR Geometry`__ class.
|
||||
These objects are instantiated directly from the given ``geom_input``
|
||||
parameter, which may be a string containing WKT, HEX, GeoJSON, a ``buffer``
|
||||
containing WKB data, or an :class:`OGRGeomType` object. These objects
|
||||
are also returned from the :class:`Feature.geom` attribute, when
|
||||
reading vector data from :class:`Layer` (which is in turn a part of
|
||||
a :class:`DataSource`).
|
||||
This object is a wrapper for the `OGR Geometry`__ class. These objects are
|
||||
instantiated directly from the given ``geom_input`` parameter, which may be
|
||||
a string containing WKT, HEX, GeoJSON, a ``buffer`` containing WKB data, or
|
||||
an :class:`OGRGeomType` object. These objects are also returned from the
|
||||
:class:`Feature.geom` attribute, when reading vector data from
|
||||
:class:`Layer` (which is in turn a part of a :class:`DataSource`).
|
||||
|
||||
__ http://www.gdal.org/classOGRGeometry.html
|
||||
|
||||
@ -463,8 +454,8 @@ systems and coordinate transformation::
|
||||
|
||||
.. method:: __len__()
|
||||
|
||||
Returns the number of points in a :class:`LineString`, the
|
||||
number of rings in a :class:`Polygon`, or the number of geometries in a
|
||||
Returns the number of points in a :class:`LineString`, the number of rings
|
||||
in a :class:`Polygon`, or the number of geometries in a
|
||||
:class:`GeometryCollection`. Not applicable to other geometry types.
|
||||
|
||||
.. method:: __iter__()
|
||||
@ -490,8 +481,8 @@ systems and coordinate transformation::
|
||||
|
||||
.. attribute:: coord_dim
|
||||
|
||||
Returns or sets the coordinate dimension of this geometry. For
|
||||
example, the value would be 2 for two-dimensional geometries.
|
||||
Returns or sets the coordinate dimension of this geometry. For example, the
|
||||
value would be 2 for two-dimensional geometries.
|
||||
|
||||
.. attribute:: geom_count
|
||||
|
||||
@ -528,8 +519,8 @@ systems and coordinate transformation::
|
||||
|
||||
.. attribute:: area
|
||||
|
||||
Returns the area of this geometry, or 0 for geometries that do not
|
||||
contain an area::
|
||||
Returns the area of this geometry, or 0 for geometries that do not contain
|
||||
an area::
|
||||
|
||||
>>> polygon.area
|
||||
25.0
|
||||
@ -590,7 +581,6 @@ systems and coordinate transformation::
|
||||
>>> OGRGeometry('POINT(1 2)').json
|
||||
'{ "type": "Point", "coordinates": [ 1.000000, 2.000000 ] }'
|
||||
|
||||
|
||||
.. attribute:: kml
|
||||
|
||||
Returns a string representation of this geometry in KML format.
|
||||
@ -631,10 +621,11 @@ systems and coordinate transformation::
|
||||
|
||||
.. method:: transform(coord_trans, clone=False)
|
||||
|
||||
Transforms this geometry to a different spatial reference system. May
|
||||
take a :class:`CoordTransform` object, a :class:`SpatialReference` object,
|
||||
or any other input accepted by :class:`SpatialReference` (including
|
||||
spatial reference WKT and PROJ.4 strings, or an integer SRID).
|
||||
Transforms this geometry to a different spatial reference system. May take
|
||||
a :class:`CoordTransform` object, a :class:`SpatialReference` object, or
|
||||
any other input accepted by :class:`SpatialReference` (including spatial
|
||||
reference WKT and PROJ.4 strings, or an integer SRID).
|
||||
|
||||
By default nothing is returned and the geometry is transformed in-place.
|
||||
However, if the ``clone`` keyword is set to ``True`` then a transformed
|
||||
clone of this geometry is returned instead.
|
||||
@ -646,8 +637,8 @@ systems and coordinate transformation::
|
||||
|
||||
.. method:: equals(other)
|
||||
|
||||
Returns ``True`` if this geometry is equivalent to the other, otherwise returns
|
||||
``False``.
|
||||
Returns ``True`` if this geometry is equivalent to the other, otherwise
|
||||
returns ``False``.
|
||||
|
||||
.. method:: disjoint(other)
|
||||
|
||||
@ -666,8 +657,8 @@ systems and coordinate transformation::
|
||||
|
||||
.. method:: within(other)
|
||||
|
||||
Returns ``True`` if this geometry is contained within the other, otherwise returns
|
||||
``False``.
|
||||
Returns ``True`` if this geometry is contained within the other, otherwise
|
||||
returns ``False``.
|
||||
|
||||
.. method:: contains(other)
|
||||
|
||||
@ -740,8 +731,8 @@ systems and coordinate transformation::
|
||||
|
||||
.. attribute:: z
|
||||
|
||||
Returns the Z coordinate of this point, or ``None`` if the
|
||||
point does not have a Z coordinate::
|
||||
Returns the Z coordinate of this point, or ``None`` if the point does not
|
||||
have a Z coordinate::
|
||||
|
||||
>>> OGRGeometry('POINT (1 2 3)').z
|
||||
3.0
|
||||
@ -764,8 +755,8 @@ systems and coordinate transformation::
|
||||
|
||||
.. attribute:: z
|
||||
|
||||
Returns a list of Z coordinates in this line, or ``None`` if the
|
||||
line does not have Z coordinates::
|
||||
Returns a list of Z coordinates in this line, or ``None`` if the line does
|
||||
not have Z coordinates::
|
||||
|
||||
>>> OGRGeometry('LINESTRING (1 2 3,4 5 6)').z
|
||||
[3.0, 6.0]
|
||||
@ -793,7 +784,6 @@ systems and coordinate transformation::
|
||||
Adds a geometry to this geometry collection. Not applicable to other
|
||||
geometry types.
|
||||
|
||||
|
||||
``OGRGeomType``
|
||||
---------------
|
||||
|
||||
@ -826,8 +816,7 @@ systems and coordinate transformation::
|
||||
.. attribute:: django
|
||||
|
||||
Returns the Django field type (a subclass of GeometryField) to use for
|
||||
storing this OGR type, or ``None`` if there is no appropriate Django
|
||||
type::
|
||||
storing this OGR type, or ``None`` if there is no appropriate Django type::
|
||||
|
||||
>>> gt1.django
|
||||
'PolygonField'
|
||||
@ -837,10 +826,9 @@ systems and coordinate transformation::
|
||||
|
||||
.. class:: Envelope(*args)
|
||||
|
||||
Represents an OGR Envelope structure that contains the
|
||||
minimum and maximum X, Y coordinates for a rectangle bounding box.
|
||||
The naming of the variables is compatible with the OGR Envelope
|
||||
C structure.
|
||||
Represents an OGR Envelope structure that contains the minimum and maximum
|
||||
X, Y coordinates for a rectangle bounding box. The naming of the variables
|
||||
is compatible with the OGR Envelope C structure.
|
||||
|
||||
.. attribute:: min_x
|
||||
|
||||
@ -874,7 +862,6 @@ systems and coordinate transformation::
|
||||
|
||||
A string representing this envelope as a polygon in WKT format.
|
||||
|
||||
|
||||
.. method:: expand_to_include(*args)
|
||||
|
||||
Coordinate System Objects
|
||||
@ -891,7 +878,8 @@ Coordinate System Objects
|
||||
* OGC Well Known Text (WKT) (a string)
|
||||
* EPSG code (integer or string)
|
||||
* PROJ.4 string
|
||||
* A shorthand string for well-known standards (``'WGS84'``, ``'WGS72'``, ``'NAD27'``, ``'NAD83'``)
|
||||
* A shorthand string for well-known standards (``'WGS84'``, ``'WGS72'``,
|
||||
``'NAD27'``, ``'NAD83'``)
|
||||
|
||||
Example::
|
||||
|
||||
@ -914,8 +902,8 @@ Coordinate System Objects
|
||||
.. method:: __getitem__(target)
|
||||
|
||||
Returns the value of the given string attribute node, ``None`` if the node
|
||||
doesn't exist. Can also take a tuple as a parameter, (target, child),
|
||||
where child is the index of the attribute in the WKT. For example::
|
||||
doesn't exist. Can also take a tuple as a parameter, (target, child), where
|
||||
child is the index of the attribute in the WKT. For example::
|
||||
|
||||
>>> wkt = 'GEOGCS["WGS 84", DATUM["WGS_1984, ... AUTHORITY["EPSG","4326"]]')
|
||||
>>> srs = SpatialReference(wkt) # could also use 'WGS84', or 4326
|
||||
@ -953,8 +941,8 @@ Coordinate System Objects
|
||||
|
||||
.. method:: identify_epsg()
|
||||
|
||||
This method inspects the WKT of this SpatialReference, and will
|
||||
add EPSG authority nodes where an EPSG identifier is applicable.
|
||||
This method inspects the WKT of this ``SpatialReference`` and will add EPSG
|
||||
authority nodes where an EPSG identifier is applicable.
|
||||
|
||||
.. method:: from_esri()
|
||||
|
||||
@ -1013,14 +1001,13 @@ Coordinate System Objects
|
||||
|
||||
.. attribute:: units
|
||||
|
||||
Returns a 2-tuple of the units value and the units name,
|
||||
and will automatically determines whether to return the linear
|
||||
or angular units.
|
||||
Returns a 2-tuple of the units value and the units name and will
|
||||
automatically determines whether to return the linear or angular units.
|
||||
|
||||
.. attribute:: ellipsoid
|
||||
|
||||
Returns a tuple of the ellipsoid parameters for this spatial
|
||||
reference: (semimajor axis, semiminor axis, and inverse flattening)
|
||||
Returns a tuple of the ellipsoid parameters for this spatial reference:
|
||||
(semimajor axis, semiminor axis, and inverse flattening).
|
||||
|
||||
.. attribute:: semi_major
|
||||
|
||||
@ -1036,18 +1023,18 @@ Coordinate System Objects
|
||||
|
||||
.. attribute:: geographic
|
||||
|
||||
Returns ``True`` if this spatial reference is geographic
|
||||
(root node is ``GEOGCS``).
|
||||
Returns ``True`` if this spatial reference is geographic (root node is
|
||||
``GEOGCS``).
|
||||
|
||||
.. attribute:: local
|
||||
|
||||
Returns ``True`` if this spatial reference is local
|
||||
(root node is ``LOCAL_CS``).
|
||||
Returns ``True`` if this spatial reference is local (root node is
|
||||
``LOCAL_CS``).
|
||||
|
||||
.. attribute:: projected
|
||||
|
||||
Returns ``True`` if this spatial reference is a projected coordinate
|
||||
system (root node is ``PROJCS``).
|
||||
Returns ``True`` if this spatial reference is a projected coordinate system
|
||||
(root node is ``PROJCS``).
|
||||
|
||||
.. attribute:: wkt
|
||||
|
||||
@ -1069,7 +1056,6 @@ Coordinate System Objects
|
||||
|
||||
Returns the XML representation of this spatial reference.
|
||||
|
||||
|
||||
``CoordTransform``
|
||||
------------------
|
||||
|
||||
@ -1077,8 +1063,8 @@ Coordinate System Objects
|
||||
|
||||
Represents a coordinate system transform. It is initialized with two
|
||||
:class:`SpatialReference`, representing the source and target coordinate
|
||||
systems, respectively. These objects should be used when performing
|
||||
the same coordinate transformation repeatedly on different geometries::
|
||||
systems, respectively. These objects should be used when performing the same
|
||||
coordinate transformation repeatedly on different geometries::
|
||||
|
||||
>>> ct = CoordTransform(SpatialReference('WGS84'), SpatialReference('NAD83'))
|
||||
>>> for feat in layer:
|
||||
|
@ -1308,8 +1308,8 @@ Returns a ``LineString`` constructed from the point field geometries in the
|
||||
|
||||
Example::
|
||||
|
||||
>>> print(City.objects.filter(name__in=('Houston', 'Dallas')
|
||||
... ).aggregate(MakeLine('poly'))['poly__makeline']
|
||||
>>> qs = City.objects.filter(name__in=('Houston', 'Dallas')).aggregate(MakeLine('poly'))
|
||||
>>> print(qs['poly__makeline'])
|
||||
LINESTRING (-95.3631510000000020 29.7633739999999989, -96.8016109999999941 32.7820570000000018)
|
||||
|
||||
``Union``
|
||||
|
@ -645,9 +645,9 @@ is returned instead.
|
||||
|
||||
.. class:: Point(x=None, y=None, z=None, srid=None)
|
||||
|
||||
``Point`` objects are instantiated using arguments that represent
|
||||
the component coordinates of the point or with a single sequence
|
||||
coordinates. For example, the following are equivalent::
|
||||
``Point`` objects are instantiated using arguments that represent the
|
||||
component coordinates of the point or with a single sequence coordinates.
|
||||
For example, the following are equivalent::
|
||||
|
||||
>>> pnt = Point(5, 23)
|
||||
>>> pnt = Point([5, 23])
|
||||
@ -667,15 +667,15 @@ is returned instead.
|
||||
|
||||
.. class:: LineString(*args, **kwargs)
|
||||
|
||||
``LineString`` objects are instantiated using arguments that are
|
||||
either a sequence of coordinates or :class:`Point` objects.
|
||||
For example, the following are equivalent::
|
||||
``LineString`` objects are instantiated using arguments that are either a
|
||||
sequence of coordinates or :class:`Point` objects. For example, the
|
||||
following are equivalent::
|
||||
|
||||
>>> ls = LineString((0, 0), (1, 1))
|
||||
>>> ls = LineString(Point(0, 0), Point(1, 1))
|
||||
|
||||
In addition, ``LineString`` objects may also be created by passing
|
||||
in a single sequence of coordinate or :class:`Point` objects::
|
||||
In addition, ``LineString`` objects may also be created by passing in a
|
||||
single sequence of coordinate or :class:`Point` objects::
|
||||
|
||||
>>> ls = LineString( ((0, 0), (1, 1)) )
|
||||
>>> ls = LineString( [Point(0, 0), Point(1, 1)] )
|
||||
@ -702,14 +702,14 @@ is returned instead.
|
||||
.. class:: LinearRing(*args, **kwargs)
|
||||
|
||||
``LinearRing`` objects are constructed in the exact same way as
|
||||
:class:`LineString` objects, however the coordinates must be
|
||||
*closed*, in other words, the first coordinates must be the
|
||||
same as the last coordinates. For example::
|
||||
:class:`LineString` objects, however the coordinates must be *closed*, in
|
||||
other words, the first coordinates must be the same as the last
|
||||
coordinates. For example::
|
||||
|
||||
>>> ls = LinearRing((0, 0), (0, 1), (1, 1), (0, 0))
|
||||
|
||||
Notice that ``(0, 0)`` is the first and last coordinate -- if
|
||||
they were not equal, an error would be raised.
|
||||
Notice that ``(0, 0)`` is the first and last coordinate -- if they were not
|
||||
equal, an error would be raised.
|
||||
|
||||
``Polygon``
|
||||
-----------
|
||||
|
@ -82,8 +82,8 @@ is required.
|
||||
|
||||
.. note::
|
||||
|
||||
On Linux platforms, it may be necessary to run the ``ldconfig``
|
||||
command after installing each library. For example::
|
||||
On Linux platforms, it may be necessary to run the ``ldconfig`` command
|
||||
after installing each library. For example::
|
||||
|
||||
$ sudo make install
|
||||
$ sudo ldconfig
|
||||
@ -253,7 +253,6 @@ the GDAL library. For example::
|
||||
|
||||
GDAL_LIBRARY_PATH = '/home/sue/local/lib/libgdal.so'
|
||||
|
||||
|
||||
.. rubric:: Footnotes
|
||||
.. [#] The datum shifting files are needed for converting data to and from
|
||||
certain projections.
|
||||
|
@ -113,10 +113,10 @@ Measurement API
|
||||
|
||||
.. class:: Distance(**kwargs)
|
||||
|
||||
To initialize a distance object, pass in a keyword corresponding to
|
||||
the desired :ref:`unit attribute name <supported_units>` set with
|
||||
desired value. For example, the following creates a distance
|
||||
object representing 5 miles::
|
||||
To initialize a distance object, pass in a keyword corresponding to the
|
||||
desired :ref:`unit attribute name <supported_units>` set with desired
|
||||
value. For example, the following creates a distance object representing 5
|
||||
miles::
|
||||
|
||||
>>> dist = Distance(mi=5)
|
||||
|
||||
@ -130,8 +130,8 @@ Measurement API
|
||||
|
||||
.. classmethod:: unit_attname(unit_name)
|
||||
|
||||
Returns the distance unit attribute name for the given full unit name.
|
||||
For example::
|
||||
Returns the distance unit attribute name for the given full unit name. For
|
||||
example::
|
||||
|
||||
>>> Distance.unit_attname('Mile')
|
||||
'mi'
|
||||
@ -145,25 +145,25 @@ Measurement API
|
||||
|
||||
.. class:: Area(**kwargs)
|
||||
|
||||
To initialize an area object, pass in a keyword corresponding to
|
||||
the desired :ref:`unit attribute name <supported_units>` set with
|
||||
desired value. For example, the following creates an area
|
||||
object representing 5 square miles::
|
||||
To initialize an area object, pass in a keyword corresponding to the
|
||||
desired :ref:`unit attribute name <supported_units>` set with desired
|
||||
value. For example, the following creates an area object representing 5
|
||||
square miles::
|
||||
|
||||
>>> a = Area(sq_mi=5)
|
||||
|
||||
.. method:: __getattr__(unit_att)
|
||||
|
||||
Returns the area value in units corresponding to the given unit
|
||||
attribute. For example::
|
||||
Returns the area value in units corresponding to the given unit attribute.
|
||||
For example::
|
||||
|
||||
>>> print(a.sq_km)
|
||||
12.949940551680001
|
||||
|
||||
.. classmethod:: unit_attname(unit_name)
|
||||
|
||||
Returns the area unit attribute name for the given full unit name.
|
||||
For example::
|
||||
Returns the area unit attribute name for the given full unit name. For
|
||||
example::
|
||||
|
||||
>>> Area.unit_attname('Kilometer')
|
||||
'sq_km'
|
||||
|
Loading…
x
Reference in New Issue
Block a user