csiro-hydrogeology / pyela

Python package for Exploratory Lithology Analysis
Other
24 stars 5 forks source link

add_height for DEM plus Depths: issue with rasterio rasters with NODATA -3.4e38 #2

Closed jmp75 closed 5 years ago

jmp75 commented 5 years ago

Was getting very large magnitude AHD heights after blending COndamine DEM

Diagnosing in debug mode, it looks like a change of value from np.float32 to np.float64 on assigning (as an aside, unintuitive)

v[i] = read_raster_value(self.dem_raster, self.data_grid, x[i], y[i])
v.dtype
dtype('float64')
self.data_grid.dtype
dtype('float32')
v[0]
-3.3999999521443642e+38
self.data_grid[0][0]
-3.4e+38
self.dem_raster.nodata
-3.4e+38

so, further comparison in whether v[i] is equal to raster.nodata fails.

jmp75 commented 5 years ago

Changed to cast the raster.nodata to a np.float32. Works better with a raster where the band data is indeed returned as an np.float32 but remains to be seen whether works with other, preexisting cases e.g. and foremost on the Peel.

jmp75 commented 5 years ago

Another version of this issue is likely to show up on other data sets, but this can be closed.