[GRASS-user] r.to.vect problem

Hi again,

I have a bunch of raster maps that I want to convert to vectors. I
think...

I have 8 raster maps, produced by Maxent. The pixels in the map have
values of 0-100. I want to quantify the area that has pixels with
values > 5, and also the pair-wise overlap between all 8 maps.

I thought it would make sense to convert each map to a shapefile, and
then get the overlap with v.overlay. However, r.to.vect doesn't appear
to allow for selecting a range of values to turn into an area. Is
there a way to do this? If not, is there a better way to approach my
problem?

I did try:

r.to.vect input=aestivalis_model output=aest_shape1 feature=area

but this didn't work well. It looks like I've got one huge area that
covers the entire region, except that it stops after filling in the
top 1/5 of the display.

Thanks.

--
Regards,

Tyler Smith

On Thu, Feb 08, 2007 at 06:50:01PM -0400, Tyler Smith wrote:

I thought it would make sense to convert each map to a shapefile, and
then get the overlap with v.overlay. However, r.to.vect doesn't appear
to allow for selecting a range of values to turn into an area. Is
there a way to do this?

Aha! Since sending this first message I have discovered that my new
favourite function, r.null, can be used to 'NULL'-ify the 0-5 part of my
raster, making the rest available for vectorization. So I've got my
answer, and can continue working toward the ultimate solution.

Sorry for the bother.

--
Regards,

Tyler Smith

Tyler Smith wrote:

On Thu, Feb 08, 2007 at 06:50:01PM -0400, Tyler Smith wrote:
> I thought it would make sense to convert each map to a shapefile,
> and then get the overlap with v.overlay. However, r.to.vect doesn't
> appear to allow for selecting a range of values to turn into an
> area. Is there a way to do this?

Aha! Since sending this first message I have discovered that my new
favourite function, r.null, can be used to 'NULL'-ify the 0-5 part of
my raster, making the rest available for vectorization. So I've got my
answer, and can continue working toward the ultimate solution.

you can also use r.mapcalc to make a MASK map if you don't want to
modify your raster map.

r.mapcalc "MASK = if(oldmap > 5)"

"g.remove MASK" when done.

or,

r.mapcalc "newmap = if(oldmap > 5, oldmap, null() )"
# if( this, then use this, otherwise use this )

rasterintro.html needs something added to it about raster MASKs...

Hamish

Tyler Smith wrote:

I have 8 raster maps, produced by Maxent. The pixels in the map have
values of 0-100. I want to quantify the area that has pixels with
values > 5, and also the pair-wise overlap between all 8 maps.

no need to convert to vector,

g.region rast=map
r.mapcalc "MASK=if(value > 5)"

r.report -n map units=k
  or
r.stats -an map > spreadsheet
  or
r.univar map then multiply "n" by map resolution ^2.

g.remove MASK

and probably a few other ways.

Hamish

On Fri, Feb 09, 2007 at 02:47:25PM +1300, Hamish wrote:

you can also use r.mapcalc to make a MASK map if you don't want to
modify your raster map.

r.mapcalc "MASK = if(oldmap > 5)"

"g.remove MASK" when done.

or,

r.mapcalc "newmap = if(oldmap > 5, oldmap, null() )"
# if( this, then use this, otherwise use this )

Thanks! I stumbled onto r.mapcalc myself, and realized that I wouldn't
need to convert to vectors after all. Which is good, because r.to.vect
takes a long time on my laptop. I used r.mapcalc to produce new
'binary' maps with all values 5 and up switched to 1, everything else
switched to 0, then used r.coin to go through and calculate all the
overlaps. There is probably a better way to transfer the data into R,
but for a single 8x8 matrix this wasn't too bad.

Now I have to figure out what exactly I'm going to do with my
data... Maybe it's just because my previous experience learning R and
Emacs has toughened me up a bit, but I'm finding GRASS is a lot of
fun!

Thanks for your suggestions, it really helps when you're working in
isolation.

--
Regards,

Tyler Smith

Tyler Smith wrote:

On Fri, Feb 09, 2007 at 02:47:25PM +1300, Hamish wrote:
> you can also use r.mapcalc to make a MASK map if you don't want to
> modify your raster map.
>
> r.mapcalc "MASK = if(oldmap > 5)"
>
> "g.remove MASK" when done.
>
> or,
>
> r.mapcalc "newmap = if(oldmap > 5, oldmap, null() )"
> # if( this, then use this, otherwise use this )
>

Thanks! I stumbled onto r.mapcalc myself, and realized that I wouldn't
need to convert to vectors after all. Which is good, because r.to.vect
takes a long time on my laptop. I used r.mapcalc to produce new
'binary' maps with all values 5 and up switched to 1, everything else
switched to 0, then used r.coin to go through and calculate all the
overlaps. There is probably a better way to transfer the data into R,
but for a single 8x8 matrix this wasn't too bad.

Also check out the r.reclass module, it lets you make new "virtual"
raster maps based on the values in another raster map. Might save you
some time & disk space.

Now I have to figure out what exactly I'm going to do with my
data... Maybe it's just because my previous experience learning R and
Emacs has toughened me up a bit, but I'm finding GRASS is a lot of
fun!

In my experience, if someone has lots of experience with either UNIX or
GIS (dating back to ArcInfo) then GRASS is not too hard to learn. If
someone does not know either of those two things, then the learning
curve can be very steep. If someone knows both well, then GRASS is a
breath of fresh air.

Hamish