[GRASS-user] calculating perimeter per patch

Dear all,

I have a raster map where each patch (i.e. forest fragment) have different ID.
I need to estimate the perimeter per patch, but R.le.patch can’t do the job.

GRASS 6.4> r.le.patch map=fragments sam=w per=p1 siz=s1 out=STATS.txt

PARAMETER CHOICES:
MAP: fragments
SAMPLE: whole map TRACING: 8 neighbor
SIZE MEASURES:
mean patch size
PERIMETER MEASURES:
sum of perims

R.LE.PATCH IS WORKING…;

ERROR: G_calloc: unable to allocate 24806 * 8 bytes at alloc_cell.c:83

Any hint?

bests

milton

On Sat, Feb 12, 2011 at 5:11 AM, Milton Cezar Ribeiro
<miltinho.astronauta@gmail.com> wrote:

Dear all,

I have a raster map where each patch (i.e. forest fragment) have different
ID.
I need to estimate the perimeter per patch, but R.le.patch can't do the job.

Have you tried a vector approach? Then the perimeter can be simply uploaded with
v.to.db option=perimeter.

(Watch out for the fractal problem, both r.le.patch and v.to.db)

Markus M

------------
GRASS 6.4> r.le.patch map=fragments sam=w per=p1 siz=s1 out=STATS.txt

PARAMETER CHOICES:
MAP: fragments
SAMPLE: whole map TRACING: 8 neighbor
SIZE MEASURES:
mean patch size
PERIMETER MEASURES:
sum of perims

R.LE.PATCH IS WORKING....;

ERROR: G_calloc: unable to allocate 24806 * 8 bytes at alloc_cell.c:83
------------

Any hint?

bests

milton

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

Hi Markus,

Thanks for the reply. In fact a vector-based should solve this.
But, unfortulatelly, as I am working with a very large raster map
(48,000 x 60,000 pixels; 250,000 clumps), and GRASS fail when
I try r.to.vect under Windows/Vista. Is there any other options
of convert large raster maps to vector, instead of r.to.vect?

cheers
milton

2011/2/12 Markus Metz <markus.metz.giswork@googlemail.com>

On Sat, Feb 12, 2011 at 5:11 AM, Milton Cezar Ribeiro
<miltinho.astronauta@gmail.com> wrote:

Dear all,

I have a raster map where each patch (i.e. forest fragment) have different
ID.
I need to estimate the perimeter per patch, but R.le.patch can’t do the job.

Have you tried a vector approach? Then the perimeter can be simply uploaded with
v.to.db option=perimeter.

(Watch out for the fractal problem, both r.le.patch and v.to.db)

Markus M


GRASS 6.4> r.le.patch map=fragments sam=w per=p1 siz=s1 out=STATS.txt

PARAMETER CHOICES:
MAP: fragments
SAMPLE: whole map TRACING: 8 neighbor
SIZE MEASURES:
mean patch size
PERIMETER MEASURES:
sum of perims

R.LE.PATCH IS WORKING…;

ERROR: G_calloc: unable to allocate 24806 * 8 bytes at alloc_cell.c:83

Any hint?

bests

milton


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

On Sat, Feb 12, 2011 at 11:58 AM, Milton Cezar Ribeiro
<miltinho.astronauta@gmail.com> wrote:

Hi Markus,

Thanks for the reply. In fact a vector-based should solve this.
But, unfortulatelly, as I am working with a very large raster map
(48,000 x 60,000 pixels; 250,000 clumps), and GRASS fail when
I try r.to.vect under Windows/Vista. Is there any other options
of convert large raster maps to vector, instead of r.to.vect?

No, but you could try a recent version of GRASS 7 and after starting
GRASS, set at the commandline

export GRASS_VECTOR_LOWMEM=1

then try r.to.vect

It will take some time, but it should finish eventually.

Markus M

Markus Metz:

Milton Cezar Ribeiro:
> Dear all,
>
> I have a raster map where each patch (i.e. forest fragment) have
> different
> ID.
> I need to estimate the perimeter per patch, but R.le.patch can't do the
> job.

Have you tried a vector approach? Then the perimeter can be simply
uploaded with
v.to.db option=perimeter.

(Watch out for the fractal problem, both r.le.patch and v.to.db)

Markus M

> ------------
> GRASS 6.4> r.le.patch map=fragments sam=w per=p1 siz=s1 out=STATS.txt
>
> PARAMETER CHOICES:
> MAP: fragments
> SAMPLE: whole map TRACING: 8 neighbor
> SIZE MEASURES:
> mean patch size
> PERIMETER MEASURES:
> sum of perims
>
> R.LE.PATCH IS WORKING....;
>
> ERROR: G_calloc: unable to allocate 24806 * 8 bytes at alloc_cell.c:83
> ------------
>
> Any hint?
>
> bests
>
> milton
>
> _______________________________________________
> grass-user mailing list
> grass-user@lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-user
>
>

Hi Markus,

I will try that. The GRASS_VECTOR_LOWMEM=1 works only for G7?

best

milton

2011/2/12 Markus Metz <markus.metz.giswork@googlemail.com>

On Sat, Feb 12, 2011 at 11:58 AM, Milton Cezar Ribeiro

<miltinho.astronauta@gmail.com> wrote:

Hi Markus,

Thanks for the reply. In fact a vector-based should solve this.
But, unfortulatelly, as I am working with a very large raster map
(48,000 x 60,000 pixels; 250,000 clumps), and GRASS fail when
I try r.to.vect under Windows/Vista. Is there any other options
of convert large raster maps to vector, instead of r.to.vect?

