jblindsay / whitebox-tools

An advanced geospatial data analysis platform
https://www.whiteboxgeo.com/
MIT License
962 stars 160 forks source link

Whitebox-Worflows: Erroneous results when using raster files in NAD83 projection #396

Closed stphnmrgn closed 8 months ago

stphnmrgn commented 8 months ago

@jblindsay Thank you for the great work on whitebox. While testing some tools in the new whitebox-workflows (1.2.2) it became apparent there are issues when writing and/or operating on raster datasets in projected coordinate system EPSG 5070 (NAD83/Conus Albers). Understood that raster-input-to-raster-output projections are challenging because every raster format stores projection information in different ways and that Whitebox is a one-man shop. Just wanted to put this on your radar in the hope it helps Whitebox.

tools tested:

Test for write_raster on DEM using EPSG 5070:

$ python
Python 3.10.13 | packaged by conda-forge | (main, Dec 23 2023, 15:36:39) [GCC 12.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from whitebox_workflows import WbEnvironment
>>> wbe = WbEnvironment()
>>> ds = wbe.read_raster("USGS_13_n40w085_20230407_5070.tif")
>>> wbe.write_raster(ds, "USGS_13_n40w085_20230407_5070_output.tif", compress=True)

Results for write_raster on DEM using EPSG 5070: wbw-qgis-results

This same result appears when performing fill_pits and/or breach_depressions_least_cost before writing the raster to disk.

Test for write_raster on DEM using EPSG 4326:

$ gdalwarp -q -t_srs EPSG:4326 -r bilinear USGS_13_n40w085_20230407_5070.tif USGS_13_n40w085_20230407_4326.tif
$ python
Python 3.10.13 | packaged by conda-forge | (main, Dec 23 2023, 15:36:39) [GCC 12.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from whitebox_workflows import WbEnvironment
>>> wbe = WbEnvironment()
>>> ds = wbe.read_raster("USGS_13_n40w085_20230407_4326.tif")
>>> wbe.write_raster(ds, "USGS_13_n40w085_20230407_4326_output.tif", compress=True)

Results for write_raster on DEM using EPSG 4326: wbw-qgis-results-4326

Environment

OS: Ubuntu 22.04.4 LTS on Windows 10 WSL Conda: 23.5.2 Python: 3.9.18 Pip: 23.2.1 Whitebox-Workflows: 1.2.2

stphnmrgn commented 8 months ago

UPDATE: it seems this was not an issue with projections, but rather compressions. When the input DEM used DEFLATE PREDICTOR=2|3, WBW would fail. When the input DEM used no compression or DEFLATE PREDICTOR=1, WBW seems to work fine.