Commit 99a36e0b authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Bugfixes and minor improvements.

parent 6cedabc1
...@@ -34,7 +34,6 @@ from py_tools_ds.geo.vector.topology \ ...@@ -34,7 +34,6 @@ from py_tools_ds.geo.vector.topology \
import get_footprint_polygon, polyVertices_outside_poly, fill_holes_within_poly import get_footprint_polygon, polyVertices_outside_poly, fill_holes_within_poly
from py_tools_ds.geo.vector.geometry import boxObj from py_tools_ds.geo.vector.geometry import boxObj
from py_tools_ds.io.raster.gdal import get_GDAL_ds_inmem from py_tools_ds.io.raster.gdal import get_GDAL_ds_inmem
from py_tools_ds.numeric.array import find_noDataVal
from py_tools_ds.compatibility.python.exceptions \ from py_tools_ds.compatibility.python.exceptions \
import TimeoutError as TimeoutError_comp, FileNotFoundError as FileNotFoundError_comp import TimeoutError as TimeoutError_comp, FileNotFoundError as FileNotFoundError_comp
from py_tools_ds.compatibility.gdal import get_gdal_func from py_tools_ds.compatibility.gdal import get_gdal_func
...@@ -342,7 +341,7 @@ class GeoArray(object): ...@@ -342,7 +341,7 @@ class GeoArray(object):
if not self.is_inmem: if not self.is_inmem:
self.set_gdalDataset_meta() self.set_gdalDataset_meta()
if self._nodata is None: if self._nodata is None:
self._nodata = find_noDataVal(self) self._nodata = self.find_noDataVal(self)
if self._nodata == 'ambiguous': if self._nodata == 'ambiguous':
warnings.warn('Nodata value could not be clearly identified. It has been set to None.') warnings.warn('Nodata value could not be clearly identified. It has been set to None.')
self._nodata = None self._nodata = None
...@@ -397,6 +396,13 @@ class GeoArray(object): ...@@ -397,6 +396,13 @@ class GeoArray(object):
%(imName, self.__class__.__name__) %(imName, self.__class__.__name__)
self._mask_nodata = geoArr_mask self._mask_nodata = geoArr_mask
else:
del self.mask_nodata
@mask_nodata.deleter
def mask_nodata(self):
self._mask_nodata = None
@property @property
...@@ -435,6 +441,13 @@ class GeoArray(object): ...@@ -435,6 +441,13 @@ class GeoArray(object):
%(imName, self.__class__.__name__) %(imName, self.__class__.__name__)
self._mask_baddata = geoArr_mask self._mask_baddata = geoArr_mask
else:
del self.mask_baddata
@mask_baddata.deleter
def mask_baddata(self):
self._mask_baddata = None
@property @property
...@@ -451,8 +464,8 @@ class GeoArray(object): ...@@ -451,8 +464,8 @@ class GeoArray(object):
self._footprint_poly = self.box.mapPoly self._footprint_poly = self.box.mapPoly
else: else:
try: try:
multipolygon = raster2polygon(self, exact=False, progress=self.progress, q=self.q, multipolygon = raster2polygon(self, self.gt, self.prj, exact=False, progress=self.progress,
maxfeatCount=10, timeout=3) q=self.q, maxfeatCount=10, timeout=3)
self._footprint_poly = fill_holes_within_poly(multipolygon) self._footprint_poly = fill_holes_within_poly(multipolygon)
except (RuntimeError, TimeoutError, TimeoutError_comp): except (RuntimeError, TimeoutError, TimeoutError_comp):
if not self.q: if not self.q:
...@@ -797,15 +810,15 @@ class GeoArray(object): ...@@ -797,15 +810,15 @@ class GeoArray(object):
if len(bL) == 1: if len(bL) == 1:
band = ds.GetRasterBand(bL[0] + 1) band = ds.GetRasterBand(bL[0] + 1)
out_arr= band.ReadAsArray(cS, rS, cE - cS + 1, rE - rS + 1) out_arr= band.ReadAsArray(cS, rS, cE - cS + 1, rE - rS + 1)
band = None del band
else: else:
out_arr = np.empty((rE - rS + 1, cE - cS + 1, len(bL))) out_arr = np.empty((rE - rS + 1, cE - cS + 1, len(bL)))
for i, bIdx in enumerate(bL): for i, bIdx in enumerate(bL):
band = ds.GetRasterBand(bIdx + 1) band = ds.GetRasterBand(bIdx + 1)
out_arr[:, :, i] = band.ReadAsArray(cS, rS, cE - cS + 1, rE - rS + 1) out_arr[:, :, i] = band.ReadAsArray(cS, rS, cE - cS + 1, rE - rS + 1)
band = None del band
ds = None del ds
if out_arr is None: if out_arr is None:
raise Exception('Error reading file: ' + gdal.GetLastErrorMsg()) raise Exception('Error reading file: ' + gdal.GetLastErrorMsg())
...@@ -862,7 +875,7 @@ class GeoArray(object): ...@@ -862,7 +875,7 @@ class GeoArray(object):
del meta2write['band_name'] del meta2write['band_name']
band.SetMetadata(meta2write) band.SetMetadata(meta2write)
band = None del band
# set global domain metadata # set global domain metadata
ds.SetMetadata(global_meta) ds.SetMetadata(global_meta)
...@@ -886,7 +899,7 @@ class GeoArray(object): ...@@ -886,7 +899,7 @@ class GeoArray(object):
gdal_Translate = get_gdal_func('Translate') gdal_Translate = get_gdal_func('Translate')
gdal_Translate(out_path, src_ds, format=fmt, creationOptions=creationOptions) gdal_Translate(out_path, src_ds, format=fmt, creationOptions=creationOptions)
src_ds = None del src_ds
if not os.path.exists(out_path): if not os.path.exists(out_path):
raise Exception(gdal.GetLastErrorMsg()) raise Exception(gdal.GetLastErrorMsg())
......
...@@ -11,8 +11,8 @@ with open('HISTORY.rst') as history_file: ...@@ -11,8 +11,8 @@ with open('HISTORY.rst') as history_file:
history = history_file.read() history = history_file.read()
requirements = [ requirements = [
'py_tools_ds', 'numpy', 'matplotlib', 'six', 'gdal', 'shapely', 'geopandas', 'dill', 'mpld3', 'geojson', 'folium', 'py_tools_ds', 'numpy', 'matplotlib', 'six', 'gdal', 'shapely', 'geopandas', 'pandas', 'dill', 'mpld3', 'geojson',
'scikit-image' 'folium', 'scikit-image'
#'holoviews', # conda install --yes -c ioam bokeh holoviews=1.8.0 ; \ #'holoviews', # conda install --yes -c ioam bokeh holoviews=1.8.0 ; \
# git+https://github.com/matplotlib/basemap.git # git+https://github.com/matplotlib/basemap.git
] ]
......
...@@ -15,7 +15,8 @@ RUN /bin/bash -i -c "source /root/anaconda3/bin/activate ; \ ...@@ -15,7 +15,8 @@ RUN /bin/bash -i -c "source /root/anaconda3/bin/activate ; \
conda install --yes -c conda-forge gdal ; \ conda install --yes -c conda-forge gdal ; \
conda install --yes -c conda-forge 'icu=58.*' lxml ; \ conda install --yes -c conda-forge 'icu=58.*' lxml ; \
conda install --yes -c conda-forge glymur pygrib rasterio pyproj cachetools basemap; \ conda install --yes -c conda-forge glymur pygrib rasterio pyproj cachetools basemap; \
pip install shapely geopandas dicttoxml jsmin cerberus pyprind pint iso8601 tqdm mpld3 sphinx-argparse folium geojson" pip install shapely geopandas pandas dicttoxml jsmin cerberus pyprind pint iso8601 tqdm mpld3 sphinx-argparse \
folium geojson"
# copy some needed stuff to /root # copy some needed stuff to /root
#COPY *.pkl /root/ # EXAMPLE #COPY *.pkl /root/ # EXAMPLE
......
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