No, but you could try a recent version of GRASS 7 and after starting
GRASS, set at the commandline

export GRASS_VECTOR_LOWMEM=1

then try r.to.vect

It will take some time, but it should finish eventually.

Markus M

Markus Metz:

Milton Cezar Ribeiro:

Dear all,

I have a raster map where each patch (i.e. forest fragment) have
different
ID.
I need to estimate the perimeter per patch, but R.le.patch can’t do the
job.

Have you tried a vector approach? Then the perimeter can be simply
uploaded with
v.to.db option=perimeter.

(Watch out for the fractal problem, both r.le.patch and v.to.db)

Markus M


GRASS 6.4> r.le.patch map=fragments sam=w per=p1 siz=s1 out=STATS.txt

PARAMETER CHOICES:
MAP: fragments
SAMPLE: whole map TRACING: 8 neighbor
SIZE MEASURES:
mean patch size
PERIMETER MEASURES:
sum of perims

R.LE.PATCH IS WORKING…;

ERROR: G_calloc: unable to allocate 24806 * 8 bytes at alloc_cell.c:83

Any hint?

bests

milton


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

Milton Cezar Ribeiro:

Hi Markus,

I will try that. The GRASS_VECTOR_LOWMEM=1 works only for G7?

Yes, only for G7. Also Large File Support for wingrass is only available in G7.

Markus Metz:

On Sat, Feb 12, 2011 at 11:58 AM, Milton Cezar Ribeiro
<miltinho.astronauta@gmail.com> wrote:
> Hi Markus,
>
> Thanks for the reply. In fact a vector-based should solve this.
> But, unfortulatelly, as I am working with a very large raster map
> (48,000 x 60,000 pixels; 250,000 clumps), and GRASS fail when
> I try r.to.vect under Windows/Vista. Is there any other options
> of convert large raster maps to vector, instead of r.to.vect?
>
No, but you could try a recent version of GRASS 7 and after starting
GRASS, set at the commandline

export GRASS_VECTOR_LOWMEM=1

then try r.to.vect

It will take some time, but it should finish eventually.

Markus M

>
> Markus Metz:
>>
>> Milton Cezar Ribeiro:
>> > Dear all,
>> >
>> > I have a raster map where each patch (i.e. forest fragment) have
>> > different
>> > ID.
>> > I need to estimate the perimeter per patch, but R.le.patch can't do
>> > the
>> > job.
>>
>> Have you tried a vector approach? Then the perimeter can be simply
>> uploaded with
>> v.to.db option=perimeter.
>>
>> (Watch out for the fractal problem, both r.le.patch and v.to.db)
>>
>> Markus M
>>
>> > ------------
>> > GRASS 6.4> r.le.patch map=fragments sam=w per=p1 siz=s1 out=STATS.txt
>> >
>> > PARAMETER CHOICES:
>> > MAP: fragments
>> > SAMPLE: whole map TRACING: 8 neighbor
>> > SIZE MEASURES:
>> > mean patch size
>> > PERIMETER MEASURES:
>> > sum of perims
>> >
>> > R.LE.PATCH IS WORKING....;
>> >
>> > ERROR: G_calloc: unable to allocate 24806 * 8 bytes at
>> > alloc_cell.c:83
>> > ------------
>> >
>> > Any hint?
>> >
>> > bests
>> >
>> > milton
>> >
>> > _______________________________________________
>> > grass-user mailing list
>> > grass-user@lists.osgeo.org
>> > http://lists.osgeo.org/mailman/listinfo/grass-user
>> >
>> >
>
>

Milton:

But, unfortulatelly, as I am working with a very large raster
map (48,000 x 60,000 pixels; 250,000 clumps), and GRASS fail
when I try r.to.vect under Windows/Vista.

...

I will try that. The GRASS_VECTOR_LOWMEM=1 works only
for G7?

Markus Metz wrote:

Yes, only for G7. Also Large File Support for wingrass is
only available in G7.

for what it's worth, the problem here is most likely to be
trying to work with large rasters in Windows, not large vectors.
So GRASS_VECTOR_LOWMEM=1 is probably not needed, but the large
file support in GRASS 7.svn is.

i.e. the same command will probably work on a Mac or Linux using
GRASS 6.4, but if it were truly a large vector file problem and
not a large raster one it would require GRASS 7.svn on all
platforms.

(and LFS vector maps are a helluva lot of data if you consider
how much more efficient vector data is than raster [in general]
...)

mostly I just mean to make sure the right problem gets blamed. :slight_smile:

also of course you'll need 64bit Vista or Windows7 to get access
to all the RAM you need.

dev note: we need to figure out the sqlite DB file-per-mapset or
file-per-map (like dbf) before we go much further. file-per-
mapset hits filesystem/sqlite library limits & problems much
sooner than per-map, although that's just mitigating the problem
of large-files, not solving it. also per-map is a bit less
damaging if the DB file gets corrupted.

Hamish

ps- oblig comment on perimeters: it's a fractal problem and so
has no real answer. It's only useful to consider as compared
as a ratio to values from the same dataset, and only then if you
can guarantee that the data is consistently measured/created
across the entire map; which is very hard to do. search for the
"length of UK coastline" on wikipedia for reasons. I'd argue we
should consider removing any option which reports perimeter as a
favour to our users, rather than knowingly giving them dubious,
albeit popular, metrics which can, in the long run, only act to
harm their results and mislead their understanding of the data.
or at minimum add a WARNING: perimeter is a garbage metric when
used outside of pure mathematics, use at your own risk.