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

Bugfixes

geo.raster.reproject:
- warp_ndarray: added output bounds verification

io.raster.GeoArray:
- refactored _alias_property() to alias_property()
- GeoArray.reproject_to_new_grid(): bugfix for missing update of footprint_poly after reprojection

- updated __version__
parent 12324e3b
......@@ -15,7 +15,7 @@ __all__=[#'compatibility',
'similarity',
'GeoArray']
__version__ = '20170210_01'
__version__ = '20170221_01'
__author__='Daniel Scheffler'
# Validate GDAL version
......
......@@ -21,6 +21,7 @@ from rasterio.warp import Resampling
from ...dtypes.conversion import dTypeDic_NumPy2GDAL
from ..projection import WKT2EPSG, isProjectedOrGeographic, prj_equal
from ..coord_trafo import pixelToLatLon
from ..coord_calc import corner_coord_to_minmax, get_corner_coordinates
from ...io.raster.gdal import get_GDAL_ds_inmem
from ...processing.progress_mon import ProgressBar
from ...compatibility.gdal import get_gdal_func
......@@ -422,4 +423,11 @@ def warp_ndarray(ndarray, in_gt, in_prj, out_prj=None, out_dtype=None, out_gsd=(
if out_prj and prj_equal(out_prj,4626):
assert -180 < res_gt[0] < 180 and -90 < res_gt[3] < 90, 'Testing of gdal_warp output failed.'
# output bounds verification
if out_bounds:
xmin, xmax, ymin, ymax = \
corner_coord_to_minmax(get_corner_coordinates(gt=res_gt, rows=res_arr.shape[0], cols=res_arr.shape[1]))
if out_bounds != (xmin, ymin, xmax, ymax):
warnings.warn('The output bounds of warp_ndarray do not match the requested bounds!')
return res_arr, res_gt, res_prj
\ No newline at end of file
......@@ -40,7 +40,7 @@ from ...compatibility.python.exceptions import TimeoutError as TimeoutError_comp
from ...compatibility.gdal import get_gdal_func
def _alias_property(key):
def alias_property(key):
return property(
lambda self: getattr(self, key),
lambda self, val: setattr(self, key, val),
......@@ -208,7 +208,7 @@ class GeoArray(object):
return self.shape[1]
cols = _alias_property('columns')
cols = alias_property('columns')
@property
......@@ -249,7 +249,7 @@ class GeoArray(object):
self._geotransform = gt
gt = _alias_property('geotransform')
gt = alias_property('geotransform')
@property
......@@ -295,7 +295,7 @@ class GeoArray(object):
self._projection = prj
prj = _alias_property('projection')
prj = alias_property('projection')
@property
......@@ -497,7 +497,7 @@ class GeoArray(object):
self._metadata = GDF
meta = _alias_property('metadata')
meta = alias_property('metadata')
def __getitem__(self, given):
......@@ -1202,6 +1202,11 @@ class GeoArray(object):
rspAlg = 'near',
CPUs = CPUs)
# update footprint polygon
if self._footprint_poly:
if not (self.footprint_poly.within(self.box.mapPoly) or self.footprint_poly.equals(self.box.mapPoly)):
self.footprint_poly = self.footprint_poly.intersection(self.box.mapPoly)
def read_pointData(self, mapXY_points, mapXY_points_prj=None, band=None):
"""Returns the array values for the given set of X/Y coordinates.
......@@ -1471,7 +1476,7 @@ def _clip_array_at_mapPos(arr, mapBounds, arr_gt, band2clip=None, fillVal=0):
data = arr[rS_in:rE_in + 1, cS_in:cE_in + 1, band2clip] if band2clip is not None else \
arr[rS_in:rE_in + 1, cS_in:cE_in + 1, :]
# calculate correct area of out_arr to be filled and fill it with read data from input array
# calculate correct area of out_arr to be filled and fill it with read data from input array
cS_out, rS_out = [int(i) for i in mapXY2imXY((xmin_in, ymax_in), out_gt)]
cE_out, rE_out = [int(i)-1 for i in mapXY2imXY((xmax_in, ymin_in), out_gt)] # -1 because max values do not represent pixel origins
......
Markdown is supported
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