[gdal-dev] How to publish null as nodata by gdalwarp?

OHTSUKA Ko-hei kochizufan at gmail.com
Tue Sep 18 13:44:32 PDT 2012


Even,

Very thanks! I could do it.

color-relief's alpha channel masks hillshade's gray sea area, so TMS tiles are
become transparent.

Ko-hei

2012/9/18 Even Rouault <even.rouault at mines-paris.org>:
> Le lundi 17 septembre 2012 07:12:24, OHTSUKA Ko-hei a écrit :
>> Hello,
>>
>> I have a GeoTiff DEM, which is written in WGS84 and describes nodata as
>> null. (No data means sea area.)
>>
>> I want to make shaded-color-relief tiff in spherical mercator from it, so I
>> run:
>>
>> gdalwarp -s_srs EPSG:4326 -t_srs EPSG:3785 -r bilinear wgs_dem.tif
>> merc_dem.tif
>> gdaldem color-relief -alpha -co ALPHA=YES merc_dem.tif
>> ramp.txt merc_rel.tif
>> gdaldem hillshade -compute_edges merc_dem.tif
>> melc_shd.tiff
>> hsv_merge.py merc_rel.tif melc_shd.tiff melc_shdrel.tiff
>>
>> But, result file melc_shdrel.tiff not contains null data.
>> null data are all changed into value 0, so they are not transparent,
>> and colored as ground.
>>
>>
>> I tried several change to command, consequently,
>>
>> gdalwarp -s_srs EPSG:4326 -t_srs EPSG:3785 -srcnodata "" -r bilinear
>> wgs_dem.tif merc_dem.tif
>>
>> This command makes null data not to value 0 but to -9999.
>> "gdaldem color-relief" detect this change and make sea area as transparent.
>> But, "gdaldem hillshade" not detect this, so sea shore shown as huge
>> cliff, and sea area became
>> gray.
>>
>> I tried '--dstnodata' or '-dstalpha' option, but they makes any good
>> change.
>>
>>
>> Is there any ways to get destination data which describes null as
>> nodata in gdalwarp?
>
> Try adding -dstnodata 0 to your gdalwarp commandline.
> The option -srcnodata "" is likely interpreted as equivalent to -srcnodata 0,
> which should not be necessary at all, as gdalwarp will autodetect it
>
>>
>> Or, making "gdaldem hillshade" to detect -9999 as nodata?
>
> In your ramp.txt, make sure that you have a line like :
> "nv 0 0 0 0"
>
> Note: the important 0 is the 4th one, which means that the alpha component for
> the nodata value (nv) will be 0.
>
> A quick review of hsv_merge.py shows that it should preserve the alpha band of
> the colored raster.
>
> But to debug this more easily, make sure to check that the result of each
> intermediate step is OK.
>
>>
>>
>> Regards,
>>
>> OHTSUKA Ko-hei
>> _______________________________________________
>> gdal-dev mailing list
>> gdal-dev at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/gdal-dev


More information about the gdal-dev mailing list