Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All pixels shift to the right in very large rasters #53

Open
hampmark opened this issue Nov 9, 2019 · 8 comments
Open

All pixels shift to the right in very large rasters #53

hampmark opened this issue Nov 9, 2019 · 8 comments
Labels
bug Something isn't working

Comments

@hampmark
Copy link

hampmark commented Nov 9, 2019

When using either BreachDepressions or D8FlowAccumulation on a large raster exceeding 500 000 000 pixels, the resulting raster will be shifted one pixel to the right.

raster_shift_1pixel

@jblindsay
Copy link
Owner

@hampmark I encountered this error myself for the first time the other day. I'll do some digging to see if I can figure out what is going on but it would be useful for me to know what file format the input and output files were in, e.g. GeoTIFF, and what front-end you were using for WhiteboxTools.

@jblindsay jblindsay added the bug Something isn't working label Nov 11, 2019
@hampmark
Copy link
Author

I used the python bindings to WhiteboxTools on a Windows 10 machine (Python 3.5-64bit, Whitebox tools 1.0.0).

I believe all tested so far are GeoTIFF, and I append the information on 3 rasters used where the first (info_INDATA.png) is used to produce a breached DEM (info_BREACHED.png) which in turn was used as indata to create D8_flowacc (info_FLOWACC.png). All 3 raster are shifted one pixel for every operation performed. In this case it means that the D8_flowacc raster is shifted 2 pixels to the right of the first indata raster.

info_INDATA
info_BREACHED
info_FLOWACC

@jblindsay
Copy link
Owner

I'm sorry to be a bother, but would you mind running the PrintGeoTiffTags tool on both the input and output files and post the tool output? It provides a level of detail on the data that I will need to diagnose the issue. Thanks.

@jblindsay
Copy link
Owner

This is also a possible duplicate of Issue #45 although that bug report documents a half-pixel shift instead.

@hampmark
Copy link
Author

Here is the log with the detailed information:

Processing DEM: //MARK-VVANALYS8/D$/HM/aros_fromfaruk/outdata/bigger2m/372820_6246331_428933_6320224_2m_dem_crop.tif
.\whitebox_tools.exe --run="PrintGeoTiffTags" --wd="c:\sim\hampus\python_whitebox" --input='//MARK-VVANALYS8/D$/HM/aros_fromfaruk/outdata/bigger2m/372820_6246331_428933_6320224_2m_dem_crop.tif' -v


  • Welcome to PrintGeoTiffTags *

