Commit d953800f authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Merge branch 'bugfix/fix_get_coordarray' into 'master'

Fixed issue #15 (boxObj.get_coordArray_MapXY() returns faulty y-coordinate...

Closes #15

See merge request !26
parents 9391dfbc 38b9f0ec
Pipeline #16469 canceled with stages
in 2 minutes and 48 seconds
...@@ -2,6 +2,13 @@ ...@@ -2,6 +2,13 @@
History History
======= =======
0.16.4 (2020-12-07)
-------------------
* Fixed issue #15 (boxObj.get_coordArray_MapXY() returns faulty y-coordinate array).
* Test_boxObj.test_get_coordArray_MapXY() now also validates the output of boxObj.get_coordArray_MapXY().
0.16.3 (2020-12-03) 0.16.3 (2020-12-03)
------------------- -------------------
......
...@@ -220,7 +220,7 @@ class boxObj(object): ...@@ -220,7 +220,7 @@ class boxObj(object):
xmin, xmax, ymin, ymax = self.boundsMap xmin, xmax, ymin, ymax = self.boundsMap
Xarr, Yarr = np.meshgrid(np.arange(xmin, xmax, abs(self.gt[1])), Xarr, Yarr = np.meshgrid(np.arange(xmin, xmax, abs(self.gt[1])),
np.arange(ymin, ymax, abs(self.gt[5]))) np.arange(ymax, ymin, -abs(self.gt[5])))
if prj and not prj_equal(self.prj, prj): if prj and not prj_equal(self.prj, prj):
Xarr, Yarr = transform_coordArray(self.prj, prj, Xarr, Yarr) Xarr, Yarr = transform_coordArray(self.prj, prj, Xarr, Yarr)
......
...@@ -29,6 +29,7 @@ test_geometry ...@@ -29,6 +29,7 @@ test_geometry
Tests for `py_tools_ds.geo.vector.geometry` module. Tests for `py_tools_ds.geo.vector.geometry` module.
""" """
import numpy as np
from unittest import TestCase, main from unittest import TestCase, main
from py_tools_ds.geo.vector.geometry import boxObj, get_winPoly from py_tools_ds.geo.vector.geometry import boxObj, get_winPoly
...@@ -173,38 +174,51 @@ class Test_boxObj(TestCase): ...@@ -173,38 +174,51 @@ class Test_boxObj(TestCase):
self.assertEqual((x_larger, y_larger), (False, True)) self.assertEqual((x_larger, y_larger), (False, True))
def test_get_coordArray_MapXY(self): def test_get_coordArray_MapXY(self):
self.box.get_coordArray_MapXY() # test for correct output
coords_x, coords_y = self.box.get_coordArray_MapXY()
self.assertIsInstance(coords_x, np.ndarray)
self.assertTupleEqual(coords_x.shape, self.box.imDimsYX)
self.assertTupleEqual(coords_y.shape, self.box.imDimsYX)
self.assertEqual(coords_x[0, 0], self.box.boundsMap[0]) # ULx == xmin
self.assertEqual(coords_y[0, 0], self.box.boundsMap[3]) # ULy == ymax
self.assertTrue(np.isclose(coords_x[-1, -1] + self.box.gt[1],
self.box.boundsMap[1])) # LRx + xGSD == xmax
self.assertTrue(np.isclose(coords_y[-1, -1] - abs(self.box.gt[5]),
self.box.boundsMap[2])) # LRy - yGSD == ymin
# test to return coords array in another projection # test to return coords array in another projection
self.box.get_coordArray_MapXY(prj=' '.join(""" self.box.get_coordArray_MapXY(
PROJCS["WGS 84 / UTM zone 33N", prj=' '.join("""
GEOGCS["WGS 84", PROJCS["WGS 84 / UTM zone 33N",
DATUM["WGS_1984", GEOGCS["WGS 84",
SPHEROID["WGS 84", 6378137, 298.257223563, DATUM["WGS_1984",
AUTHORITY["EPSG", "7030"]], SPHEROID["WGS 84", 6378137, 298.257223563,
AUTHORITY["EPSG", "6326"]], AUTHORITY["EPSG", "7030"]],
PRIMEM["Greenwich", 0, AUTHORITY["EPSG", "6326"]],
AUTHORITY["EPSG", "8901"]], PRIMEM["Greenwich", 0,
UNIT["degree", 0.0174532925199433, AUTHORITY["EPSG", "8901"]],
AUTHORITY["EPSG", "9122"]], UNIT["degree", 0.0174532925199433,
AUTHORITY["EPSG", "4326"]], AUTHORITY["EPSG", "9122"]],
PROJECTION["Transverse_Mercator"], AUTHORITY["EPSG", "4326"]],
PARAMETER["latitude_of_origin", 0], PROJECTION["Transverse_Mercator"],
PARAMETER["central_meridian", 15], PARAMETER["latitude_of_origin", 0],
PARAMETER["scale_factor", 0.9996], PARAMETER["central_meridian", 15],
PARAMETER["false_easting", 500000], PARAMETER["scale_factor", 0.9996],
PARAMETER["false_northing", 0], PARAMETER["false_easting", 500000],
UNIT["metre", 1, PARAMETER["false_northing", 0],
AUTHORITY["EPSG", "9001"]], UNIT["metre", 1,
AXIS["Easting", EAST], AUTHORITY["EPSG", "9001"]],
AXIS["Northing", NORTH], AXIS["Easting", EAST],
AUTHORITY["EPSG", "32633"]] AXIS["Northing", NORTH],
""".split()) AUTHORITY["EPSG", "32633"]]
) """.split())
)
# test input validation
box = self.box box = self.box
box.prj = None box.prj = None
with self.assertRaises(ValueError): with self.assertRaisesRegex(
ValueError, 'geotransform and projection must both be available for computing coordinate array.'):
self.box.get_coordArray_MapXY() self.box.get_coordArray_MapXY()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment