I want to convert the elevation of a GeoTIFF from meter to the feet, so I can create a contour in feet. I've used gdal_translate:

gdal_translate -scale 0 0.3048 0 1 inputmeters.tif outputfeet.tif

but when I create a contour, both are identical. and with the gdal_info I don't see any changes in the metadata. I'm not sure if the gdal_translate is the command that I need!

It is necessary for me somehow to check if the outputfeet.tif unit type is feet.

  • Scale in gdal_translate is doing totally different scaling. Re-read gdal.org/gdal_translate.html. – user30184 Oct 27 '17 at 16:33
  • 2
    @user30184 Based on the name, it certainly looks like the right thing. However, it’s written as if your goal is something like re-scaling a band to use the full scale (e.g. expand it to use 0 to 255). You have to provide the min and max for input and output. When you look at the code, you realize it is using that to compute a scale and offset, which is just what you’d need to convert. – GeoCom Oct 27 '17 at 16:36
  • 1
    You are right, it can be used for scaling from meters to feet if user gives reasonable parameters. For unit conversions offset must not happen. I am not sure if user must explicitly check the upper limit of the source value range. – user30184 Oct 27 '17 at 18:07
  • @user30184, honestly I cannot trust on gdal_translate for my purpose, but also I got the problem from the answer(gdal_calc), please see EDIT 1 in question. – GeoCom Oct 27 '17 at 22:27
  • 1
    Sorry, I thought that you had a better idea about what you are doing. You can't create contours from the satellite mosaic product. Heights are in the SRTM DEM data. Satellite image have Red, Green, and Blue channels and you can show the image in color monitor but none of the channels contain height data. – user30184 Oct 28 '17 at 10:27

Try with gdal_calc:

gdal_calc -A inputmeters.tif --outfile=outputfeet.tif --calc="A/0.3048"

I think could be more precise for your purposes. But, CRS is in feet or meters? Maybe a two-step process with gdalwarp and gdal_calc

  • CRS is in meter (the original data is in meter). What could be these process? why gdalwarp and why gdal_calc? – GeoCom Oct 27 '17 at 16:30
  • Meters are longer than feet so you probably want to divide, not multiply with 0.3048. – user30184 Oct 27 '17 at 16:31
  • @aldo_tapia you mean with these two processes I can completely convert and store the geotiff from the meter to the feet? – GeoCom Oct 27 '17 at 16:31
  • 1
    It should be enough to make the conversion of heights into feet with gdal_calc and then continue with gdal_contour. – user30184 Oct 27 '17 at 16:35
  • 1
    Open the image with QGIS and click with the identify tool in some place for checking the pixel value. – user30184 Oct 27 '17 at 16:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.