Little-endian byte order used
BigTIFF format
TIFF Tags:
Number of tags: 19
ImageWidth (code=256 type=DT_Short): 56113
ImageLength (code=257 type=DT_Long offset=73893): 73893
BitsPerSample (code=258 type=DT_Short): 32
Compression (code=259 type=DT_Short): "None" (1)
PhotometricInterpretation (code=262 type=DT_Short): "BlackIsZero" (1)
SamplesPerPixel (code=277 type=DT_Short): 1
PlanarConfiguration (code=284 type=DT_Short): "Contiguous" (1)
TileWidth (code=322 type=DT_Short): 128
TileLength (code=323 type=DT_Short): 128
TileOffsets (code=324 type=DT_Long8 count=253742 offset=16635327066): [4061021, 4126557, 4192093, 4257629, 4323165, 4388701, 4454237, 4519773, 4585309, 4650845, 4716381, 4781917, 4847453, 4912989, 4978525, 5044061, 5109597, 5175133, 5240669, 5306205, 5371741, 5437277, 5502813, 5568349, 5633885, 5699421, 5764957, 5830493, 5896029, 5961565, 6027101, 6092637, 6158173, 6223709, 6289245, 6354781, 6420317, 6485853, 6551389, 6616925, 6682461, 6747997, 6813533, 6879069, 6944605, 7010141, 7075677, 7141213, 7206749, 7272285, 7337821, 7403357, 7468893, 7534429, 7599965, 7665501, 7731037, 7796573, 7862109, 7927645, 7993181, 8058717, 8124253, 8189789, 8255325, 8320861, 8386397, 8451933, 8517469, 8583005, 8648541, 8714077, 8779613, 8845149, 8910685, 8976221, 9041757, 9107293, 9172829, 9238365, 9303901, 9369437, 9434973, 9500509, 9566045, 9631581, 9697117, 9762653, 9828189, 9893725, 9959261, 10024797, 10090333, 10155869, 10221405, 10286941, 10352477, 10418013, 10483549, 10549085]
TileByteCounts (code=325 type=DT_Long8 count=253742 offset=16633297130): [65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536, 65536]
SampleFormat (code=339 type=DT_Short): "Floating point data" (3)
ModelPixelScaleTag (code=33550 type=DT_Double count=3 offset=16637357002): [2.0, 2.0, 0.0]
ModelTiepointTag (code=33922 type=DT_Double count=6 offset=16637357026): [0.0, 0.0, 0.0, 372820.0, 6394118.0, 0.0]
GeoKeyDirectoryTag (code=34735 type=DT_Short count=68 offset=16637357074): [1, 1, 0, 16, 1024, 0, 1, 1, 1025, 0, 1, 1, 1026, 34737, 23, 0, 2048, 0, 1, 4619, 2049, 34737, 84, 23, 2050, 0, 1, 6619, 2051, 0, 1, 8901, 2054, 0, 1, 9102, 2055, 34736, 1, 0, 2056, 0, 1, 7019, 2057, 34736, 1, 1, 2059, 34736, 1, 2, 2061, 34736, 1, 3, 3072, 0, 1, 3006, 3073, 34737, 409, 107, 3076, 0, 1, 9001]
GeoDoubleParamsTag (code=34736 type=DT_Double count=4 offset=16637357210): [0.0174532925199433, 6378137.0, 298.257222101, 0.0]
GeoAsciiParamsTag (code=34737 type=DT_ASCII count=517 offset=16637357242): PCS Name = SWEREF99_TM|GCS Name = GCS_SWEREF99|Datum = D_SWEREF99|Ellipsoid = GRS_1980|Primem = Greenwich||ESRI PE String = PROJCS["SWEREF99_TM",GEOGCS["GCS_SWEREF99",DATUM["D_SWEREF99",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",15.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]|
GDAL_METADATA (code=42112 type=DT_ASCII count=477 offset=16637357760):

377.5768737793
176.36290490658
-0.25201225280762
1
1
56.197052251384

GDAL_NODATA (code=42113 type=DT_ASCII count=5 offset=960051501): -999
GeoKey Info:
Version: 1
Key revision: 1.0
GTModelTypeGeoKey (code=1024): ModelTypeProjected (1)
GTRasterTypeGeoKey (code=1025): RasterPixelIsArea (1)
GTCitationGeoKey (code=1026, type=ASCII): PCS Name = SWEREF99_TM
GeographicTypeGeoKey (code=2048): Unrecognized value (4619)
GeogCitationGeoKey (code=2049, type=ASCII): GCS Name = GCS_SWEREF99Datum = D_SWEREF99Ellipsoid = GRS_1980Primem = Greenwich
GeogGeodeticDatumGeoKey (code=2050): Unrecognized value (6619)
GeogPrimeMeridianGeoKey (code=2051): PM_Greenwich (8901)
GeogAngularUnitsGeoKey (code=2054): Angular_Degree (9102)
GeogAngularUnitSizeGeoKey (code=2055, type=Double, count=1): 0.0174532925199433
GeogEllipsoidGeoKey (code=2056): Ellipse_GRS_1980 (7019)
GeogSemiMajorAxisGeoKey (code=2057, type=Double, count=1): 6378137
GeogInvFlatteningGeoKey (code=2059, type=Double, count=1): 298.257222101
GeogPrimeMeridianLongGeoKey (code=2061, type=Double, count=1): 0
ProjectedCSTypeGeoKey (code=3072): Unrecognized value (3006)
PCSCitationGeoKey (code=3073, type=ASCII): ESRI PE String = PROJCS["SWEREF99_TM",GEOGCS["GCS_SWEREF99",DATUM["D_SWEREF99",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",15.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]
ProjLinearUnitsGeoKey (code=3076): Linear_Meter (9001)
Time used so far:
Time passed so far hour:min:sek = 00:00:00

Processing DEM: //MARK-VVANALYS8/D$/HM/aros_fromfaruk/outdata/bigger2m/Breached_DEMs/WBT372820_6246331_428933_6320224_2m_dem_crop.tif
.\whitebox_tools.exe --run="PrintGeoTiffTags" --wd="c:\sim\hampus\python_whitebox" --input='//MARK-VVANALYS8/D$/HM/aros_fromfaruk/outdata/bigger2m/Breached_DEMs/WBT372820_6246331_428933_6320224_2m_dem_crop.tif' -v


  • Welcome to PrintGeoTiffTags *

Little-endian byte order used
BigTIFF format
TIFF Tags:
Number of tags: 20
ImageWidth (code=256 type=DT_Long offset=56113): 56113
ImageLength (code=257 type=DT_Long offset=73893): 73893
BitsPerSample (code=258 type=DT_Short): 64
Compression (code=259 type=DT_Short): "None" (1)
PhotometricInterpretation (code=262 type=DT_Short): "BlackIsZero" (1)
StripOffsets (code=273 type=DT_Long8 count=73893 offset=33170863704): [8, 448912, 897816, 1346720, 1795624, 2244528, 2693432, 3142336, 3591240, 4040144, 4489048, 4937952, 5386856, 5835760, 6284664, 6733568, 7182472, 7631376, 8080280, 8529184, 8978088, 9426992, 9875896, 10324800, 10773704, 11222608, 11671512, 12120416, 12569320, 13018224, 13467128, 13916032, 14364936, 14813840, 15262744, 15711648, 16160552, 16609456, 17058360, 17507264, 17956168, 18405072, 18853976, 19302880, 19751784, 20200688, 20649592, 21098496, 21547400, 21996304, 22445208, 22894112, 23343016, 23791920, 24240824, 24689728, 25138632, 25587536, 26036440, 26485344, 26934248, 27383152, 27832056, 28280960, 28729864, 29178768, 29627672, 30076576, 30525480, 30974384, 31423288, 31872192, 32321096, 32770000, 33218904, 33667808, 34116712, 34565616, 35014520, 35463424, 35912328, 36361232, 36810136, 37259040, 37707944, 38156848, 38605752, 39054656, 39503560, 39952464, 40401368, 40850272, 41299176, 41748080, 42196984, 42645888, 43094792, 43543696, 43992600, 44441504]
SamplesPerPixel (code=277 type=DT_Short): 1
RowsPerStrip (code=278 type=DT_Short): 1
StripByteCounts (code=279 type=DT_Long8 count=73893 offset=33171454848): [448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904]
XResolution (code=282 type=DT_Rational offset=33172045992): 168, 64, 53, 185, 7, 0, 0, 0
YResolution (code=283 type=DT_Rational offset=33172046000): 176, 64, 53, 185, 7, 0, 0, 0
ResolutionUnit (code=296 type=DT_Short): "Dots per inch" (2)
Software (code=305 type=DT_ASCII count=14 offset=33172046008): WhiteboxTools
SampleFormat (code=339 type=DT_Short): "Floating point data" (3)
ModelPixelScaleTag (code=33550 type=DT_Double count=3 offset=33172046022): [2.0, 2.0, 0.0]
ModelTiepointTag (code=33922 type=DT_Double count=6 offset=33172046046): [0.0, 0.0, 0.0, 372820.0, 6394118.0, 0.0]
GeoKeyDirectoryTag (code=34735 type=DT_Short count=68 offset=33172046104): [1, 1, 0, 16, 1024, 0, 1, 1, 1025, 0, 1, 1, 1026, 34737, 23, 0, 2048, 0, 1, 4619, 2049, 34737, 84, 23, 2050, 0, 1, 6619, 2051, 0, 1, 8901, 2054, 0, 1, 9102, 2055, 34736, 1, 0, 2056, 0, 1, 7019, 2057, 34736, 1, 1, 2059, 34736, 1, 2, 2061, 34736, 1, 3, 3072, 0, 1, 3006, 3073, 34737, 409, 107, 3076, 0, 1, 9001]
GeoDoubleParamsTag (code=34736 type=DT_Double count=4 offset=33172046240): [0.0174532925199433, 6378137.0, 298.257222101, 0.0]
GeoAsciiParamsTag (code=34737 type=DT_ASCII count=517 offset=33172046272): PCS Name = SWEREF99_TM|GCS Name = GCS_SWEREF99|Datum = D_SWEREF99|Ellipsoid = GRS_1980|Primem = Greenwich||ESRI PE String = PROJCS["SWEREF99_TM",GEOGCS["GCS_SWEREF99",DATUM["D_SWEREF99",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",15.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]|
GDAL_NODATA (code=42113 type=DT_ASCII count=10 offset=33172046094): -999
GeoKey Info:
Version: 1
Key revision: 1.0
GTModelTypeGeoKey (code=1024): ModelTypeProjected (1)
GTRasterTypeGeoKey (code=1025): RasterPixelIsArea (1)
GTCitationGeoKey (code=1026, type=ASCII): PCS Name = SWEREF99_TM
GeographicTypeGeoKey (code=2048): Unrecognized value (4619)
GeogCitationGeoKey (code=2049, type=ASCII): GCS Name = GCS_SWEREF99Datum = D_SWEREF99Ellipsoid = GRS_1980Primem = Greenwich
GeogGeodeticDatumGeoKey (code=2050): Unrecognized value (6619)
GeogPrimeMeridianGeoKey (code=2051): PM_Greenwich (8901)
GeogAngularUnitsGeoKey (code=2054): Angular_Degree (9102)
GeogAngularUnitSizeGeoKey (code=2055, type=Double, count=1): 0.0174532925199433
GeogEllipsoidGeoKey (code=2056): Ellipse_GRS_1980 (7019)
GeogSemiMajorAxisGeoKey (code=2057, type=Double, count=1): 6378137
GeogInvFlatteningGeoKey (code=2059, type=Double, count=1): 298.257222101
GeogPrimeMeridianLongGeoKey (code=2061, type=Double, count=1): 0
ProjectedCSTypeGeoKey (code=3072): Unrecognized value (3006)
PCSCitationGeoKey (code=3073, type=ASCII): ESRI PE String = PROJCS["SWEREF99_TM",GEOGCS["GCS_SWEREF99",DATUM["D_SWEREF99",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",15.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]
ProjLinearUnitsGeoKey (code=3076): Linear_Meter (9001)
Time used so far:
Time passed so far hour:min:sek = 00:00:00

Processing DEM: //MARK-VVANALYS8/D$/HM/aros_fromfaruk/outdata/bigger2m/Breached_DEMs/D8_Flowacc/WBT372820_6246331_428933_6320224_2m_dem_crop.tif
.\whitebox_tools.exe --run="PrintGeoTiffTags" --wd="c:\sim\hampus\python_whitebox" --input='//MARK-VVANALYS8/D$/HM/aros_fromfaruk/outdata/bigger2m/Breached_DEMs/D8_Flowacc/WBT372820_6246331_428933_6320224_2m_dem_crop.tif' -v


  • Welcome to PrintGeoTiffTags *

Little-endian byte order used
BigTIFF format
TIFF Tags:
Number of tags: 20
ImageWidth (code=256 type=DT_Long offset=56113): 56113
ImageLength (code=257 type=DT_Long offset=73893): 73893
BitsPerSample (code=258 type=DT_Short): 64
Compression (code=259 type=DT_Short): "None" (1)
PhotometricInterpretation (code=262 type=DT_Short): "BlackIsZero" (1)
StripOffsets (code=273 type=DT_Long8 count=73893 offset=33170863704): [8, 448912, 897816, 1346720, 1795624, 2244528, 2693432, 3142336, 3591240, 4040144, 4489048, 4937952, 5386856, 5835760, 6284664, 6733568, 7182472, 7631376, 8080280, 8529184, 8978088, 9426992, 9875896, 10324800, 10773704, 11222608, 11671512, 12120416, 12569320, 13018224, 13467128, 13916032, 14364936, 14813840, 15262744, 15711648, 16160552, 16609456, 17058360, 17507264, 17956168, 18405072, 18853976, 19302880, 19751784, 20200688, 20649592, 21098496, 21547400, 21996304, 22445208, 22894112, 23343016, 23791920, 24240824, 24689728, 25138632, 25587536, 26036440, 26485344, 26934248, 27383152, 27832056, 28280960, 28729864, 29178768, 29627672, 30076576, 30525480, 30974384, 31423288, 31872192, 32321096, 32770000, 33218904, 33667808, 34116712, 34565616, 35014520, 35463424, 35912328, 36361232, 36810136, 37259040, 37707944, 38156848, 38605752, 39054656, 39503560, 39952464, 40401368, 40850272, 41299176, 41748080, 42196984, 42645888, 43094792, 43543696, 43992600, 44441504]
SamplesPerPixel (code=277 type=DT_Short): 1
RowsPerStrip (code=278 type=DT_Short): 1
StripByteCounts (code=279 type=DT_Long8 count=73893 offset=33171454848): [448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904, 448904]
XResolution (code=282 type=DT_Rational offset=33172045992): 168, 64, 53, 185, 7, 0, 0, 0
YResolution (code=283 type=DT_Rational offset=33172046000): 176, 64, 53, 185, 7, 0, 0, 0
ResolutionUnit (code=296 type=DT_Short): "Dots per inch" (2)
Software (code=305 type=DT_ASCII count=14 offset=33172046008): WhiteboxTools
SampleFormat (code=339 type=DT_Short): "Floating point data" (3)
ModelPixelScaleTag (code=33550 type=DT_Double count=3 offset=33172046022): [2.0, 2.0, 0.0]
ModelTiepointTag (code=33922 type=DT_Double count=6 offset=33172046046): [0.0, 0.0, 0.0, 372820.0, 6394118.0, 0.0]
GeoKeyDirectoryTag (code=34735 type=DT_Short count=68 offset=33172046104): [1, 1, 0, 16, 1024, 0, 1, 1, 1025, 0, 1, 1, 1026, 34737, 23, 0, 2048, 0, 1, 4619, 2049, 34737, 84, 23, 2050, 0, 1, 6619, 2051, 0, 1, 8901, 2054, 0, 1, 9102, 2055, 34736, 1, 0, 2056, 0, 1, 7019, 2057, 34736, 1, 1, 2059, 34736, 1, 2, 2061, 34736, 1, 3, 3072, 0, 1, 3006, 3073, 34737, 409, 107, 3076, 0, 1, 9001]
GeoDoubleParamsTag (code=34736 type=DT_Double count=4 offset=33172046240): [0.0174532925199433, 6378137.0, 298.257222101, 0.0]
GeoAsciiParamsTag (code=34737 type=DT_ASCII count=517 offset=33172046272): PCS Name = SWEREF99_TM|GCS Name = GCS_SWEREF99|Datum = D_SWEREF99|Ellipsoid = GRS_1980|Primem = Greenwich||ESRI PE String = PROJCS["SWEREF99_TM",GEOGCS["GCS_SWEREF99",DATUM["D_SWEREF99",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",15.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]|
GDAL_NODATA (code=42113 type=DT_ASCII count=10 offset=33172046094): -999
GeoKey Info:
Version: 1
Key revision: 1.0
GTModelTypeGeoKey (code=1024): ModelTypeProjected (1)
GTRasterTypeGeoKey (code=1025): RasterPixelIsArea (1)
GTCitationGeoKey (code=1026, type=ASCII): PCS Name = SWEREF99_TM
GeographicTypeGeoKey (code=2048): Unrecognized value (4619)
GeogCitationGeoKey (code=2049, type=ASCII): GCS Name = GCS_SWEREF99Datum = D_SWEREF99Ellipsoid = GRS_1980Primem = Greenwich
GeogGeodeticDatumGeoKey (code=2050): Unrecognized value (6619)
GeogPrimeMeridianGeoKey (code=2051): PM_Greenwich (8901)
GeogAngularUnitsGeoKey (code=2054): Angular_Degree (9102)
GeogAngularUnitSizeGeoKey (code=2055, type=Double, count=1): 0.0174532925199433
GeogEllipsoidGeoKey (code=2056): Ellipse_GRS_1980 (7019)
GeogSemiMajorAxisGeoKey (code=2057, type=Double, count=1): 6378137
GeogInvFlatteningGeoKey (code=2059, type=Double, count=1): 298.257222101
GeogPrimeMeridianLongGeoKey (code=2061, type=Double, count=1): 0
ProjectedCSTypeGeoKey (code=3072): Unrecognized value (3006)
PCSCitationGeoKey (code=3073, type=ASCII): ESRI PE String = PROJCS["SWEREF99_TM",GEOGCS["GCS_SWEREF99",DATUM["D_SWEREF99",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",15.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]
ProjLinearUnitsGeoKey (code=3076): Linear_Meter (9001)

@jfbourdon
Copy link
Contributor

I think that something wrong is happening when writing Float64 GeoTIFF or simply writing BigTIFF variant. In my current workflow, I execute in order FillSingleCellPits, BreachSingleCellPits, BreachDepressionsLeastCost and BreachDepressions. All my inputs and outputs are GeoTIFF, but only the last two operation are shifted, BreachDepressionsLeastCost output being shifted 1 pixel to the right and BreachDepressions ouput being shifted 2 pixels to the right relative to my original DEM.

It is important to note that the extent of all output files are the same as the original DEM, so the shift to the right makes the last colum to right vanishing while the first colum to the left being filled with NoData.

Here is some data to try (link valid for the next 14 days) and my current code. I'll do more tests to try find if the issue is with Float64 TIFF or with BigTIFF, (but I think it's with BigTIFF as e same workflow with a subset of the DEM doesn't produce any shift).

import os
import subprocess

wbt_dir = "WhiteboxTools_1.2.0" # WhiteboxTools directory
outdir = "shifting_problems" # working directory
dem_path = os.path.join(outdir, "DEM.tif")

# Fill Single-Cell Pits (FSCP)
outFSCP = os.path.join(outdir, "DEM_1_FSCP.tif")
cmd = " ".join([wbt_dir + "\\whitebox_tools.exe",
                "-r=FillSingleCellPits",
                "--dem='" + dem_path + "'",
                "--output='" + outFSCP + "'",
                "-v"])
subprocess.run(cmd)

# Breach Single-Cell Pits (BSCP)
outFBSCP = os.path.join(outdir, "DEM_2_FBSCP.tif")
cmd = " ".join([wbt_dir + "\\whitebox_tools.exe",
                "-r=BreachSingleCellPits",
                "--dem='" + outFSCP + "'",
                "--output='" + outFBSCP + "'",
                "-v"])
subprocess.run(cmd)

# Breach Depressions Least-Cost
outFBSCP_BREACH = os.path.join(outdir, "DEM_3_FBSCP_BREACH.tif")
cmd = " ".join([wbt_dir + "\\whitebox_tools.exe",
                "-r=BreachDepressionsLeastCost",
                "--dem='" + outFBSCP + "'",
                "--output='" + outFBSCP_BREACH + "'",
                "--radius='50'",
                "--min_dist",
                "--fill",
                "-v"])
subprocess.run(cmd)

# Breach Depressions Fast
outFBSCP_BREACH_BFAST = os.path.join(outdir, "DEM_4_FBSCP_BREACH_BFAST.tif")
cmd = " ".join([wbt_dir + "\\whitebox_tools.exe",
                "-r=BreachDepressions",
                "--dem='" + outFBSCP_BREACH + "'",
                "--output='" + outFBSCP_BREACH_BFAST + "'",
                "--flat_increment='0.0001'",
                "--fill_pits",
                "-v"])
subprocess.run(cmd)

@jfbourdon
Copy link
Contributor

jfbourdon commented Apr 21, 2020

After some more tests, I'm now pretty confident that the issue is with the TIFF writer when the output file exceed 4GB and that WhiteboxTools is forced to write a BigTIFF. As long as a normal TIFF below 4GB is written, there is no shift.

I also tested a BigTIFF below 4GB as input and the output file of WhiteboxTools returned a normal TIFF (also below 4GB) without any shift. So it seems to read BigTIFF just fine.

@jfbourdon
Copy link
Contributor

jfbourdon commented Apr 21, 2020

To make sure, I tried ConvertRasterFormat with a .TIF (BigTIFF) as input and .TIF as output and got the shift to the right (this time a 2 pixel shift). My raster was 65268 columns by 38763 rows Float32. Maybe the shift increased with the width of the raster.

My workaround for now is to use DEP as input/output and then at the end I convert the files I need to FLT and then to GeoTIFF (BigTIFF) with gdal_translate... However, there is a bug in the way the extent is written in DEP that cause an error to the resolution and extent of the FLT in the output (issue #84) that force me to edit the .HDR to modify the YLLCORNER and CELLSIZE to get the real extent and resolution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants