mapbox / rio-rgbify

Encoded arbitrary bit depth rasters in pseudo base-256
MIT License
99 stars 36 forks source link

Support of DTED and SRTM #13

Open raggnic opened 6 years ago

raggnic commented 6 years ago

Hello

Are DTED format or SRTM Supported?

With a DTED I run the following command rio rgbify -b 10000 -i 0.1 N43.dt0 n43.rgb.tif and I get the following message : rasterio._err.CPLE_NotSupportedError: DTED driver only uses the first band of the dataset

With a SRTM downloaded from http://dwtkns.com/srtm/ i run the same command rio rgbify -b 10000 -i 0.1 srtm_38_04.tif srtm_38_04_rgb.tif and I get this message Given nodata value, -32768.0, is beyond the valid range of its data type, <class 'numpy.uint8'>.

I may be doing something wrong somewhere but so far i've not seen where... Regards

raggnic commented 6 years ago

Ok never mind, I was able to change the nodata value using gdal

dnomadb commented 6 years ago

@raggnic thanks for the ticket! This is happening because while we are updating the output data type, I neglected to also update the nodata value: https://github.com/mapbox/rio-rgbify/blob/master/rio_rgbify/scripts/cli.py#L46

The fix to avoid this would be straightforward (just update the destination profile with a nodata of None). I am not sure that this fixes the underlying problem, however, which is -- how do you support transparency with this encoding?

Side note: any specific reason you are outputting to a tif instead of an mbtiles? I mention this because almost any usage (tiling or otherwise) could introduce artifacts due to resampling that would break the encoding.

raggnic commented 6 years ago

It's fine, i don't need transparency currently, but yes, it should be possible to have nodata areas. I've seen Dted with no data areas. I'm tried mbtiles format, but when I run the command nothing happens, Python keeps forking new process but CPU is at 5% and the output does not grow for hours. I'm on windows.

Besides this format is useful to be able to serve the result through tms. So far I've not seen artefacts on tile borders

dnomadb commented 6 years ago

should be possible to have nodata areas

Yes, agree, I am just not sure how to implement it with 8 bit rgb encoding without using a possibly valid data value (0 0 0); the best solution might be to add an alpha band.

So far I've not seen artefacts

Excellent -- you wouldn't see them on borders, youd see them in the encoding. The problem is that a slope proceeds, the B (for example) band goes from 0, 1, ... 256, then back to 0, 1; is any resampling is performed in between subsequent pixels, it will add artifacts between 255 and 0 (unless using nearest neighbor resampling).

That said, it shouldn't take hours (minutes if that), I'll take a look at an SRTM from above. Do you have the exact command you are using?

ThomasHalwax commented 4 years ago

I'm tried mbtiles format, but when I run the command nothing happens, Python keeps forking new process but CPU is at 5% and the output does not grow for hours. I'm on windows.

This is still an issue. I am running rasterio inside a docker container with Ubuntu 18 and Python 3.