summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Wiesmann <daniel.wiesmann@gmail.com>2015-10-28 12:05:22 +0000
committerClaude Paroz <claude@2xlibre.net>2015-10-28 15:27:19 +0100
commit48548d1a473a40adeaf292b63857efdd00a034be (patch)
tree8aea90c3617cabaa12fca4c141051ae8db7ceef2
parente5ab75d2fda8ef2617bc13074206e66c980ca51f (diff)
Refs #25588 -- Added the srid property to GDALRaster
Geometry objects have an srid property, so this addition makes the raster api more similar to the geometries api.
-rw-r--r--django/contrib/gis/gdal/raster/source.py14
-rw-r--r--docs/ref/contrib/gis/gdal.txt15
-rw-r--r--tests/gis_tests/gdal_tests/test_raster.py10
3 files changed, 39 insertions, 0 deletions
diff --git a/django/contrib/gis/gdal/raster/source.py b/django/contrib/gis/gdal/raster/source.py
index 3b4eb183b1..0f3a3a2744 100644
--- a/django/contrib/gis/gdal/raster/source.py
+++ b/django/contrib/gis/gdal/raster/source.py
@@ -215,6 +215,20 @@ class GDALRaster(GDALBase):
self._flush()
@property
+ def srid(self):
+ """
+ Shortcut to access the srid of this GDALRaster.
+ """
+ return self.srs.srid
+
+ @srid.setter
+ def srid(self, value):
+ """
+ Shortcut to set this GDALRaster's srs from an srid.
+ """
+ self.srs = value
+
+ @property
def geotransform(self):
"""
Returns the geotransform of the data source.
diff --git a/docs/ref/contrib/gis/gdal.txt b/docs/ref/contrib/gis/gdal.txt
index 3aea16ad36..afddcad094 100644
--- a/docs/ref/contrib/gis/gdal.txt
+++ b/docs/ref/contrib/gis/gdal.txt
@@ -1204,6 +1204,21 @@ blue.
>>> rst.srs.srid
3086
+ .. attribute:: srid
+
+ The Spatial Reference System Identifier (SRID) of the raster. This
+ property is a shortcut to getting or setting the SRID through the
+ :attr:`srs` attribute.
+
+ >>> rst = GDALRaster({'width': 10, 'height': 20, 'srid': 4326})
+ >>> rst.srid
+ 4326
+ >>> rst.srid = 3086
+ >>> rst.srid
+ 3086
+ >>> rst.srs.srid # This is equivalent
+ 3086
+
.. attribute:: geotransform
The affine transformation matrix used to georeference the source, as a
diff --git a/tests/gis_tests/gdal_tests/test_raster.py b/tests/gis_tests/gdal_tests/test_raster.py
index 257296a07d..8b9021bfc7 100644
--- a/tests/gis_tests/gdal_tests/test_raster.py
+++ b/tests/gis_tests/gdal_tests/test_raster.py
@@ -83,6 +83,16 @@ class GDALRasterTests(unittest.TestCase):
self.assertEqual(self.rs.srs.srid, 3086)
self.assertEqual(self.rs.srs.units, (1.0, 'metre'))
+ def test_rs_srid(self):
+ rast = GDALRaster({
+ 'width': 16,
+ 'height': 16,
+ 'srid': 4326,
+ })
+ self.assertEqual(rast.srid, 4326)
+ rast.srid = 3086
+ self.assertEqual(rast.srid, 3086)
+
def test_geotransform_and_friends(self):
# Assert correct values for file based raster
self.assertEqual(self.rs.geotransform,