7 .. module:: django.contrib.gis.gdal
8 :synopsis: GeoDjango's high-level interface to the GDAL library.
10 `GDAL`__ stands for **G**\ eospatial **D**\ ata **A**\ bstraction **L**\ ibrary,
11 and is a veritable "swiss army knife" of GIS data functionality. A subset
12 of GDAL is the `OGR`__ Simple Features Library, which specializes
13 in reading and writing vector geographic data in a variety of standard
16 GeoDjango provides a high-level Python interface for some of the
17 capabilities of OGR, including the reading and coordinate transformation
18 of vector spatial data.
22 Although the module is named ``gdal``, GeoDjango only supports
23 some of the capabilities of OGR. Thus, none of GDAL's features
24 with respect to raster (image) data are supported at this time.
26 __ http://www.gdal.org/
27 __ http://www.gdal.org/ogr/
35 The GDAL/OGR tools described here are designed to help you read in
36 your geospatial data, in order for most of them to be useful you have
37 to have some data to work with. If you're starting out and don't yet
38 have any data of your own to use, GeoDjango comes with a number of
39 simple data sets that you can use for testing. This snippet will
40 determine where these sample files are installed on your computer::
43 >>> import django.contrib.gis
44 >>> GIS_PATH = os.path.dirname(django.contrib.gis.__file__)
45 >>> CITIES_PATH = os.path.join(GIS_PATH, 'tests/data/cities/cities.shp')
47 Vector Data Source Objects
48 ==========================
53 :class:`DataSource` is a wrapper for the OGR data source object that
54 supports reading data from a variety of OGR-supported geospatial file
55 formats and data sources using a simple, consistent interface. Each
56 data source is represented by a :class:`DataSource` object which contains
57 one or more layers of data. Each layer, represented by a :class:`Layer`
58 object, contains some number of geographic features (:class:`Feature`),
59 information about the type of features contained in that layer (e.g.
60 points, polygons, etc.), as well as the names and types of any
61 additional fields (:class:`Field`) of data that may be associated with
62 each feature in that layer.
64 .. class:: DataSource(ds_input)
66 The constructor for ``DataSource`` just a single parameter: the path of
67 the file you want to read. However, OGR
68 also supports a variety of more complex data sources, including
69 databases, that may be accessed by passing a special name string instead
70 of a path. For more information, see the `OGR Vector Formats`__
71 documentation. The :attr:`name` property of a ``DataSource``
72 instance gives the OGR name of the underlying data source that it is
75 Once you've created your ``DataSource``, you can find out how many
76 layers of data it contains by accessing the :attr:`layer_count` property,
77 or (equivalently) by using the ``len()`` function. For information on
78 accessing the layers of data themselves, see the next section::
80 >>> from django.contrib.gis.gdal import DataSource
81 >>> ds = DataSource(CITIES_PATH)
82 >>> ds.name # The exact filename may be different on your computer
83 '/usr/local/lib/python2.6/site-packages/django/contrib/gis/tests/data/cities/cities.shp'
84 >>> ds.layer_count # This file only contains one layer
87 .. attribute:: layer_count
89 Returns the number of layers in the data source.
93 Returns the name of the data source.
95 __ http://www.gdal.org/ogr/ogr_formats.html
102 ``Layer`` is a wrapper for a layer of data in a ``DataSource`` object.
103 You never create a ``Layer`` object directly. Instead, you retrieve
104 them from a :class:`DataSource` object, which is essentially a standard
105 Python container of ``Layer`` objects. For example, you can access a
106 specific layer by its index (e.g. ``ds[0]`` to access the first
107 layer), or you can iterate over all the layers in the container in a
108 ``for`` loop. The ``Layer`` itself acts as a container for geometric
111 Typically, all the features in a given layer have the same geometry type.
112 The :attr:`geom_type` property of a layer is an :class:`OGRGeomType`
113 that identifies the feature type. We can use it to print out some basic
114 information about each layer in a :class:`DataSource`::
117 ... print 'Layer "%s": %i %ss' % (layer.name, len(layer), layer.geom_type.name)
119 Layer "cities": 3 Points
121 The example output is from the cities data source, loaded above, which
122 evidently contains one layer, called ``"cities"``, which contains three
123 point features. For simplicity, the examples below assume that you've
124 stored that layer in the variable ``layer``::
130 Returns the name of this layer in the data source.
135 .. attribute:: num_feat
137 Returns the number of features in the layer. Same as ``len(layer)``::
142 .. attribute:: geom_type
144 Returns the geometry type of the layer, as an :class:`OGRGeomType`
147 >>> layer.geom_type.name
150 .. attribute:: num_fields
152 Returns the number of fields in the layer, i.e the number of fields of
153 data associated with each feature in the layer::
158 .. attribute:: fields
160 Returns a list of the names of each of the fields in this layer::
163 ['Name', 'Population', 'Density', 'Created']
165 .. attribute field_types
167 Returns a list of the data types of each of the fields in this layer.
168 These are subclasses of ``Field``, discussed below::
170 >>> [ft.__name__ for ft in layer.field_types]
171 ['OFTString', 'OFTReal', 'OFTReal', 'OFTDate']
173 .. attribute:: field_widths
175 Returns a list of the maximum field widths for each of the fields in
178 >>> layer.field_widths
181 .. attribute:: field_precisions
183 Returns a list of the numeric precisions for each of the fields in
184 this layer. This is meaningless (and set to zero) for non-numeric
187 >>> layer.field_precisions
190 .. attribute:: extent
192 Returns the spatial extent of this layer, as an :class:`Envelope`
195 >>> layer.extent.tuple
196 (-104.609252, 29.763374, -95.23506, 38.971823)
200 Property that returns the :class:`SpatialReference` associated
204 GEOGCS["GCS_WGS_1984",
206 SPHEROID["WGS_1984",6378137,298.257223563]],
207 PRIMEM["Greenwich",0],
208 UNIT["Degree",0.017453292519943295]]
210 If the :class:`Layer` has no spatial reference information associated
211 with it, ``None`` is returned.
213 .. attribute:: spatial_filter
215 .. versionadded:: 1.2
217 Property that may be used to retrieve or set a spatial filter for this
218 layer. A spatial filter can only be set with an :class:`OGRGeometry`
219 instance, a 4-tuple extent, or ``None``. When set with something
220 other than ``None``, only features that intersect the filter will be
221 returned when iterating over the layer::
223 >>> print layer.spatial_filter
227 >>> [feat.get('Name') for feat in layer]
228 ['Pueblo', 'Lawrence', 'Houston']
229 >>> ks_extent = (-102.051, 36.99, -94.59, 40.00) # Extent for state of Kansas
230 >>> layer.spatial_filter = ks_extent
233 >>> [feat.get('Name') for feat in layer]
235 >>> layer.spatial_filter = None
239 .. method:: get_fields()
241 A method that returns a list of the values of a given field for each
242 feature in the layer::
244 >>> layer.get_fields('Name')
245 ['Pueblo', 'Lawrence', 'Houston']
247 .. method:: get_geoms([geos=False])
249 A method that returns a list containing the geometry of each feature
250 in the layer. If the optional argument ``geos`` is set to ``True``
251 then the geometries are converted to :class:`~django.contrib.gis.geos.GEOSGeometry`
252 objects. Otherwise, they are returned as :class:`OGRGeometry` objects::
254 >>> [pt.tuple for pt in layer.get_geoms()]
255 [(-104.609252, 38.255001), (-95.23506, 38.971823), (-95.363151, 29.763374)]
257 .. method:: test_capability(capability)
259 Returns a boolean indicating whether this layer supports the
260 given capability (a string). Examples of valid capability strings
261 include: ``'RandomRead'``, ``'SequentialWrite'``, ``'RandomWrite'``,
262 ``'FastSpatialFilter'``, ``'FastFeatureCount'``, ``'FastGetExtent'``,
263 ``'CreateField'``, ``'Transactions'``, ``'DeleteFeature'``, and
264 ``'FastSetNextByIndex'``.
272 ``Feature`` wraps an OGR feature. You never create a ``Feature``
273 object directly. Instead, you retrieve them from a :class:`Layer` object.
274 Each feature consists of a geometry and a set of fields containing
275 additional properties. The geometry of a field is accessible via its
276 ``geom`` property, which returns an :class:`OGRGeometry` object. A ``Feature``
277 behaves like a standard Python container for its fields, which it returns as
278 :class:`Field` objects: you can access a field directly by its index or name,
279 or you can iterate over a feature's fields, e.g. in a ``for`` loop.
283 Returns the geometry for this feature, as an ``OGRGeometry`` object::
286 (-104.609252, 38.255001)
290 A method that returns the value of the given field (specified by name)
291 for this feature, **not** a ``Field`` wrapper object::
293 >>> city.get('Population')
296 .. attribute:: geom_type
298 Returns the type of geometry for this feature, as an :class:`OGRGeomType`
299 object. This will be the same for all features in a given layer, and
300 is equivalent to the :attr:`Layer.geom_type` property of the
301 :class:`Layer`` object the feature came from.
303 .. attribute:: num_fields
305 Returns the number of fields of data associated with the feature.
306 This will be the same for all features in a given layer, and is
307 equivalent to the :attr:`Layer.num_fields` property of the
308 :class:`Layer` object the feature came from.
310 .. attribute:: fields
312 Returns a list of the names of the fields of data associated with the
313 feature. This will be the same for all features in a given layer, and
314 is equivalent to the :attr:`Layer.fields` property of the :class:`Layer`
315 object the feature came from.
319 Returns the feature identifier within the layer::
324 .. attribute:: layer_name
326 Returns the name of the :class:`Layer` that the feature came from.
327 This will be the same for all features in a given layer::
334 A method that returns the index of the given field name. This will be
335 the same for all features in a given layer::
337 >>> city.index('Population')
347 Returns the name of this field::
349 >>> city['Name'].name
354 Returns the OGR type of this field, as an integer. The
355 ``FIELD_CLASSES`` dictionary maps these values onto
356 subclasses of ``Field``::
358 >>> city['Density'].type
361 .. attribute:: type_name
363 Returns a string with the name of the data type of this field::
365 >>> city['Name'].type_name
370 Returns the value of this field. The ``Field`` class itself
371 returns the value as a string, but each subclass returns the
372 value in the most appropriate form::
374 >>> city['Population'].value
379 Returns the width of this field::
381 >>> city['Name'].width
384 .. attribute:: precision
386 Returns the numeric precision of this field. This is meaningless (and
387 set to zero) for non-numeric fields::
389 >>> city['Density'].precision
392 .. method:: as_double()
394 Returns the value of the field as a double (float)::
396 >>> city['Density'].as_double()
401 Returns the value of the field as an integer::
403 >>> city['Population'].as_int()
406 .. method:: as_string()
408 Returns the value of the field as a string::
410 >>> city['Name'].as_string()
413 .. method:: as_datetime()
415 Returns the value of the field as a tuple of date and time components::
417 >>> city['Created'].as_datetime()
418 (c_long(1999), c_long(5), c_long(23), c_long(0), c_long(0), c_long(0), c_long(0))
423 .. class:: Driver(dr_input)
425 The ``Driver`` class is used internally to wrap an OGR :class:`DataSource` driver.
427 .. attribute:: driver_count
429 Returns the number of OGR vector drivers currently registered.
438 :class:`OGRGeometry` objects share similar functionality with
439 :class:`~django.contrib.gis.geos.GEOSGeometry` objects, and are thin
440 wrappers around OGR's internal geometry representation. Thus,
441 they allow for more efficient access to data when using :class:`DataSource`.
442 Unlike its GEOS counterpart, :class:`OGRGeometry` supports spatial reference
443 systems and coordinate transformation::
445 >>> from django.contrib.gis.gdal import OGRGeometry
446 >>> polygon = OGRGeometry('POLYGON((0 0, 5 0, 5 5, 0 5))')
448 .. class:: OGRGeometry(geom_input[, srs=None])
450 This object is a wrapper for the `OGR Geometry`__ class.
451 These objects are instantiated directly from the given ``geom_input``
452 parameter, which may be a string containing WKT or HEX, a ``buffer``
453 containing WKB data, or an :class:`OGRGeomType` object. These objects
454 are also returned from the :class:`Feature.geom` attribute, when
455 reading vector data from :class:`Layer` (which is in turn a part of
456 a :class:`DataSource`).
458 __ http://www.gdal.org/ogr/classOGRGeometry.html
460 .. classmethod:: from_bbox(bbox)
462 Constructs a :class:`Polygon` from the given bounding-box (a 4-tuple).
466 Returns the number of points in a :class:`LineString`, the
467 number of rings in a :class:`Polygon`, or the number of geometries in a
468 :class:`GeometryCollection`. Not applicable to other geometry types.
472 Iterates over the points in a :class:`LineString`, the rings in a
473 :class:`Polygon`, or the geometries in a :class:`GeometryCollection`.
474 Not applicable to other geometry types.
476 .. method:: __getitem__
478 Returns the point at the specified index for a :class:`LineString`, the
479 interior ring at the specified index for a :class:`Polygon`, or the geometry
480 at the specified index in a :class:`GeometryCollection`. Not applicable to
481 other geometry types.
483 .. attribute:: dimension
485 Returns the number of coordinated dimensions of the geometry, i.e. 0
486 for points, 1 for lines, and so forth::
491 .. attribute:: coord_dim
493 .. versionchanged:: 1.2
495 Returns or sets the coordinate dimension of this geometry. For
496 example, the value would be 2 for two-dimensional geometries.
500 Setting this property is only available in versions 1.2 and above.
502 .. attribute:: geom_count
504 Returns the number of elements in this geometry::
506 >>> polygon.geom_count
509 .. attribute:: point_count
511 Returns the number of points used to describe this geometry::
513 >>> polygon.point_count
516 .. attribute:: num_points
518 Alias for :attr:`point_count`.
520 .. attribute:: num_coords
522 Alias for :attr:`point_count`.
524 .. attribute:: geom_type
526 Returns the type of this geometry, as an :class:`OGRGeomType` object.
528 .. attribute:: geom_name
530 Returns the name of the type of this geometry::
532 >>> polygon.geom_name
537 Returns the area of this geometry, or 0 for geometries that do not
543 .. attribute:: envelope
545 Returns the envelope of this geometry, as an :class:`Envelope` object.
547 .. attribute:: extent
549 Returns the envelope of this geometry as a 4-tuple, instead of as an
550 :class:`Envelope` object::
557 This property controls the spatial reference for this geometry, or
558 ``None`` if no spatial reference system has been assigned to it.
559 If assigned, accessing this property returns a :class:`SpatialReference`
560 object. It may be set with another :class:`SpatialReference` object,
561 or any input that :class:`SpatialReference` accepts. Example::
563 >>> city.geom.srs.name
568 Returns or sets the spatial reference identifier corresponding to
569 :class:`SpatialReference` of this geometry. Returns ``None`` if
570 there is no spatial reference information associated with this
571 geometry, or if an SRID cannot be determined.
575 Returns a :class:`~django.contrib.gis.geos.GEOSGeometry` object
576 corresponding to this geometry.
580 Returns a string representation of this geometry in GML format::
582 >>> OGRGeometry('POINT(1 2)').gml
583 '<gml:Point><gml:coordinates>1,2</gml:coordinates></gml:Point>'
587 Returns a string representation of this geometry in HEX WKB format::
589 >>> OGRGeometry('POINT(1 2)').hex
590 '0101000000000000000000F03F0000000000000040'
594 Returns a string representation of this geometry in JSON format::
596 >>> OGRGeometry('POINT(1 2)').json
597 '{ "type": "Point", "coordinates": [ 1.000000, 2.000000 ] }'
602 Returns a string representation of this geometry in KML format.
604 .. attribute:: wkb_size
606 Returns the size of the WKB buffer needed to hold a WKB representation
609 >>> OGRGeometry('POINT(1 2)').wkb_size
614 Returns a ``buffer`` containing a WKB representation of this geometry.
618 Returns a string representation of this geometry in WKT format.
622 .. versionadded:: 1.2
624 Returns the EWKT representation of this geometry.
628 Returns a new :class:`OGRGeometry` clone of this geometry object.
630 .. method:: close_rings()
632 If there are any rings within this geometry that have not been closed,
633 this routine will do so by adding the starting point to the end::
635 >>> triangle = OGRGeometry('LINEARRING (0 0,0 1,1 0)')
636 >>> triangle.close_rings()
638 'LINEARRING (0 0,0 1,1 0,0 0)'
640 .. method:: transform(coord_trans, clone=False)
642 Transforms this geometry to a different spatial reference system. May
643 take a :class:`CoordTransform` object, a :class:`SpatialReference` object,
644 or any other input accepted by :class:`SpatialReference` (including
645 spatial reference WKT and PROJ.4 strings, or an integer SRID).
646 By default nothing is returned and the geometry is transformed in-place.
647 However, if the `clone` keyword is set to ``True`` then a transformed clone
648 of this geometry is returned instead.
650 .. method:: intersects(other)
652 Returns ``True`` if this geometry intersects the other, otherwise returns
655 .. method:: equals(other)
657 Returns ``True`` if this geometry is equivalent to the other, otherwise returns
660 .. method:: disjoint(other)
662 Returns ``True`` if this geometry is spatially disjoint to (i.e. does
663 not intersect) the other, otherwise returns ``False``.
665 .. method:: touches(other)
667 Returns ``True`` if this geometry touches the other, otherwise returns
670 .. method:: crosses(other)
672 Returns ``True`` if this geometry crosses the other, otherwise returns
675 .. method:: within(other)
677 Returns ``True`` if this geometry is contained within the other, otherwise returns
680 .. method:: contains(other)
682 Returns ``True`` if this geometry contains the other, otherwise returns
685 .. method:: overlaps(other)
687 Returns ``True`` if this geometry overlaps the other, otherwise returns
692 The boundary of this geometry, as a new :class:`OGRGeometry` object.
694 .. attribute:: convex_hull
696 The smallest convex polygon that contains this geometry, as a new
697 :class:`OGRGeometry` object.
699 .. method:: difference
701 Returns the region consisting of the difference of this geometry and
702 the other, as a new :class:`OGRGeometry` object.
704 .. method:: intersection
706 Returns the region consisting of the intersection of this geometry and
707 the other, as a new :class:`OGRGeometry` object.
709 .. method:: sym_difference
711 Returns the region consisting of the symmetric difference of this
712 geometry and the other, as a new :class:`OGRGeometry` object.
716 Returns the region consisting of the union of this geometry and
717 the other, as a new :class:`OGRGeometry` object.
721 Returns the coordinates of a point geometry as a tuple, the
722 coordinates of a line geometry as a tuple of tuples, and so forth::
724 >>> OGRGeometry('POINT (1 2)').tuple
726 >>> OGRGeometry('LINESTRING (1 2,3 4)').tuple
727 ((1.0, 2.0), (3.0, 4.0))
729 .. attribute:: coords
731 An alias for :attr:`tuple`.
737 Returns the X coordinate of this point::
739 >>> OGRGeometry('POINT (1 2)').x
744 Returns the Y coordinate of this point::
746 >>> OGRGeometry('POINT (1 2)').y
751 Returns the Z coordinate of this point, or ``None`` if the
752 the point does not have a Z coordinate::
754 >>> OGRGeometry('POINT (1 2 3)').z
757 .. class:: LineString
761 Returns a list of X coordinates in this line::
763 >>> OGRGeometry('LINESTRING (1 2,3 4)').x
768 Returns a list of Y coordinates in this line::
770 >>> OGRGeometry('LINESTRING (1 2,3 4)').y
775 Returns a list of Z coordinates in this line, or ``None`` if the
776 line does not have Z coordinates::
778 >>> OGRGeometry('LINESTRING (1 2 3,4 5 6)').z
786 Returns the shell or exterior ring of this polygon, as a ``LinearRing``
789 .. attribute:: exterior_ring
791 An alias for :attr:`shell`.
793 .. attribute:: centroid
795 Returns a :class:`Point` representing the centroid of this polygon.
797 .. class:: GeometryCollection
799 .. method:: add(geom)
801 Adds a geometry to this geometry collection. Not applicable to other
808 .. class:: OGRGeomType(type_input)
810 This class allows for the representation of an OGR geometry type
811 in any of several ways::
813 >>> from django.contrib.gis.gdal import OGRGeomType
814 >>> gt1 = OGRGeomType(3) # Using an integer for the type
815 >>> gt2 = OGRGeomType('Polygon') # Using a string
816 >>> gt3 = OGRGeomType('POLYGON') # It's case-insensitive
817 >>> print gt1 == 3, gt1 == 'Polygon' # Equivalence works w/non-OGRGeomType objects
822 Returns a short-hand string form of the OGR Geometry type::
829 Returns the number corresponding to the OGR geometry type::
834 .. attribute:: django
836 Returns the Django field type (a subclass of GeometryField) to use for
837 storing this OGR type, or ``None`` if there is no appropriate Django
846 .. class:: Envelope(*args)
848 Represents an OGR Envelope structure that contains the
849 minimum and maximum X, Y coordinates for a rectangle bounding box.
850 The naming of the variables is compatible with the OGR Envelope
855 The value of the minimum X coordinate.
859 The value of the maximum X coordinate.
863 The value of the minimum Y coordinate.
867 The value of the maximum Y coordinate.
871 The upper-right coordinate, as a tuple.
875 The lower-left coordinate, as a tuple.
879 A tuple representing the envelope.
883 A string representing this envelope as a polygon in WKT format.
886 .. method:: expand_to_include(self, *args)
888 Coordinate System Objects
889 =========================
894 .. class:: SpatialReference(srs_input)
896 Spatial reference objects are initialized on the given ``srs_input``,
897 which may be one of the following:
899 * OGC Well Known Text (WKT) (a string)
900 * EPSG code (integer or string)
902 * A shorthand string for well-known standards (``'WGS84'``, ``'WGS72'``, ``'NAD27'``, ``'NAD83'``)
906 >>> wgs84 = SpatialReference('WGS84') # shorthand string
907 >>> wgs84 = SpatialReference(4326) # EPSG code
908 >>> wgs84 = SpatialReference('EPSG:4326') # EPSG string
909 >>> proj4 = '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs '
910 >>> wgs84 = SpatialReference(proj4) # PROJ.4 string
911 >>> wgs84 = SpatialReference("""GEOGCS["WGS 84",
913 SPHEROID["WGS 84",6378137,298.257223563,
914 AUTHORITY["EPSG","7030"]],
915 AUTHORITY["EPSG","6326"]],
916 PRIMEM["Greenwich",0,
917 AUTHORITY["EPSG","8901"]],
918 UNIT["degree",0.01745329251994328,
919 AUTHORITY["EPSG","9122"]],
920 AUTHORITY["EPSG","4326"]]""") # OGC WKT
922 .. method:: __getitem__(target)
924 Returns the value of the given string attribute node, ``None`` if the node
925 doesn't exist. Can also take a tuple as a parameter, (target, child),
926 where child is the index of the attribute in the WKT. For example::
928 >>> wkt = 'GEOGCS["WGS 84", DATUM["WGS_1984, ... AUTHORITY["EPSG","4326"]]')
929 >>> srs = SpatialReference(wkt) # could also use 'WGS84', or 4326
930 >>> print srs['GEOGCS']
932 >>> print srs['DATUM']
934 >>> print srs['AUTHORITY']
936 >>> print srs['AUTHORITY', 1] # The authority value
938 >>> print srs['TOWGS84', 4] # the fourth value in this wkt
940 >>> print srs['UNIT|AUTHORITY'] # For the units authority, have to use the pipe symbol.
942 >>> print srs['UNIT|AUTHORITY', 1] # The authority value for the units
945 .. method:: attr_value(target, index=0)
947 The attribute value for the given target node (e.g. ``'PROJCS'``).
948 The index keyword specifies an index of the child node to return.
950 .. method:: auth_name(target)
952 Returns the authority name for the given string target node.
954 .. method:: auth_code(target)
956 Returns the authority code for the given string target node.
960 Returns a clone of this spatial reference object.
962 .. method:: identify_epsg()
964 This method inspects the WKT of this SpatialReference, and will
965 add EPSG authority nodes where an EPSG identifier is applicable.
967 .. method:: from_esri()
969 Morphs this SpatialReference from ESRI's format to EPSG
971 .. method:: to_esri()
973 Morphs this SpatialReference to ESRI's format.
975 .. method:: validate()
977 Checks to see if the given spatial reference is valid, if not
978 an exception will be raised.
980 .. method:: import_epsg(epsg)
982 Import spatial reference from EPSG code.
984 .. method:: import_proj(proj)
986 Import spatial reference from PROJ.4 string.
988 .. method:: import_user_input(user_input)
990 .. method:: import_wkt(wkt)
992 Import spatial reference from WKT.
994 .. method:: import_xml(xml)
996 Import spatial reference from XML.
1000 Returns the name of this Spatial Reference.
1004 Returns the SRID of top-level authority, or ``None`` if undefined.
1006 .. attribute:: linear_name
1008 Returns the name of the linear units.
1010 .. attribute:: linear_units
1012 Returns the value of the linear units.
1014 .. attribute:: angular_name
1016 Returns the name of the angular units."
1018 .. attribute:: angular_units
1020 Returns the value of the angular units.
1022 .. attribute:: units
1024 Returns a 2-tuple of the units value and the units name,
1025 and will automatically determines whether to return the linear
1028 .. attribute:: ellisoid
1030 Returns a tuple of the ellipsoid parameters for this spatial
1031 reference: (semimajor axis, semiminor axis, and inverse flattening)
1033 .. attribute:: semi_major
1035 Returns the semi major axis of the ellipsoid for this spatial reference.
1037 .. attribute:: semi_minor
1039 Returns the semi minor axis of the ellipsoid for this spatial reference.
1041 .. attribute:: inverse_flattening
1043 Returns the inverse flattening of the ellipsoid for this spatial reference.
1045 .. attribute:: geographic
1047 Returns ``True`` if this spatial reference is geographic
1048 (root node is ``GEOGCS``).
1050 .. attribute:: local
1052 Returns ``True`` if this spatial reference is local
1053 (root node is ``LOCAL_CS``).
1055 .. attribute:: projected
1057 Returns ``True`` if this spatial reference is a projected coordinate
1058 system (root node is ``PROJCS``).
1062 Returns the WKT representation of this spatial reference.
1064 .. attribute:: pretty_wkt
1066 Returns the 'pretty' representation of the WKT.
1070 Returns the PROJ.4 representation for this spatial reference.
1072 .. attribute:: proj4
1074 Alias for :attr:`SpatialReference.proj`.
1078 Returns the XML representation of this spatial reference.
1084 .. class:: CoordTransform(source, target)
1086 Represents a coordinate system transform. It is initialized with two
1087 :class:`SpatialReference`, representing the source and target coordinate
1088 systems, respectively. These objects should be used when performing
1089 the same coordinate transformation repeatedly on different geometries::
1091 >>> ct = CoordTransform(SpatialReference('WGS84'), SpatialReference('NAD83'))
1092 >>> for feat in layer:
1093 ... geom = feat.geom # getting clone of feature geometry
1094 ... geom.transform(ct) # transforming
1099 .. setting:: GDAL_LIBRARY_PATH
1104 A string specifying the location of the GDAL library. Typically,
1105 this setting is only used if the GDAL library is in a non-standard
1106 location (e.g., ``/home/john/lib/libgdal.so``).