1

I have two rasters, one for road network and another one for the DEM of the country.

I have to overlay the road network raster on top of DEM raster so as to get the elevation of roads. But my rasters have very different values and warp and resample didn't help.

This is my road network raster

Road network raster

And this is the DEM raster

DEM raster

Any ideas how I can accomplish my goal?

Both the rasters have same projection

'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433],AUTHORITY["EPSG","4326"]]'

GDAL INFO of rasters

Here's the gdalinfo on the rasters :

Road Network Raster:

Driver: GTiff/GeoTIFF

Files: Samoa_reprojected.tif

Size is 1379, 607

Coordinate System is:

GEOGCS["WGS 84",
    DATUM["WGS_1984",
        SPHEROID["WGS 84",6378137,298.257223563,
            AUTHORITY["EPSG","7030"]],
        AUTHORITY["EPSG","6326"]],
    PRIMEM["Greenwich",0],
    UNIT["degree",0.0174532925199433],
    AUTHORITY["EPSG","4326"]]

Origin = (-172.802650000000000,-13.440900899999999)

Pixel Size = (0.001000000000000,-0.001000000000000)

Metadata:

  AREA_OR_POINT=Area
  TIFFTAG_RESOLUTIONUNIT=2 (pixels/inch)
  TIFFTAG_SOFTWARE=WhiteboxTools
  TIFFTAG_XRESOLUTION=72
  TIFFTAG_YRESOLUTION=72

Image Structure Metadata:

  INTERLEAVE=BAND

Corner Coordinates:

Upper Left  (-172.8026500, -13.4409009) (172d48' 9.54"W, 13d26'27.24"S)
Lower Left  (-172.8026500, -14.0479009) (172d48' 9.54"W, 14d 2'52.44"S)
Upper Right (-171.4236500, -13.4409009) (171d25'25.14"W, 13d26'27.24"S)
Lower Right (-171.4236500, -14.0479009) (171d25'25.14"W, 14d 2'52.44"S)
Center      (-172.1131500, -13.7444009) (172d 6'47.34"W, 13d44'39.84"S)

Band 1 Block=1379x1 Type=Float32, ColorInterp=Gray

  NoData Value=-32768 

DEM Raster:

Driver: GTiff/GeoTIFF

Files: SamoaElev_reprojected.tif

Size is 1204, 439

Coordinate System is:

GEOGCS["WGS 84",
    DATUM["WGS_1984",
        SPHEROID["WGS 84",6378137,298.257223563,
            AUTHORITY["EPSG","7030"]],
        AUTHORITY["EPSG","6326"]],
    PRIMEM["Greenwich",0],
    UNIT["degree",0.0174532925199433],
    AUTHORITY["EPSG","4326"]]

Origin = (-173.832990217792712,-13.115807779999948)

Pixel Size = (0.002301515790457,-0.002301515790457)

Metadata:

  AREA_OR_POINT=Area
  TIFFTAG_RESOLUTIONUNIT=2 (pixels/inch)
  TIFFTAG_SOFTWARE=WhiteboxTools
  TIFFTAG_XRESOLUTION=72
  TIFFTAG_YRESOLUTION=72

Image Structure Metadata:

  INTERLEAVE=BAND

Corner Coordinates:

Upper Left  (-173.8329902, -13.1158078) (173d49'58.76"W, 13d 6'56.91"S)
Lower Left  (-173.8329902, -14.1261732) (173d49'58.76"W, 14d 7'34.22"S)
Upper Right (-171.0619652, -13.1158078) (171d 3'43.07"W, 13d 6'56.91"S)
Lower Right (-171.0619652, -14.1261732) (171d 3'43.07"W, 14d 7'34.22"S)
Center      (-172.4474777, -13.6209905) (172d26'50.92"W, 13d37'15.57"S)

Band 1 Block=1204x1 Type=Float32, ColorInterp=Gray

  NoData Value=-32768 
  • You can do it with gdal_calc.py. Can you add the gdalinfo output of your raster files? – Gabriel De Luca Feb 2 at 0:38
  • I've added the gdalinfo to the main thread. Thanks! – gaurav bhardwaj Feb 4 at 16:28
0

You need to warp the DEM raster to the same extent and resolution than the road raster before calculate. Naming the output as B.tif.

gdalwarp -te -172.8026500 -14.0479009 -171.4236500 -13.4409009 -tr 0.001 0.001 -r bilinear SamoaElev_reprojected.tif B.tif

Then you can calculate: if in the road raster there is a value not equal to the nodata value, returns 1 and multiply by the new B.tif raster. Naming the output as C.tif

gdal_calc.py --calc=(A!=-32768)*B --outfile=C.tif -A Samoa_reprojected.tif --A_band=1 -B B.tif --B_band=1

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.