Commit 7f161116 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

edited some assertion messages and docstrings, updated __version__

geo.raster.coversion:
- raster2polygon(): now raises RunTimeError if no polygons have been found; edited docstring

io.raster.GeoArray:
- footprint_poly: edited warning message; added assertion message

updated __version__
parent 6df976a1
......@@ -15,7 +15,7 @@ __all__=[#'compatibility',
'similarity',
'GeoArray']
__version__ = '20161102_01'
__version__ = '20161182_01'
__author__='Daniel Scheffler'
# Validate GDAL version
......
......@@ -26,9 +26,10 @@ def raster2polygon(array_or_GeoArray, gt=None, prj=None, DN2extract=1, exact=Tru
:param array_or_GeoArray:
:param gt:
:param prj:
:param DN2extract:
:param DN2extract: <int, float> pixel value to create polygons for
:param exact:
:param maxfeatCount:
:param maxfeatCount: <int> the maximum expected number of polygons. If more polygons are found, every further
processing is cancelled and a RunTimeError is raised.
:param timeout: breaks the process after a given time in seconds
:param progress: show progress bars (default: True)
:param q: quiet mode (default: False)
......@@ -77,11 +78,12 @@ def raster2polygon(array_or_GeoArray, gt=None, prj=None, DN2extract=1, exact=Tru
from geopandas import GeoDataFrame
featCount = mem_layer.GetFeatureCount()
if not featCount:
raise RuntimeError('No features with DN=%s found in the input image.' %DN2extract)
if maxfeatCount and featCount > maxfeatCount:
raise RuntimeError('Found %s features with DN=%s but maximum feature count was set to %s.'
%(featCount, DN2extract, maxfeatCount))
#if featCount>1:
#tmp = np.full((featCount,2), DN, geoArr.dtype)
#tmp[:,0] = range(featCount)
#GDF = GeoDataFrame(tmp, columns=['idx','DN'])
......
......@@ -293,13 +293,15 @@ class GeoArray(object):
except (RuntimeError, TimeoutError, TimeoutError_comp):
if not self.q:
warnings.warn("\nCalculation of footprint polygon failed for %s '%s'. Using outer bounds. One "
"reason could be that the nodata value appears within of the actual image. "
"To avoid this use another nodata value. Current nodata value is %s."
%(self.__class__.__name__, self.basename, self.nodata))
"reason could be that the nodata value appears within the actual image (not only "
"as fill value). To avoid this use another nodata value. Current nodata value is "
"%s." %(self.__class__.__name__, self.basename, self.nodata))
self._footprint_poly = self.box.mapPoly
# validation
assert not polyVertices_outside_poly(self._footprint_poly, self.box.mapPoly)
assert not polyVertices_outside_poly(self._footprint_poly, self.box.mapPoly),\
"Computing footprint polygon for %s '%s' failed. The resulting polygon is partly or completely outside " \
"of the image bounds." %(self.__class__.__name__, self.basename)
#assert self._footprint_poly
# for XY in self.corner_coord:
# assert self.GeoArray.box.mapPoly.contains(Point(XY)) or self.GeoArray.box.mapPoly.touches(Point(XY)), \
......
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