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

Passed metadata through to GeoArray subset that comes out of GeoArray.get_subset()

parent 8465e516
......@@ -657,7 +657,6 @@ class GeoArray(object):
# TODO add support for global domain metadata
if not self._gdalDataset_meta_already_set:
assert self.filePath
ds = gdal.Open(self.filePath)
......@@ -669,6 +668,7 @@ class GeoArray(object):
self._dtype = gdal_array.GDALTypeCodeToNumericTypeCode(ds.GetRasterBand(1).DataType)
self._geotransform = ds.GetGeoTransform()
self._projection = EPSG2WKT(WKT2EPSG(ds.GetProjection())) # temp conversion to EPSG needed because GDAL seems to modify WKT string when writing file to disk (e.g. using gdal_merge) -> conversion to EPSG and back undos that
if not 'nodata' in self._initParams or self._initParams['nodata'] is None:
band = ds.GetRasterBand(1)
self._nodata = band.GetNoDataValue() # FIXME this does not support different nodata values within the same file
......@@ -678,6 +678,10 @@ class GeoArray(object):
band = ds.GetRasterBand(b+1)
self.metadata[b] = GeoSeries(band.GetMetadata())
# read global domain metadata
# TODO add support for global domain metadata
ds = band = None
self._gdalDataset_meta_already_set = True
......@@ -1240,7 +1244,9 @@ class GeoArray(object):
zslice if zslice else slice(None)] # band
sub_ulXY = imXY2mapXY((xslice.start, yslice.start),
sub_gt = (sub_ulXY[0],[1],[2], sub_ulXY[1],[4],[5])
sub_gA = GeoArray(sub_arr, sub_gt, self.prj)
sub_gA = GeoArray(sub_arr, sub_gt, self.prj,
bandnames=list(self.bandnames.keys()), nodata=self.nodata, progress=self.progress, q=self.q)
sub_gA.meta = self.meta
return sub_gA if return_GeoArray else (sub_arr, sub_gt, self.prj)
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