[GRASSLIST:7172] Re: crop of raster - once again

Axel Orth axel_orth at gmx.de
Wed Jun 15 14:45:02 EDT 2005

Ian MacMillan schrieb:

> Axel, you might try
> r.mapcalc MASK='if(V_rast=0, null(), 1)'
> I am not sure if this will work, but it is worth a try.
> G'luck,
> -Ian
> On Jun 15, 2005, at 6:57 AM, Axel Orth wrote:
>> Hey,
>> I had some success with cropping my raster maps with borders of 
>> municipalities (available as vector - converted to raster) and 
>> thought I figured out how it works.
>> But now I try do do the same with some other data and strange things 
>> happen:
>> import raster map "MAP" - import vector "V" - do raster conversation 
>> with vector and get the raster map "V_rast"
>> set the region: g.region rast=V_rast zoom=V_rast
>> create the mask: g.copy V_rast,MASK
>> create new map based on the existing map while only the area of the 
>> mask is taken into consideration: r.mapcalc MAP_crop=MAP
>> Problem: the resulting map MAP_crop is just a colored rectangle - the 
>> size of the rectangle is equal to the bounding box of V_rast
>> By chance I made some errors and somehow got the result i wanted:
>> instead of the r.mapcalc command shown above I did:
>> r.mapcalc
>> MAP_crop=MAP end -> syntax error
>> r.mapcalc MAP_crop=MAP
>> MAP looks now exactly the way I wanted. When I leave GRASS, start 
>> again then MAP looks like I had when imported it.
>> I have no clue what's this is all about and hope someone has a idea.
>> Regards
>> Axel
Hey Ian,
thank you for the suggestion.
I used that command between g.copy V_rast,MASK and r.mapcalc 
MAP_crop=MAP but that did not change anything.
Have I been supposed to use it that way? I don't work much with GRASS 
but the command looks like it is about making sure that just pixel that 
contain information are taken to create the mask. Is that right?

As it did not work out I looked at the MASK after your command and it 
looked like this: see mask_2.gif - the result of r.mapcalc MAP_crop=MAP 
looks also that way. Without your command, the MASK looks like: mask.gif 
- this it the way the mask has to look. This outline should become the 
new border for the cropped map.

I hope the pictures make things a little easier to understand.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: mask_2.gif
Type: image/gif
Size: 1154 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/grass-user/attachments/20050615/3f7a0f41/mask_2.gif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mask.gif
Type: image/gif
Size: 2396 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/grass-user/attachments/20050615/3f7a0f41/mask.gif

More information about the grass-user mailing list