|
Hi Marcello, Thanks for this response! After my post I also figured out exactly this method for doing it as well, although as you say would be great to have a one-liner. I will probably just write a little script that performs all these steps and takes in the relevant vector, cat, and raster values. thanks! ken On 06/17/2010 04:17 PM, Marcello Gorini wrote: Kwas wrote:Hello, I have a raster map (dem) and I want to select a region of the raster corresponding to a polygon that is in a vector map. What is the best way to do this? It looks like r.in.poly might be along the lines of what I need but in that case I think I would need to generate the ascii poly file first but I'm wondering if there is a better way? Seems like there should be a single command to do this. My vector map has 45 polygons with cat values 1..45, so I would like to get a section from my raster map corresponding to one of the polygons specified by cat value. appreciate any help! thanks, ken _______________________________________________ grass-user mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/grass-userHello Ken, I am also new to GRASS, but I have been doing what you want quite a lot these days. 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 Now, any processing that you do will be applied only in the region corresponding to the selected polygon. If you want to create a raster corresponding to the selected polygon, just do: r.mapcalc "new_raster=any_old_raster" To take out the mask, just type: r.mask -r Hope this helps, Marcello. |
_______________________________________________ grass-user mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/grass-user
