Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have two raster layers.

(A) is state-sized, 30m.

(B) is county-sized, 3m.

I'd like to get a new raster (C) which is the part of (A) which coincides with (B), preferably scaled to the same resolution as (B).

Is there a way to do this from the command line? From Python or C++?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

This is best done with the gdalwarp command-line tool. The functionality also has a GDAL Warp API for C++ and is exposed for Python too (see help(gdal.ReprojectImage) from a Python shell).

For example, using the gdalwarp command-line:

gdalwarp -te xmin ymin xmax ymax -tr 3 3 -r bilinear A_state_30m.tif C_county_3m.tif

where:

  • -te target extents, you need to supply this from your (B) county-sized raster; try using gdalinfo to help determine this extent
  • -tr target resolution, 3 m
  • -r bilinear, a good algorithm for orthophotos and DEMs, but not for others; other algorithms are available
  • A_state_30m.tif, input (A) file
  • C_county_3m.tif, output (C) file
share|improve this answer
    
This worked perfectly, thank you. –  Richard Aug 7 '12 at 20:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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