[GRASS-user] Limit d.raster with vector map

Is there a way to limit the displayed raster with a vector map? E.g. I have a rather large raster and I only want to display the values that are inside a vector area. I don't see how this could be done in a simple way, but I am thinking it should :slight_smile: and hopefully there is something I am not seeing or I have done some bad research.

Please help.

Martin

I would do the following, assuming you've got an area vector that's covering
the raster data you want to show:

1. Convert the vector to a raster with r.to.vect
2. Reclassify it so that it's got only two values: 1 and NoData.
3. Multiply the reclassified raster with the raster data that you want to
limit to the area of the vector. The old values will be preserved in the
resulting map because x * 1 = x, but everything that's not collocated with
the vector map will be removed because it's multiplied with NoData.

--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Limit-d-raster-with-vector-map-tp6533406p6533536.html
Sent from the Grass - Users mailing list archive at Nabble.com.

I would do what Daniel said, but use the raster (use command v.to.rast) as a mask (use command r.mask) to limit the displayed area to the vector map area.

On Thu, Jun 30, 2011 at 9:40 PM, Daniel Lee <Lee@isi-solutions.org> wrote:

I would do the following, assuming you’ve got an area vector that’s covering
the raster data you want to show:

  1. Convert the vector to a raster with r.to.vect
  2. Reclassify it so that it’s got only two values: 1 and NoData.
  3. Multiply the reclassified raster with the raster data that you want to
    limit to the area of the vector. The old values will be preserved in the
    resulting map because x * 1 = x, but everything that’s not collocated with
    the vector map will be removed because it’s multiplied with NoData.

–
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Limit-d-raster-with-vector-map-tp6533406p6533536.html
Sent from the Grass - Users mailing list archive at Nabble.com.


grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Thanks!

I also got an answer from Sylvain (see under). I tested both methods, but the best (and safest) is v.to.rast and r.mask. Worked nicely!
I was kind of hoping that was a function for this…well it is not to hard to do when scripting.

Thanks.

Martin

hi,

2 ways to do that:

  • set the region extents to match the vector map (g.region vect=your_vector)
  • transform the vector into raster (v.to.rast), then use this new raster as a mask

Sylvain


Fra: grass-user-bounces@lists.osgeo.org [mailto:grass-user-bounces@lists.osgeo.org] PĂĄ vegne av Nick Jachowski
Sendt: 30. juni 2011 18:37
Til: Daniel Lee
Kopi: grass-user@lists.osgeo.org
Emne: Re: [GRASS-user] Re: Limit d.raster with vector map

I would do what Daniel said, but use the raster (use command v.to.rast) as a mask (use command r.mask) to limit the displayed area to the vector map area.

On Thu, Jun 30, 2011 at 9:40 PM, Daniel Lee <Lee@isi-solutions.org> wrote:

I would do the following, assuming you’ve got an area vector that’s covering
the raster data you want to show:

  1. Convert the vector to a raster with r.to.vect
  2. Reclassify it so that it’s got only two values: 1 and NoData.
  3. Multiply the reclassified raster with the raster data that you want to
    limit to the area of the vector. The old values will be preserved in the
    resulting map because x * 1 = x, but everything that’s not collocated with
    the vector map will be removed because it’s multiplied with NoData.

–
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Limit-d-raster-with-vector-map-tp6533406p6533536.html
Sent from the Grass - Users mailing list archive at Nabble.com.


grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user