Commit 0449ff41 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Fixed exception in case Tie_Point_Grid.to_PointShapefile() is called with skip_nodata=False.

parent 92366aca
Pipeline #3290 failed with stages
in 3 minutes and 35 seconds
...@@ -609,11 +609,16 @@ class Tie_Point_Grid(object): ...@@ -609,11 +609,16 @@ class Tie_Point_Grid(object):
""" """
GDF = self.CoRegPoints_table GDF = self.CoRegPoints_table
GDF2pass = GDF if not skip_nodata else GDF[GDF[skip_nodata_col] != self.outFillVal]
if skip_nodata:
GDF2pass = GDF
else:
GDF2pass = GDF[GDF[skip_nodata_col] != self.outFillVal].copy()
GDF2pass.LAST_ERR = GDF2pass.apply(lambda GDF_row: repr(GDF_row.LAST_ERR), axis=1)
# replace boolean values (cannot be written) # replace boolean values (cannot be written)
GDF2pass = GDF2pass.replace(False, 0) # replace all booleans where column dtype is not np.bool but np.object GDF2pass = GDF2pass.replace(False, 0).copy() # replace booleans where column dtype is not np.bool but np.object
GDF2pass = GDF2pass.replace(True, 1) GDF2pass = GDF2pass.replace(True, 1).copy()
for col in GDF2pass.columns: for col in GDF2pass.columns:
if GDF2pass[col].dtype == np.bool: if GDF2pass[col].dtype == np.bool:
GDF2pass[col] = GDF2pass[col].astype(int) GDF2pass[col] = GDF2pass[col].astype(int)
......
__version__ = '0.8.9' __version__ = '0.8.10'
__versionalias__ = '2018-11-27_01' __versionalias__ = '2018-11-28_01'
...@@ -74,6 +74,11 @@ class Test_Tie_Point_Grid(unittest.TestCase): ...@@ -74,6 +74,11 @@ class Test_Tie_Point_Grid(unittest.TestCase):
self.TPG.to_PointShapefile(outpath) self.TPG.to_PointShapefile(outpath)
self.assertTrue(os.path.isfile(outpath)) self.assertTrue(os.path.isfile(outpath))
with tempfile.TemporaryDirectory() as tmpdir:
outpath = os.path.join(tmpdir, 'test_out_shapefile_incl_nodata.shp')
self.TPG.to_PointShapefile(outpath, skip_nodata=False)
self.assertTrue(os.path.isfile(outpath))
def test_to_vectorfield(self): def test_to_vectorfield(self):
with tempfile.TemporaryDirectory() as tmpdir: with tempfile.TemporaryDirectory() as tmpdir:
outpath = os.path.join(tmpdir, 'test_vectorfield.bsq') outpath = os.path.join(tmpdir, 'test_vectorfield.bsq')
......
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