[GRASS-user] Re: how to get raster region corresponding to vector
polygon region?
Hamish
hamish_b at yahoo.com
Thu Jun 17 22:52:35 EDT 2010
Marcello wrote:
> There is probably a better way to do that (and I would like to
> "hear" it very much, specially if there is a single command
> to do this), but for now, I think the code below does the job:
>
> g.region vect=your_vector
> v.extract input=your_vector output=selected_polygon type=area
> where="cat=desired_cat"
> v.to.rast input=selected_polygon output=polygon_rasterized use=val type=area
> r.mask input=polygon_rasterized
another way (probably there are many),
v.to.rast
then a loop using r.reclass to make a temporary MASK map of each
category, then
g.region rast=rasterized_vect
g.region zoom=rasterized_vect
r.reclass are tiny virtual maps (ie very quick to create+remove),
g.region zoom= starts at the current region and shrinks inward
until it hits a non-NULL cell.
Hamish
More information about the grass-user
mailing list