4

I have gone through similar questions to mine here, but I didn't find a solution. Please help!

When cropping a raster image by using g.region & r.mapcalc, I get a new image but the resulting image doesn't have the same resolution. I have used r.resample in the outer raster map but is still different. I have tried to change the resolution using g.region, and even though the resolution is the same, the image display is not.

Is there a way in grass to cut an image from the main raster image and keep the resolution unchanged?

Also, I have tried using zoom to choose the crop area and its works! but as I have to do the same with a lot of images and need to be precise (when zooming), so it is difficult and takes a lot of time.

How could I solve this? Many thanks!

  • That's very unlikely. each mapset has a fixed resolution based on g.region. Im sorry for questing you bad have you checked the resulting image's resolution with r.info just to be sure? – nickves Jul 8 '13 at 9:36
  • Thanks for your comment. I'm re-checking the procedure I was following... – Lbx Jul 8 '13 at 13:24
  • Please also see grasswiki.osgeo.org/wiki/Computational_region – markusN Jul 8 '13 at 23:32
  • Ok. I'm doing right with resolution now. Maybe I was not following the instruction in the right order before. – Lbx Jul 12 '13 at 22:04
3

You might need simply g.region twice, first to set the resolution to the same as the original raster, and a second time to change the extents, so:

g.region rast=<original_raster>
g.region e=... w=... n=... s=...
r.mapcalc clipped_rast=original_rast

You can also permanently set the MAPSET region with g.region -s res=... e=... w=...

  • Thanks for clarifying. Takes me a while to conceptualize the concepts. So far everything is working following the steps here. – Lbx Jul 12 '13 at 22:09
0

Another way to crop a raster is to create a mask for the area you want to extract, either from a raster of from a vector and then (with the mask raster present) run:

mapcalc "mImage_Croped = mImage"

  • Thanks. I 'm comparing the result of cropping by creating a mask and using g.region. I think with the last one I would use less memory as have to work with severals images. – Lbx Jul 12 '13 at 22:13

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.