3

When I run r.resample to crop a map by using a vector and a mask, the resulting map has the same shape as the vector that I used but does not replicate (exactly) the portion of the raster map that I used as input in the r.resample. It produced a map with altered elevation values that is different from the raster map I used as input. I read that r.resample just "crops" the raster that is its input and does not alter it. I do not know why r.resample alters the output map

2
  • This question (although it doesn't seem to) actually asks the same thing as the answered one at gis.stackexchange.com/q/6736/664 . The answer is to avoid resampling by making sure the output and input grids are precisely registered.
    – whuber
    Commented Mar 8, 2011 at 17:27
  • How can it be done in GRASS? r.resample just crops a given input map and produces a new map containing the selection of the mask. I cannot see how to make sure that the output and input grids are precisely registered
    – teamAngat
    Commented Mar 8, 2011 at 17:42

1 Answer 1

2

You can change the region resolution with g.region rast=inputmap so the region will have the same resolution as inputmap. Then r.resample will output a map with that resolution. If that does not work you can try r.mapcalc outputmap=inputmap instead of r.resample.
After that copy the colortable from one map to another: r.colors map=croppedmap rast=originalmap.

3
  • I tried changing the region and setting it with the inputmap.I also tried using r.mapcalc. Both still produced a map with altered values. I noticed that it had altered values because the colors in the output raster map are different from the inputmap.
    – teamAngat
    Commented Mar 9, 2011 at 14:37
  • 1
    ok, maybe that's a problem with the colortable, try to copy the colortable from one map to another and see if it works: r.colors map=croppedmap rast=originalmap
    – Pablo
    Commented Mar 9, 2011 at 17:35
  • Nice, I'am editing the answer with that information.
    – Pablo
    Commented Mar 10, 2011 at 17:29

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.