Skip to content

no georeferencing info in geotiff output by rd_fill_spill_merge #79

@jkingslake

Description

@jkingslake

Problem

I am running rd_fill_spill_merge on a DEM and the resulting wtd file lacks x and y coordinates. The data exist in the geotiff, but when I try to load the geotiff (with rioxarray.open_rasterio for example) I get an warning and the resulting xarray has just x = 0.5, 1.5, 2.5 etc. and y = = 0.5, 1.5, 2.5 etc. instead of the coordinates I was expecting based on the georeferenced DEM I used as input.

Errors during execution

Also, despite successfully completing, I get several errors when I run rd_fill_spill_merge:

apps/rd_fill_spill_merge.exe  path/to/dem/dem_small_2.tif test 0 --swl 0.1  --save_dh  my_DH

yields

m Input DEM           = /Users/jkingslake/Documents/science/meltwater_routing/BFRN_meltwater/python/notebooks/rema_subsets/dem_small_2.tif
m Output prefix       = test
m Surface water level = 0.1
m Surface water file  = 
m Ocean level         = 0
p Reading topography...
ERROR 1: GetNoDataValue() should be called instead
m Data width  = 1024
m Data height = 3072
m Data cells  = 3145728
p Performing bucket fill...
p Getting depression hierarchy...
m Loading DH from my_DH
p Performing FillSpillMerge...
ERROR 6: test-wtd.tif: Dataset does not support the AddBand() method.
ERROR 6: test-hydrologic-surface-height.tif: Dataset does not support the AddBand() method.
Finished.
IO time   = 0.0696875 s
Calc time = 0.272173 s

The dem, dem_small_2.tif, is a georeferenced DEM i created using this function.

Some details on a few errors I get while compiling I am using mac 14.2.1 (23C71) Apple M2 chip.
cmake -DCMAKE_C_COMPILER="/opt/homebrew/Cellar/llvm/18.1.5/bin/clang" -D CMAKE_CXX_COMPILER="/opt/homebrew/Cellar/llvm/18.1.5/bin/clang++" -DUSE_GDAL=ON  -DCMAKE_BUILD_TYPE=Release -DCMAKE_BUILD_TYPE=Release -DBOOST_ROOT=/opt/homebrew/Cellar/boost/1.85.0 ..

make

it fails with errors:

[  1%] Building CXX object CMakeFiles/richdem.dir/src/richdem.cpp.o
[  2%] Building CXX object CMakeFiles/richdem.dir/src/random.cpp.o
[  4%] Building CXX object CMakeFiles/richdem.dir/src/gdal.cpp.o
[  5%] Building CXX object CMakeFiles/richdem.dir/src/terrain_generation/terrain_generation.cpp.o
[  7%] Building CXX object CMakeFiles/richdem.dir/src/terrain_generation/PerlinNoise.cpp.o
[  8%] Linking CXX shared library librichdem.dylib
[  8%] Built target richdem
[ 10%] Building CXX object CMakeFiles/richdem_unittests.dir/tests/tests.cpp.o
In file included from /Users/jkingslake/Documents/science/meltwater_routing/richdem/tests/tests.cpp:7:
In file included from /Users/jkingslake/Documents/science/meltwater_routing/richdem/include/richdem/richdem.hpp:7:
/Users/jkingslake/Documents/science/meltwater_routing/richdem/include/richdem/common/memory.hpp:52:13: warning: Cannot check memory statistics for this OS. [-W#pragma-messages]
   52 |     #pragma message("Cannot check memory statistics for this OS.")
      |             ^
/Users/jkingslake/Documents/science/meltwater_routing/richdem/tests/tests.cpp:71:16: warning: captured structured bindings are a C++20 extension [-Wc++20-extensions]
   71 |       REQUIRE( x==0 );
      |                ^
/Users/jkingslake/Documents/science/meltwater_routing/richdem/tests/tests.cpp:70:19: note: 'x' declared here
   70 |       const auto [x, y] = arr.iToxy(0);
      |                   ^
/Users/jkingslake/Documents/science/meltwater_routing/richdem/tests/tests.cpp:71:16: error: capturing a structured binding is not yet supported in OpenMP
   71 |       REQUIRE( x==0 );
      |                ^
/Users/jkingslake/Documents/science/meltwater_routing/richdem/tests/tests.cpp:70:19: note: 'x' declared here
   70 |       const auto [x, y] = arr.iToxy(0);
      |                   ^
/Users/jkingslake/Documents/science/meltwater_routing/richdem/tests/tests.cpp:72:16: warning: captured structured bindings are a C++20 extension [-Wc++20-extensions]
   72 |       REQUIRE( y==0 );
      |                ^
/Users/jkingslake/Documents/science/meltwater_routing/richdem/tests/tests.cpp:70:22: note: 'y' declared here
   70 |       const auto [x, y] = arr.iToxy(0);
      |                      ^
/Users/jkingslake/Documents/science/meltwater_routing/richdem/tests/tests.cpp:72:16: error: capturing a structured binding is not yet supported in OpenMP
   72 |       REQUIRE( y==0 );
      |                ^
/Users/jkingslake/Documents/science/meltwater_routing/richdem/tests/tests.cpp:70:22: note: 'y' declared here
   70 |       const auto [x, y] = arr.iToxy(0);
      |                      ^
/Users/jkingslake/Documents/science/meltwater_routing/richdem/tests/tests.cpp:77:16: warning: captured structured bindings are a C++20 extension [-Wc++20-extensions]
   77 |       REQUIRE( x==arr.width()-1  );
      |                ^
/Users/jkingslake/Documents/science/meltwater_routing/richdem/tests/tests.cpp:76:19: note: 'x' declared here
   76 |       const auto [x,y] = arr.iToxy(arr.size()-1);
      |                   ^
/Users/jkingslake/Documents/science/meltwater_routing/richdem/tests/tests.cpp:77:16: error: capturing a structured binding is not yet supported in OpenMP
   77 |       REQUIRE( x==arr.width()-1  );
      |                ^
/Users/jkingslake/Documents/science/meltwater_routing/richdem/tests/tests.cpp:76:19: note: 'x' declared here
   76 |       const auto [x,y] = arr.iToxy(arr.size()-1);
      |                   ^
/Users/jkingslake/Documents/science/meltwater_routing/richdem/tests/tests.cpp:78:16: warning: captured structured bindings are a C++20 extension [-Wc++20-extensions]
   78 |       REQUIRE( y==arr.height()-1 );
      |                ^
/Users/jkingslake/Documents/science/meltwater_routing/richdem/tests/tests.cpp:76:21: note: 'y' declared here
   76 |       const auto [x,y] = arr.iToxy(arr.size()-1);
      |                     ^
/Users/jkingslake/Documents/science/meltwater_routing/richdem/tests/tests.cpp:78:16: error: capturing a structured binding is not yet supported in OpenMP
   78 |       REQUIRE( y==arr.height()-1 );
      |                ^
/Users/jkingslake/Documents/science/meltwater_routing/richdem/tests/tests.cpp:76:21: note: 'y' declared here
   76 |       const auto [x,y] = arr.iToxy(arr.size()-1);
      |                     ^
5 warnings and 4 errors generated.
make[2]: *** [CMakeFiles/richdem_unittests.dir/tests/tests.cpp.o] Error 1
make[1]: *** [CMakeFiles/richdem_unittests.dir/all] Error 2
make: *** [all] Error 2

If you run

make -j 10

it manages to get to the fill-spill-merge compile before it fails on test.cpp as seen in the errors above.

Any help would be much appreciated!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions