stac-utils / stac-layer

Visualize a STAC Item or Collection on a Leaflet Map
Creative Commons Zero v1.0 Universal
48 stars 11 forks source link

Geotiff visualization creates strange artifacts and does not handle correctly NaN #70

Open sylar11 opened 11 months ago

sylar11 commented 11 months ago

Hi, I created a series of collections where it is possible to visualise the geotiff but I'm experiencing strange behaviour in certain cases.

If you look here, for example, you can find a geotiff that is correctly displayed. This geotiff has -999 as no data.

In other cases, my geotiff has NaN as no data value. In this case, the geotiff creates the artefacts as in this example

I tried using gdal to substitute the NaN with -999 with this command:

gdal_calc.py -A $tiff --outfile=$output_folder$output_tif_nan --calc="A*(A>0)" --NoDataValue=-999 --overwrite

and with gdalinfo it results that the image has -999 as no data but if I try using this new image it results in a black image like here

What is strange is that if I open the image with QGIS it is clear and the values are correct.

Could you please tell me if I'm doing something wrong or if it is a possible bug in the browser?

The images are all stored in an Amazon S3 bucket

sylar11 commented 11 months ago

Hi @DanielJDufour please find here the result of the gdalinfo cmd

gdalinfo /mnt/CEPH_PROJECTS/4DMED/sen_et/4DMED_TIFs/upload_setnull_to_S3/test/Subset_SenET_Ebro_20210904.tif Driver: GTiff/GeoTIFF Files: /mnt/CEPH_PROJECTS/4DMED/sen_et/4DMED_TIFs/upload_setnull_to_S3/test/Subset_SenET_Ebro_20210904.tif /mnt/CEPH_PROJECTS/4DMED/sen_et/4DMED_TIFs/upload_setnull_to_S3/test/Subset_SenET_Ebro_20210904.tif.aux.xml Size is 8333, 4131 Coordinate System is: GEOGCRS["WGS 84", DATUM["World Geodetic System 1984", ELLIPSOID["WGS 84",6378137,298.257223563, LENGTHUNIT["metre",1]]], PRIMEM["Greenwich",0, ANGLEUNIT["degree",0.0174532925199433]], CS[ellipsoidal,2], AXIS["geodetic latitude (Lat)",north, ORDER[1], ANGLEUNIT["degree",0.0174532925199433]], AXIS["geodetic longitude (Lon)",east, ORDER[2], ANGLEUNIT["degree",0.0174532925199433]], ID["EPSG",4326]] Data axis to CRS axis mapping: 2,1 Origin = (-5.467733333000001,43.353633332999998) Pixel Size = (0.000900000000001,-0.000900000000000) Metadata: AREA_OR_POINT=Area Image Structure Metadata: INTERLEAVE=BAND Corner Coordinates: Upper Left ( -5.4677333, 43.3536333) ( 5d28' 3.84"W, 43d21'13.08"N) Lower Left ( -5.4677333, 39.6357333) ( 5d28' 3.84"W, 39d38' 8.64"N) Upper Right ( 2.0319667, 43.3536333) ( 2d 1'55.08"E, 43d21'13.08"N) Lower Right ( 2.0319667, 39.6357333) ( 2d 1'55.08"E, 39d38' 8.64"N) Center ( -1.7178833, 41.4946833) ( 1d43' 4.38"W, 41d29'40.86"N) Band 1 Block=8333x1 Type=Float32, ColorInterp=Gray Min=-0.000 Max=14.271 Minimum=-0.000, Maximum=14.271, Mean=3.578, StdDev=0.986 NoData Value=-999 Metadata: STATISTICS_APPROXIMATE=YES STATISTICS_MAXIMUM=14.271381378174 STATISTICS_MEAN=3.5783093426146 STATISTICS_MINIMUM=-0 STATISTICS_STDDEV=0.98571644098685 STATISTICS_VALID_PERCENT=32.61

thanks

m-mohr commented 11 months ago

@sylar11 Did you check whether the latest version on the main branch handles your files correctly? If not, please try that first.