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

Hamish hamish_nospam at yahoo.com
Wed Jun 15 22:09:04 EDT 2005


> 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.



perhaps the resolution is wrong before you run v.to.rast.

r.info V_rast
?


g.region rast=MAP
v.to.rast ...
g.copy V_rast,MASK
g.region rast=V_rast zoom=V_rast
r.mapcalc MAP_crop=MAP
g.remove MASK


Also note v.to.rast only works on features with categories, etc..



Hamish




More information about the grass-user mailing list