Fixed #25974 -- Switched GIS docs to 4 spaces indentation.

This commit is contained in:
Sergey Fedoseev 2016-02-19 12:31:25 +05:00 committed by Tim Graham
parent dbaa1a6b59
commit 23e1ad537a
19 changed files with 929 additions and 944 deletions

View File

@ -26,10 +26,10 @@ API Reference
.. class:: Feed .. class:: Feed
In addition to methods provided by In addition to methods provided by the
the :class:`django.contrib.syndication.views.Feed` :class:`django.contrib.syndication.views.Feed` base class, GeoDjango's
base class, GeoDjango's ``Feed`` class provides ``Feed`` class provides the following overrides. Note that these overrides
the following overrides. Note that these overrides may be done in multiple ways:: may be done in multiple ways::
from django.contrib.gis.feeds import Feed from django.contrib.gis.feeds import Feed
@ -56,8 +56,8 @@ API Reference
.. method:: geometry(obj) .. method:: geometry(obj)
Takes the object returned by ``get_object()`` and returns the *feed's* Takes the object returned by ``get_object()`` and returns the *feed's*
geometry. Typically this is a ``GEOSGeometry`` instance, or can be a geometry. Typically this is a ``GEOSGeometry`` instance, or can be a tuple
tuple to represent a point or a box. For example:: to represent a point or a box. For example::
class ZipcodeFeed(Feed): class ZipcodeFeed(Feed):
@ -67,9 +67,9 @@ API Reference
.. method:: item_geometry(item) .. method:: item_geometry(item)
Set this to return the geometry for each *item* in the feed. This Set this to return the geometry for each *item* in the feed. This can be a
can be a ``GEOSGeometry`` instance, or a tuple that represents a ``GEOSGeometry`` instance, or a tuple that represents a point coordinate or
point coordinate or bounding box. For example:: bounding box. For example::
class ZipcodeFeed(Feed): class ZipcodeFeed(Feed):

View File

