0

I've been trying to use gdalwarp with the -tr and -te parameters to apply a scale factor to 'stretch' a raster. The result is a raster with correct extents and pixel size, but no RGB data. I've also added parameters for -of Gtiff and -ot in various combination to support Byte and Float values. Color me stuck!

gdalwarp $input_raster $scaled_raster -te $scaled_x_ll $scaled_y_ll $scaled_x_ur $scaled_y_ur -tr $scaled_px_x $scaled_px_y -s_srs EPSG:6428 -t_srs EPSG:6428
3
  • 1
    Do you mean that you want kind of falsify the source data by putting it into another place and pixels stretched? Is the original georeferencing wrong?
    – user30184
    Commented Mar 30 at 16:29
  • Basically yes. Georeferencibg is correct in state plane, I am trying to scale to ground based coordinates with a modified state plane approach. In a second step I truncate the millions to get to friendly coordinates that can be transformed back to grid if needed.
    – Summitbri
    Commented Mar 30 at 16:48
  • I don't understand why you want to do that, but perhaps you could use world files for georeferencing and change the coordinates of the origin and pixel size terms with some script. GDAL does not support that kind of "scaling". In a special case you could define a custom projection that is using kilometre as unit instead of metre. And with gdal_translate it is possible to define the upper left-lower right coordinates gdal.org/programs/…. See also gdal.org/programs/….
    – user30184
    Commented Apr 1 at 11:34

1 Answer 1

0

One thing you could try is using gdaldem and color-relief option with your own colorscale in a CSV file after you warp the raster. From GDAL docs:

gdaldem color-relief <input_dem> <color_text_file> <output_color_relief_map>
             [-alpha] [-exact_color_entry | -nearest_color_entry]
             [-b <band>] [-of format] [-co <NAME>=<VALUE>]... [-q]

where color_text_file contains lines of the format "elevation_value red green blue"

The elevation_value can actually be whatever scalar value you want. You just have to provide the color scale file.

There are also a few color options through gdal_translate as well as using the GDAL python script pct2rgb.py. But I found using gdaldem to be the easiest and straightforward to color an image.

1
  • I am actually trying to scale the pixel size and extents, not the raster value. Also right now I am focused on an orthophoto.
    – Summitbri
    Commented Mar 30 at 22:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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