Closed tobkug closed 3 years ago
Check if no-data is properly defined and masked in your DEMs. The program fails to compute any valid stats (all nans), hence the minimizer/fit program complains. Can use replace_odv.py
I used replace_ndv.py
but the error remains. So the no-data should be properly defined.
Can you paste output of gdalinfo -stats
for both input DEMs? It's possible that one uses nan
as nodata, or that there is a nodata value defined in geotiff header, like 0 or -9999, but there are nan values in the geotiff.
There was a recent commit to replace_ndv.py
to deal with this case (did you pull latest?). We should probably just add a check for nan in iolib
functions in pygeotools, which should fix the issues you're experiencing with dem_align.py
.
after using replace_ndv.py
with -9999 as new nodata value. I pulled the lastet.
Reference Dem:
Driver: GTiff/GeoTIFF
Files: /media/RefDem.tif
Size is 601, 601
Coordinate System is:
PROJCS["WGS_1984_UTM_Zone_18N",
GEOGCS["WGS 84",
DATUM["WGS_1984",
SPHEROID["WGS 84",6378137,298.257223563,
AUTHORITY["EPSG","7030"]],
AUTHORITY["EPSG","6326"]],
PRIMEM["Greenwich",0],
UNIT["degree",0.0174532925199433],
AUTHORITY["EPSG","4326"]],
PROJECTION["Transverse_Mercator"],
PARAMETER["latitude_of_origin",0],
PARAMETER["central_meridian",-75],
PARAMETER["scale_factor",0.9996],
PARAMETER["false_easting",500000],
PARAMETER["false_northing",0],
UNIT["metre",1,
AUTHORITY["EPSG","9001"]],
AUTHORITY["EPSG","32618"]]
Origin = (780121.000000000000000,2053238.000000000000000)
Pixel Size = (1.000000000000000,-1.000000000000000)
Metadata:
AREA_OR_POINT=Area
DataType=Generic
Image Structure Metadata:
COMPRESSION=LZW
INTERLEAVE=BAND
Corner Coordinates:
Upper Left ( 780121.000, 2053238.000) ( 72d20'46.72"W, 18d33' 4.42"N)
Lower Left ( 780121.000, 2052637.000) ( 72d20'47.03"W, 18d32'44.89"N)
Upper Right ( 780722.000, 2053238.000) ( 72d20'26.24"W, 18d33' 4.14"N)
Lower Right ( 780722.000, 2052637.000) ( 72d20'26.55"W, 18d32'44.60"N)
Center ( 780421.500, 2052937.500) ( 72d20'36.63"W, 18d32'54.51"N)
Band 1 Block=128x128 Type=Float32, ColorInterp=Gray
Min=-43.781 Max=7.619
Minimum=-43.781, Maximum=7.619, Mean=-14.493, StdDev=4.976
NoData Value=nan
Metadata:
RepresentationType=ATHEMATIC
STATISTICS_COVARIANCES=24.75758567854982
STATISTICS_MAXIMUM=7.6189703941345
STATISTICS_MEAN=-14.493315708945
STATISTICS_MINIMUM=-43.781005859375
STATISTICS_SKIPFACTORX=1
STATISTICS_SKIPFACTORY=1
STATISTICS_STDDEV=4.9756995165052
Source Dem:
Driver: GTiff/GeoTIFF
Files: SrcDem.tif
Size is 622, 617
Coordinate System is:
PROJCS["WGS 84 / UTM zone 18N",
GEOGCS["WGS 84",
DATUM["WGS_1984",
SPHEROID["WGS 84",6378137,298.257223563,
AUTHORITY["EPSG","7030"]],
AUTHORITY["EPSG","6326"]],
PRIMEM["Greenwich",0,
AUTHORITY["EPSG","8901"]],
UNIT["degree",0.0174532925199433,
AUTHORITY["EPSG","9122"]],
AUTHORITY["EPSG","4326"]],
PROJECTION["Transverse_Mercator"],
PARAMETER["latitude_of_origin",0],
PARAMETER["central_meridian",-75],
PARAMETER["scale_factor",0.9996],
PARAMETER["false_easting",500000],
PARAMETER["false_northing",0],
UNIT["metre",1,
AUTHORITY["EPSG","9001"]],
AXIS["Easting",EAST],
AXIS["Northing",NORTH],
AUTHORITY["EPSG","32618"]]
Origin = (780117.000000000000000,2053254.000000000000000)
Pixel Size = (1.000000000000000,-1.000000000000000)
Metadata:
AREA_OR_POINT=Area
Image Structure Metadata:
COMPRESSION=DEFLATE
INTERLEAVE=BAND
Corner Coordinates:
Upper Left ( 780117.000, 2053254.000) ( 72d20'46.85"W, 18d33' 4.95"N)
Lower Left ( 780117.000, 2052637.000) ( 72d20'47.16"W, 18d32'44.89"N)
Upper Right ( 780739.000, 2053254.000) ( 72d20'25.66"W, 18d33' 4.65"N)
Lower Right ( 780739.000, 2052637.000) ( 72d20'25.97"W, 18d32'44.59"N)
Center ( 780428.000, 2052945.500) ( 72d20'36.41"W, 18d32'54.77"N)
Band 1 Block=256x256 Type=Float32, ColorInterp=Gray
Min=-143.445 Max=104.745
Minimum=-143.445, Maximum=104.745, Mean=-25.119, StdDev=11.048
NoData Value=nan
Metadata:
STATISTICS_MAXIMUM=104.74529266357
STATISTICS_MEAN=-25.119146955916
STATISTICS_MINIMUM=-143.44519042969
STATISTICS_STDDEV=11.047686537924
STATISTICS_VALID_PERCENT=64.11
Hmm.
The above shows you still have nan
as your nodata value in both DEMs. The latest commit on pygeotools
will handle this case and replace with the input value: https://github.com/dshean/pygeotools/commit/9c8d7d5cff5f4fd1c08cf2d46dd1566d229ae9ad
When you run replace_ndv.py
it writes out a new file with *_ndv.tif
appended. That is the file with updated nodata values, not the original. Maybe you can try using those?
ok, embarrassing. I didn't realize that a new tif. file was generated.
Thanks for the help and patience.
OK! Glad to hear we figured this out and you got something to work. The doc is not great, and I've made this same replace_ndv.py
output file mistake myself from time to time. Seemed safer to create a new tif, to avoid risks of making some irreversible change to the original file.
Hi I receive following error. The DEM is without any doubt of very bad quality but I'm interest what causes the error.
`