@ -18,8 +18,8 @@ to raster (image) data.
.. note:: .. note::
Although the module is named ``gdal``, GeoDjango only supports Although the module is named ``gdal``, GeoDjango only supports some of the
some of the capabilities of OGR and GDAL's raster features at this time. capabilities of OGR and GDAL's raster features at this time.
__ http://www.gdal.org/ __ http://www.gdal.org/
__ http://www.gdal.org/ogr_arch.html __ http://www.gdal.org/ogr_arch.html
@ -61,22 +61,20 @@ each feature in that layer.
.. class:: DataSource(ds_input, encoding='utf-8') .. class:: DataSource(ds_input, encoding='utf-8')
The constructor for ``DataSource`` only requires one parameter: the path of The constructor for ``DataSource`` only requires one parameter: the path of
the file you want to read. However, OGR the file you want to read. However, OGR also supports a variety of more
also supports a variety of more complex data sources, including complex data sources, including databases, that may be accessed by passing
databases, that may be accessed by passing a special name string instead a special name string instead of a path. For more information, see the
of a path. For more information, see the `OGR Vector Formats`__ `OGR Vector Formats`__ documentation. The :attr:`name` property of a
documentation. The :attr:`name` property of a ``DataSource`` ``DataSource`` instance gives the OGR name of the underlying data source
instance gives the OGR name of the underlying data source that it is that it is using.
using.
The optional ``encoding`` parameter allows you to The optional ``encoding`` parameter allows you to specify a non-standard
specify a non-standard encoding of the strings in the source. This is encoding of the strings in the source. This is typically useful when you
typically useful when you obtain ``DjangoUnicodeDecodeError`` exceptions obtain ``DjangoUnicodeDecodeError`` exceptions while reading field values.
while reading field values.
Once you've created your ``DataSource``, you can find out how many Once you've created your ``DataSource``, you can find out how many layers
layers of data it contains by accessing the :attr:`layer_count` property, of data it contains by accessing the :attr:`layer_count` property, or
or (equivalently) by using the ``len()`` function. For information on (equivalently) by using the ``len()`` function. For information on
accessing the layers of data themselves, see the next section:: accessing the layers of data themselves, see the next section::
>>> from django.contrib.gis.gdal import DataSource >>> from django.contrib.gis.gdal import DataSource
@ -101,18 +99,17 @@ __ http://www.gdal.org/ogr_formats.html
.. class:: Layer .. class:: Layer
``Layer`` is a wrapper for a layer of data in a ``DataSource`` object. ``Layer`` is a wrapper for a layer of data in a ``DataSource`` object. You
You never create a ``Layer`` object directly. Instead, you retrieve never create a ``Layer`` object directly. Instead, you retrieve them from
them from a :class:`DataSource` object, which is essentially a standard a :class:`DataSource` object, which is essentially a standard Python
Python container of ``Layer`` objects. For example, you can access a container of ``Layer`` objects. For example, you can access a specific
specific layer by its index (e.g. ``ds[0]`` to access the first layer by its index (e.g. ``ds[0]`` to access the first layer), or you can
layer), or you can iterate over all the layers in the container in a iterate over all the layers in the container in a ``for`` loop. The
``for`` loop. The ``Layer`` itself acts as a container for geometric ``Layer`` itself acts as a container for geometric features.
features.
Typically, all the features in a given layer have the same geometry type. 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` The :attr:`geom_type` property of a layer is an :class:`OGRGeomType` that
that identifies the feature type. We can use it to print out some basic identifies the feature type. We can use it to print out some basic
information about each layer in a :class:`DataSource`:: information about each layer in a :class:`DataSource`::
>>> for layer in ds: >>> for layer in ds:
@ -143,8 +140,7 @@ __ http://www.gdal.org/ogr_formats.html
.. attribute:: geom_type .. attribute:: geom_type
Returns the geometry type of the layer, as an :class:`OGRGeomType` Returns the geometry type of the layer, as an :class:`OGRGeomType` object::
object::
>>> layer.geom_type.name >>> layer.geom_type.name
'Point' 'Point'
@ -166,41 +162,39 @@ __ http://www.gdal.org/ogr_formats.html
.. attribute field_types .. attribute field_types
Returns a list of the data types of each of the fields in this layer. Returns a list of the data types of each of the fields in this layer. These
These are subclasses of ``Field``, discussed below:: are subclasses of ``Field``, discussed below::
>>> [ft.__name__ for ft in layer.field_types] >>> [ft.__name__ for ft in layer.field_types]
['OFTString', 'OFTReal', 'OFTReal', 'OFTDate'] ['OFTString', 'OFTReal', 'OFTReal', 'OFTDate']
.. attribute:: field_widths .. attribute:: field_widths
Returns a list of the maximum field widths for each of the fields in Returns a list of the maximum field widths for each of the fields in this
this layer:: layer::
>>> layer.field_widths >>> layer.field_widths
[80, 11, 24, 10] [80, 11, 24, 10]
.. attribute:: field_precisions .. attribute:: field_precisions
Returns a list of the numeric precisions for each of the fields in Returns a list of the numeric precisions for each of the fields in this
this layer. This is meaningless (and set to zero) for non-numeric layer. This is meaningless (and set to zero) for non-numeric fields::
fields::
>>> layer.field_precisions >>> layer.field_precisions
[0, 0, 15, 0] [0, 0, 15, 0]
.. attribute:: extent .. attribute:: extent
Returns the spatial extent of this layer, as an :class:`Envelope` Returns the spatial extent of this layer, as an :class:`Envelope` object::
object::
>>> layer.extent.tuple >>> layer.extent.tuple
(-104.609252, 29.763374, -95.23506, 38.971823) (-104.609252, 29.763374, -95.23506, 38.971823)
.. attribute:: srs .. attribute:: srs
Property that returns the :class:`SpatialReference` associated Property that returns the :class:`SpatialReference` associated with this
with this layer:: layer::
>>> print(layer.srs) >>> print(layer.srs)
GEOGCS["GCS_WGS_1984", 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 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` layer. A spatial filter can only be set with an :class:`OGRGeometry`
instance, a 4-tuple extent, or ``None``. When set with something instance, a 4-tuple extent, or ``None``. When set with something other than
other than ``None``, only features that intersect the filter will be ``None``, only features that intersect the filter will be returned when
returned when iterating over the layer:: iterating over the layer::
>>> print(layer.spatial_filter) >>> print(layer.spatial_filter)
None None
@ -246,9 +240,9 @@ __ http://www.gdal.org/ogr_formats.html
.. method:: get_geoms(geos=False) .. method:: get_geoms(geos=False)
A method that returns a list containing the geometry of each feature A method that returns a list containing the geometry of each feature in the
in the layer. If the optional argument ``geos`` is set to ``True`` layer. If the optional argument ``geos`` is set to ``True`` then the
then the geometries are converted to :class:`~django.contrib.gis.geos.GEOSGeometry` geometries are converted to :class:`~django.contrib.gis.geos.GEOSGeometry`
objects. Otherwise, they are returned as :class:`OGRGeometry` objects:: objects. Otherwise, they are returned as :class:`OGRGeometry` objects::
>>> [pt.tuple for pt in layer.get_geoms()] >>> [pt.tuple for pt in layer.get_geoms()]
@ -256,9 +250,9 @@ __ http://www.gdal.org/ogr_formats.html
.. method:: test_capability(capability) .. method:: test_capability(capability)
Returns a boolean indicating whether this layer supports the Returns a boolean indicating whether this layer supports the given
given capability (a string). Examples of valid capability strings capability (a string). Examples of valid capability strings include:
include: ``'RandomRead'``, ``'SequentialWrite'``, ``'RandomWrite'``, ``'RandomRead'``, ``'SequentialWrite'``, ``'RandomWrite'``,
``'FastSpatialFilter'``, ``'FastFeatureCount'``, ``'FastGetExtent'``, ``'FastSpatialFilter'``, ``'FastFeatureCount'``, ``'FastGetExtent'``,
``'CreateField'``, ``'Transactions'``, ``'DeleteFeature'``, and ``'CreateField'``, ``'Transactions'``, ``'DeleteFeature'``, and
``'FastSetNextByIndex'``. ``'FastSetNextByIndex'``.
@ -268,15 +262,14 @@ __ http://www.gdal.org/ogr_formats.html
.. class:: Feature .. class:: Feature
``Feature`` wraps an OGR feature. You never create a ``Feature`` object
``Feature`` wraps an OGR feature. You never create a ``Feature`` directly. Instead, you retrieve them from a :class:`Layer` object. Each
object directly. Instead, you retrieve them from a :class:`Layer` object. feature consists of a geometry and a set of fields containing additional
Each feature consists of a geometry and a set of fields containing properties. The geometry of a field is accessible via its ``geom`` property,
additional properties. The geometry of a field is accessible via its which returns an :class:`OGRGeometry` object. A ``Feature`` behaves like a
``geom`` property, which returns an :class:`OGRGeometry` object. A ``Feature`` standard Python container for its fields, which it returns as :class:`Field`
behaves like a standard Python container for its fields, which it returns as objects: you can access a field directly by its index or name, or you can
:class:`Field` objects: you can access a field directly by its index or name, iterate over a feature's fields, e.g. in a ``for`` loop.
or you can iterate over a feature's fields, e.g. in a ``for`` loop.
.. attribute:: geom .. attribute:: geom
@ -296,22 +289,22 @@ __ http://www.gdal.org/ogr_formats.html
.. attribute:: geom_type .. attribute:: geom_type
Returns the type of geometry for this feature, as an :class:`OGRGeomType` 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 object. This will be the same for all features in a given layer and is
is equivalent to the :attr:`Layer.geom_type` property of the equivalent to the :attr:`Layer.geom_type` property of the :class:`Layer`
:class:`Layer` object the feature came from. object the feature came from.
.. attribute:: num_fields .. attribute:: num_fields
Returns the number of fields of data associated with the feature. Returns the number of fields of data associated with the feature. This will
This will be the same for all features in a given layer, and is be the same for all features in a given layer and is equivalent to the
equivalent to the :attr:`Layer.num_fields` property of the :attr:`Layer.num_fields` property of the :class:`Layer` object the feature
:class:`Layer` object the feature came from. came from.
.. attribute:: fields .. attribute:: fields
Returns a list of the names of the fields of data associated with the 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 feature. This will be the same for all features in a given layer and is
is equivalent to the :attr:`Layer.fields` property of the :class:`Layer` equivalent to the :attr:`Layer.fields` property of the :class:`Layer`
object the feature came from. object the feature came from.
.. attribute:: fid .. attribute:: fid
@ -323,16 +316,16 @@ __ http://www.gdal.org/ogr_formats.html
.. attribute:: layer_name .. attribute:: layer_name
Returns the name of the :class:`Layer` that the feature came from. Returns the name of the :class:`Layer` that the feature came from. This
This will be the same for all features in a given layer:: will be the same for all features in a given layer::
>>> city.layer_name >>> city.layer_name
'cities' 'cities'
.. attribute:: index .. attribute:: index
A method that returns the index of the given field name. This will be A method that returns the index of the given field name. This will be the
the same for all features in a given layer:: same for all features in a given layer::
>>> city.index('Population') >>> city.index('Population')
1 1
@ -351,9 +344,8 @@ __ http://www.gdal.org/ogr_formats.html
.. attribute:: type .. attribute:: type
Returns the OGR type of this field, as an integer. The Returns the OGR type of this field, as an integer. The ``FIELD_CLASSES``
``FIELD_CLASSES`` dictionary maps these values onto dictionary maps these values onto subclasses of ``Field``::
subclasses of ``Field``::
>>> city['Density'].type >>> city['Density'].type
2 2
@ -367,9 +359,9 @@ __ http://www.gdal.org/ogr_formats.html
.. attribute:: value .. attribute:: value
Returns the value of this field. The ``Field`` class itself Returns the value of this field. The ``Field`` class itself returns the
returns the value as a string, but each subclass returns the value as a string, but each subclass returns the value in the most
value in the most appropriate form:: appropriate form::
>>> city['Population'].value >>> city['Population'].value
102121 102121
@ -383,8 +375,8 @@ __ http://www.gdal.org/ogr_formats.html
.. attribute:: precision .. attribute:: precision
Returns the numeric precision of this field. This is meaningless (and Returns the numeric precision of this field. This is meaningless (and set
set to zero) for non-numeric fields:: to zero) for non-numeric fields::
>>> city['Density'].precision >>> city['Density'].precision
15 15
@ -422,13 +414,13 @@ __ http://www.gdal.org/ogr_formats.html
.. class:: Driver(dr_input) .. 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 .. attribute:: driver_count
Returns the number of OGR vector drivers currently registered. Returns the number of OGR vector drivers currently registered.
OGR Geometries OGR Geometries
============== ==============
@ -436,24 +428,23 @@ OGR Geometries
--------------- ---------------
:class:`OGRGeometry` objects share similar functionality with :class:`OGRGeometry` objects share similar functionality with
:class:`~django.contrib.gis.geos.GEOSGeometry` objects, and are thin :class:`~django.contrib.gis.geos.GEOSGeometry` objects and are thin wrappers
wrappers around OGR's internal geometry representation. Thus, around OGR's internal geometry representation. Thus, they allow for more
they allow for more efficient access to data when using :class:`DataSource`. efficient access to data when using :class:`DataSource`. Unlike its GEOS
Unlike its GEOS counterpart, :class:`OGRGeometry` supports spatial reference counterpart, :class:`OGRGeometry` supports spatial reference systems and
systems and coordinate transformation:: coordinate transformation::
>>> from django.contrib.gis.gdal import OGRGeometry >>> from django.contrib.gis.gdal import OGRGeometry
>>> polygon = OGRGeometry('POLYGON((0 0, 5 0, 5 5, 0 5))') >>> polygon = OGRGeometry('POLYGON((0 0, 5 0, 5 5, 0 5))')
.. class:: OGRGeometry(geom_input, srs=None) .. class:: OGRGeometry(geom_input, srs=None)
This object is a wrapper for the `OGR Geometry`__ class. This object is a wrapper for the `OGR Geometry`__ class. These objects are
These objects are instantiated directly from the given ``geom_input`` instantiated directly from the given ``geom_input`` parameter, which may be
parameter, which may be a string containing WKT, HEX, GeoJSON, a ``buffer`` a string containing WKT, HEX, GeoJSON, a ``buffer`` containing WKB data, or
containing WKB data, or an :class:`OGRGeomType` object. These objects an :class:`OGRGeomType` object. These objects are also returned from the
are also returned from the :class:`Feature.geom` attribute, when :class:`Feature.geom` attribute, when reading vector data from
reading vector data from :class:`Layer` (which is in turn a part of :class:`Layer` (which is in turn a part of a :class:`DataSource`).
a :class:`DataSource`).
__ http://www.gdal.org/classOGRGeometry.html __ http://www.gdal.org/classOGRGeometry.html
@ -463,8 +454,8 @@ systems and coordinate transformation::
.. method:: __len__() .. method:: __len__()
Returns the number of points in a :class:`LineString`, the Returns the number of points in a :class:`LineString`, the number of rings
number of rings in a :class:`Polygon`, or the number of geometries in a in a :class:`Polygon`, or the number of geometries in a
:class:`GeometryCollection`. Not applicable to other geometry types. :class:`GeometryCollection`. Not applicable to other geometry types.
.. method:: __iter__() .. method:: __iter__()
@ -490,8 +481,8 @@ systems and coordinate transformation::
.. attribute:: coord_dim .. attribute:: coord_dim
Returns or sets the coordinate dimension of this geometry. For Returns or sets the coordinate dimension of this geometry. For example, the
example, the value would be 2 for two-dimensional geometries. value would be 2 for two-dimensional geometries.
.. attribute:: geom_count .. attribute:: geom_count
@ -528,8 +519,8 @@ systems and coordinate transformation::
.. attribute:: area .. attribute:: area
Returns the area of this geometry, or 0 for geometries that do not Returns the area of this geometry, or 0 for geometries that do not contain
contain an area:: an area::
>>> polygon.area >>> polygon.area
25.0 25.0
@ -590,7 +581,6 @@ systems and coordinate transformation::
>>> OGRGeometry('POINT(1 2)').json >>> OGRGeometry('POINT(1 2)').json
'{ "type": "Point", "coordinates": [ 1.000000, 2.000000 ] }' '{ "type": "Point", "coordinates": [ 1.000000, 2.000000 ] }'
.. attribute:: kml .. attribute:: kml
Returns a string representation of this geometry in KML format. Returns a string representation of this geometry in KML format.
@ -631,10 +621,11 @@ systems and coordinate transformation::
.. method:: transform(coord_trans, clone=False) .. method:: transform(coord_trans, clone=False)
Transforms this geometry to a different spatial reference system. May Transforms this geometry to a different spatial reference system. May take
take a :class:`CoordTransform` object, a :class:`SpatialReference` object, a :class:`CoordTransform` object, a :class:`SpatialReference` object, or
or any other input accepted by :class:`SpatialReference` (including any other input accepted by :class:`SpatialReference` (including spatial
spatial reference WKT and PROJ.4 strings, or an integer SRID). reference WKT and PROJ.4 strings, or an integer SRID).
By default nothing is returned and the geometry is transformed in-place. By default nothing is returned and the geometry is transformed in-place.
However, if the ``clone`` keyword is set to ``True`` then a transformed However, if the ``clone`` keyword is set to ``True`` then a transformed
clone of this geometry is returned instead. clone of this geometry is returned instead.
@ -646,8 +637,8 @@ systems and coordinate transformation::
.. method:: equals(other) .. method:: equals(other)
Returns ``True`` if this geometry is equivalent to the other, otherwise returns Returns ``True`` if this geometry is equivalent to the other, otherwise
``False``. returns ``False``.
.. method:: disjoint(other) .. method:: disjoint(other)
@ -666,8 +657,8 @@ systems and coordinate transformation::
.. method:: within(other) .. method:: within(other)
Returns ``True`` if this geometry is contained within the other, otherwise returns Returns ``True`` if this geometry is contained within the other, otherwise
``False``. returns ``False``.
.. method:: contains(other) .. method:: contains(other)
@ -740,8 +731,8 @@ systems and coordinate transformation::
.. attribute:: z .. attribute:: z
Returns the Z coordinate of this point, or ``None`` if the Returns the Z coordinate of this point, or ``None`` if the point does not
point does not have a Z coordinate:: have a Z coordinate::
>>> OGRGeometry('POINT (1 2 3)').z >>> OGRGeometry('POINT (1 2 3)').z
3.0 3.0
@ -764,8 +755,8 @@ systems and coordinate transformation::
.. attribute:: z .. attribute:: z
Returns a list of Z coordinates in this line, or ``None`` if the Returns a list of Z coordinates in this line, or ``None`` if the line does
line does not have Z coordinates:: not have Z coordinates::
>>> OGRGeometry('LINESTRING (1 2 3,4 5 6)').z >>> OGRGeometry('LINESTRING (1 2 3,4 5 6)').z
[3.0, 6.0] [3.0, 6.0]
@ -793,7 +784,6 @@ systems and coordinate transformation::
Adds a geometry to this geometry collection. Not applicable to other Adds a geometry to this geometry collection. Not applicable to other
geometry types. geometry types.
``OGRGeomType`` ``OGRGeomType``
--------------- ---------------
@ -826,8 +816,7 @@ systems and coordinate transformation::
.. attribute:: django .. attribute:: django
Returns the Django field type (a subclass of GeometryField) to use for Returns the Django field type (a subclass of GeometryField) to use for
storing this OGR type, or ``None`` if there is no appropriate Django storing this OGR type, or ``None`` if there is no appropriate Django type::
type::
>>> gt1.django >>> gt1.django
'PolygonField' 'PolygonField'
@ -837,10 +826,9 @@ systems and coordinate transformation::
.. class:: Envelope(*args) .. class:: Envelope(*args)
Represents an OGR Envelope structure that contains the Represents an OGR Envelope structure that contains the minimum and maximum
minimum and maximum X, Y coordinates for a rectangle bounding box. X, Y coordinates for a rectangle bounding box. The naming of the variables
The naming of the variables is compatible with the OGR Envelope is compatible with the OGR Envelope C structure.
C structure.
.. attribute:: min_x .. attribute:: min_x
@ -874,7 +862,6 @@ systems and coordinate transformation::
A string representing this envelope as a polygon in WKT format. A string representing this envelope as a polygon in WKT format.
.. method:: expand_to_include(*args) .. method:: expand_to_include(*args)
Coordinate System Objects Coordinate System Objects
@ -891,7 +878,8 @@ Coordinate System Objects
* OGC Well Known Text (WKT) (a string) * OGC Well Known Text (WKT) (a string)
* EPSG code (integer or string) * EPSG code (integer or string)
* PROJ.4 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:: Example::
@ -914,8 +902,8 @@ Coordinate System Objects
.. method:: __getitem__(target) .. method:: __getitem__(target)
Returns the value of the given string attribute node, ``None`` if the node 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), doesn't exist. Can also take a tuple as a parameter, (target, child), where
where child is the index of the attribute in the WKT. For example:: child is the index of the attribute in the WKT. For example::
>>> wkt = 'GEOGCS["WGS 84", DATUM["WGS_1984, ... AUTHORITY["EPSG","4326"]]') >>> wkt = 'GEOGCS["WGS 84", DATUM["WGS_1984, ... AUTHORITY["EPSG","4326"]]')
>>> srs = SpatialReference(wkt) # could also use 'WGS84', or 4326 >>> srs = SpatialReference(wkt) # could also use 'WGS84', or 4326
@ -953,8 +941,8 @@ Coordinate System Objects
.. method:: identify_epsg() .. method:: identify_epsg()
This method inspects the WKT of this SpatialReference, and will This method inspects the WKT of this ``SpatialReference`` and will add EPSG
add EPSG authority nodes where an EPSG identifier is applicable. authority nodes where an EPSG identifier is applicable.
.. method:: from_esri() .. method:: from_esri()
@ -1013,14 +1001,13 @@ Coordinate System Objects
.. attribute:: units .. attribute:: units
Returns a 2-tuple of the units value and the units name, Returns a 2-tuple of the units value and the units name and will
and will automatically determines whether to return the linear automatically determines whether to return the linear or angular units.
or angular units.
.. attribute:: ellipsoid .. attribute:: ellipsoid
Returns a tuple of the ellipsoid parameters for this spatial Returns a tuple of the ellipsoid parameters for this spatial reference:
reference: (semimajor axis, semiminor axis, and inverse flattening) (semimajor axis, semiminor axis, and inverse flattening).
.. attribute:: semi_major .. attribute:: semi_major
@ -1036,18 +1023,18 @@ Coordinate System Objects
.. attribute:: geographic .. attribute:: geographic
Returns ``True`` if this spatial reference is geographic Returns ``True`` if this spatial reference is geographic (root node is
(root node is ``GEOGCS``). ``GEOGCS``).
.. attribute:: local .. attribute:: local
Returns ``True`` if this spatial reference is local Returns ``True`` if this spatial reference is local (root node is
(root node is ``LOCAL_CS``). ``LOCAL_CS``).
.. attribute:: projected .. attribute:: projected
Returns ``True`` if this spatial reference is a projected coordinate Returns ``True`` if this spatial reference is a projected coordinate system
system (root node is ``PROJCS``). (root node is ``PROJCS``).
.. attribute:: wkt .. attribute:: wkt
@ -1069,7 +1056,6 @@ Coordinate System Objects
Returns the XML representation of this spatial reference. Returns the XML representation of this spatial reference.
``CoordTransform`` ``CoordTransform``
------------------ ------------------
@ -1077,8 +1063,8 @@ Coordinate System Objects
Represents a coordinate system transform. It is initialized with two Represents a coordinate system transform. It is initialized with two
:class:`SpatialReference`, representing the source and target coordinate :class:`SpatialReference`, representing the source and target coordinate
systems, respectively. These objects should be used when performing systems, respectively. These objects should be used when performing the same
the same coordinate transformation repeatedly on different geometries:: coordinate transformation repeatedly on different geometries::
>>> ct = CoordTransform(SpatialReference('WGS84'), SpatialReference('NAD83')) >>> ct = CoordTransform(SpatialReference('WGS84'), SpatialReference('NAD83'))
>>> for feat in layer: >>> for feat in layer:

View File

@ -1308,8 +1308,8 @@ Returns a ``LineString`` constructed from the point field geometries in the
Example:: Example::
>>> print(City.objects.filter(name__in=('Houston', 'Dallas') >>> qs = City.objects.filter(name__in=('Houston', 'Dallas')).aggregate(MakeLine('poly'))
... ).aggregate(MakeLine('poly'))['poly__makeline'] >>> print(qs['poly__makeline'])
LINESTRING (-95.3631510000000020 29.7633739999999989, -96.8016109999999941 32.7820570000000018) LINESTRING (-95.3631510000000020 29.7633739999999989, -96.8016109999999941 32.7820570000000018)
``Union`` ``Union``

View File

@ -645,9 +645,9 @@ is returned instead.
.. class:: Point(x=None, y=None, z=None, srid=None) .. class:: Point(x=None, y=None, z=None, srid=None)
``Point`` objects are instantiated using arguments that represent ``Point`` objects are instantiated using arguments that represent the
the component coordinates of the point or with a single sequence component coordinates of the point or with a single sequence coordinates.
coordinates. For example, the following are equivalent:: For example, the following are equivalent::
>>> pnt = Point(5, 23) >>> pnt = Point(5, 23)
>>> pnt = Point([5, 23]) >>> pnt = Point([5, 23])
@ -667,15 +667,15 @@ is returned instead.
.. class:: LineString(*args, **kwargs) .. class:: LineString(*args, **kwargs)
``LineString`` objects are instantiated using arguments that are ``LineString`` objects are instantiated using arguments that are either a
either a sequence of coordinates or :class:`Point` objects. sequence of coordinates or :class:`Point` objects. For example, the
For example, the following are equivalent:: following are equivalent::
>>> ls = LineString((0, 0), (1, 1)) >>> ls = LineString((0, 0), (1, 1))
>>> ls = LineString(Point(0, 0), Point(1, 1)) >>> ls = LineString(Point(0, 0), Point(1, 1))
In addition, ``LineString`` objects may also be created by passing In addition, ``LineString`` objects may also be created by passing in a
in a single sequence of coordinate or :class:`Point` objects:: single sequence of coordinate or :class:`Point` objects::
>>> ls = LineString( ((0, 0), (1, 1)) ) >>> ls = LineString( ((0, 0), (1, 1)) )
>>> ls = LineString( [Point(0, 0), Point(1, 1)] ) >>> ls = LineString( [Point(0, 0), Point(1, 1)] )
@ -702,14 +702,14 @@ is returned instead.
.. class:: LinearRing(*args, **kwargs) .. class:: LinearRing(*args, **kwargs)
``LinearRing`` objects are constructed in the exact same way as ``LinearRing`` objects are constructed in the exact same way as
:class:`LineString` objects, however the coordinates must be :class:`LineString` objects, however the coordinates must be *closed*, in
*closed*, in other words, the first coordinates must be the other words, the first coordinates must be the same as the last
same as the last coordinates. For example:: coordinates. For example::
>>> ls = LinearRing((0, 0), (0, 1), (1, 1), (0, 0)) >>> ls = LinearRing((0, 0), (0, 1), (1, 1), (0, 0))
Notice that ``(0, 0)`` is the first and last coordinate -- if Notice that ``(0, 0)`` is the first and last coordinate -- if they were not
they were not equal, an error would be raised. equal, an error would be raised.
``Polygon`` ``Polygon``
----------- -----------

View File

@ -82,8 +82,8 @@ is required.
.. note:: .. note::
On Linux platforms, it may be necessary to run the ``ldconfig`` On Linux platforms, it may be necessary to run the ``ldconfig`` command
command after installing each library. For example:: after installing each library. For example::
$ sudo make install $ sudo make install
$ sudo ldconfig $ sudo ldconfig
@ -253,7 +253,6 @@ the GDAL library. For example::
GDAL_LIBRARY_PATH = '/home/sue/local/lib/libgdal.so' GDAL_LIBRARY_PATH = '/home/sue/local/lib/libgdal.so'
.. rubric:: Footnotes .. rubric:: Footnotes
.. [#] The datum shifting files are needed for converting data to and from .. [#] The datum shifting files are needed for converting data to and from
certain projections. certain projections.

View File

@ -113,10 +113,10 @@ Measurement API
.. class:: Distance(**kwargs) .. class:: Distance(**kwargs)
To initialize a distance object, pass in a keyword corresponding to To initialize a distance object, pass in a keyword corresponding to the
the desired :ref:`unit attribute name <supported_units>` set with desired :ref:`unit attribute name <supported_units>` set with desired
desired value. For example, the following creates a distance value. For example, the following creates a distance object representing 5
object representing 5 miles:: miles::
>>> dist = Distance(mi=5) >>> dist = Distance(mi=5)
@ -130,8 +130,8 @@ Measurement API
.. classmethod:: unit_attname(unit_name) .. classmethod:: unit_attname(unit_name)
Returns the distance unit attribute name for the given full unit name. Returns the distance unit attribute name for the given full unit name. For
For example:: example::
>>> Distance.unit_attname('Mile') >>> Distance.unit_attname('Mile')
'mi' 'mi'
@ -145,25 +145,25 @@ Measurement API
.. class:: Area(**kwargs) .. class:: Area(**kwargs)
To initialize an area object, pass in a keyword corresponding to To initialize an area object, pass in a keyword corresponding to the
the desired :ref:`unit attribute name <supported_units>` set with desired :ref:`unit attribute name <supported_units>` set with desired
desired value. For example, the following creates an area value. For example, the following creates an area object representing 5
object representing 5 square miles:: square miles::
>>> a = Area(sq_mi=5) >>> a = Area(sq_mi=5)
.. method:: __getattr__(unit_att) .. method:: __getattr__(unit_att)
Returns the area value in units corresponding to the given unit Returns the area value in units corresponding to the given unit attribute.
attribute. For example:: For example::
>>> print(a.sq_km) >>> print(a.sq_km)
12.949940551680001 12.949940551680001
.. classmethod:: unit_attname(unit_name) .. classmethod:: unit_attname(unit_name)
Returns the area unit attribute name for the given full unit name. Returns the area unit attribute name for the given full unit name. For
For example:: example::
>>> Area.unit_attname('Kilometer') >>> Area.unit_attname('Kilometer')
'sq_km' 'sq_km'