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.

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

share|improve this question
    
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 Mar 8 '11 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 Mar 8 '11 at 17:42
add comment

1 Answer

up vote 2 down vote accepted

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.

share|improve this answer
    
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 Mar 9 '11 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 Mar 9 '11 at 17:35
    
It worked. Thanks! –  teamAngat Mar 10 '11 at 16:30
    
Nice, I'am editing the answer with that information. –  Pablo Mar 10 '11 at 17:29
add comment

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.