[GRASS-user] buffer vector within a given area

Hi

I have a question which is a bit complex. Hope i can describe it ;-).

I have a point-vector layer (the citis) and a raster layer with 1 and
ZERO cells (The potenial agricultural land). One categorie in the vector
layer is the land (Squaremeter) that hast to be cultivated for each
point (city). The question is now: How can I calculate and display,
which cells of the raster map (potential agricultural land) hast to be
cultivated? Must be some sort of buffer or neighbourhood.....?

Thanks for any help!

Martin

In german / auf Deutsch:

Ich habe ein Punkt-Vector Layer (Die Städte) und ein Raster Layer,
welches das potentielle landwirtschaftlich bewirtschaftbare Land
darstellt (1 oder NULL). Nun ist im Punkte-vector Layer eine Kategorie,
welche angibt, wie viel Land (Quadratmeter) um diese Städte herum
bewirtschaftet werden. Die Frage ist nun: Wie kann ich dieses Land
darstellen? Müsste irgend eine Art Buffer oder Neighbourhood-Funktion
sein..... (Bin mir da aber nicht sicher)?

Vielen Dank für jede Hilfe!

Martin

On 22/04/09 20:39, Martin Schweizer wrote:

Hi

I have a question which is a bit complex. Hope i can describe it ;-).

I have a point-vector layer (the citis) and a raster layer with 1 and
ZERO cells (The potenial agricultural land). One categorie in the vector
layer is the land (Squaremeter) that hast to be cultivated for each
point (city). The question is now: How can I calculate and display,
which cells of the raster map (potential agricultural land) hast to be
cultivated? Must be some sort of buffer or neighbourhood.....?

Assuming that this agricultural land is the same in all directions of the city, create a column which contains the radius of the circle that encompasses the land needed (i.e. if my memories of geometry are correct: sqrt(surface/pi) and feed the name of this column to the bufcol= parameter of v.buffer (or feed the formula directly to the bufcol parameter, but this only works if you use a db-backend which has a sqrt function, i.e. PostgreSQL).

Moritz

Hi Moritz

Thanks for your help. The problem is, that not each pixel around a point
(city) can be used as agricultural land. So I can't simply buffer the
cities with a circle. To concretize what i mean, i made a picture:
http://www.fotos-hochladen.net/view/landandcity1hjbk4qy3.jpg in green
you see the potential agricultural land and the black point is a city....

Thanks a lot

Martin

Moritz Lennert schrieb:

On 22/04/09 20:39, Martin Schweizer wrote:

Hi

I have a question which is a bit complex. Hope i can describe it ;-).

I have a point-vector layer (the citis) and a raster layer with 1 and
ZERO cells (The potenial agricultural land). One categorie in the vector
layer is the land (Squaremeter) that hast to be cultivated for each
point (city). The question is now: How can I calculate and display,
which cells of the raster map (potential agricultural land) hast to be
cultivated? Must be some sort of buffer or neighbourhood.....?

Assuming that this agricultural land is the same in all directions of
the city, create a column which contains the radius of the circle that
encompasses the land needed (i.e. if my memories of geometry are
correct: sqrt(surface/pi) and feed the name of this column to the
bufcol= parameter of v.buffer (or feed the formula directly to the
bufcol parameter, but this only works if you use a db-backend which
has a sqrt function, i.e. PostgreSQL).

Moritz

Martin,
after you have done the buffering operation (as Moritz said), and transformed vector map (buffer_areas) in raster (v.to rast), you can easily extract only the interested areas by using a mapalgebra operation… for example:

if “agri” is the map of your agricultural areas (green map)
and “buff” is the map of the buffer around the vector points

you can type:

r.mapcalc “interested_areas = agri * buff”

all cells with a not-zero value are the interested areas…
(I usually prefer to use NULL rather than ZERO… if you prefer it too, you can use r.null to transform ZERO to NULL values)

Hope this helps!

Annalisa

2009/4/23 Martin Schweizer <schweizermartin@students.unibe.ch>

Hi Moritz

Thanks for your help. The problem is, that not each pixel around a point
(city) can be used as agricultural land. So I can’t simply buffer the
cities with a circle. To concretize what i mean, i made a picture:
http://www.fotos-hochladen.net/view/landandcity1hjbk4qy3.jpg in green
you see the potential agricultural land and the black point is a city…

Thanks a lot

Martin

Moritz Lennert schrieb:

On 22/04/09 20:39, Martin Schweizer wrote:

Hi

I have a question which is a bit complex. Hope i can describe it ;-).

I have a point-vector layer (the citis) and a raster layer with 1 and
ZERO cells (The potenial agricultural land). One categorie in the vector
layer is the land (Squaremeter) that hast to be cultivated for each
point (city). The question is now: How can I calculate and display,
which cells of the raster map (potential agricultural land) hast to be
cultivated? Must be some sort of buffer or neighbourhood…?

Assuming that this agricultural land is the same in all directions of
the city, create a column which contains the radius of the circle that
encompasses the land needed (i.e. if my memories of geometry are
correct: sqrt(surface/pi) and feed the name of this column to the
bufcol= parameter of v.buffer (or feed the formula directly to the
bufcol parameter, but this only works if you use a db-backend which
has a sqrt function, i.e. PostgreSQL).

Moritz


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

Annalisa
Thanks for your help, but there is a little problem: I calculate the
agricultural land around a city, then i buffer the vector, transform it
into a raster map and subtract all the "not possible land". At the end,
there is less agricultural land than I calculated. There must be a
buffering operation which excludes already the NULL values of the "agri
map" in the calculation.... is there something like that?

Thanks a lot

Martin

Annalisa Minelli schrieb:

Martin,
after you have done the buffering operation (as Moritz said), and
transformed vector map (buffer_areas) in raster (v.to <http://v.to>
rast), you can easily extract only the interested areas by using a
mapalgebra operation.. for example:

if "agri" is the map of your agricultural areas (green map)
and "buff" is the map of the buffer around the vector points

you can type:

r.mapcalc "interested_areas = agri * buff"

all cells with a not-zero value are the interested areas..
(I usually prefer to use NULL rather than ZERO.. if you prefer it too,
you can use r.null to transform ZERO to NULL values)

Hope this helps!

Annalisa

2009/4/23 Martin Schweizer <schweizermartin@students.unibe.ch
<mailto:schweizermartin@students.unibe.ch>>

    Hi Moritz

    Thanks for your help. The problem is, that not each pixel around a
    point
    (city) can be used as agricultural land. So I can't simply buffer the
    cities with a circle. To concretize what i mean, i made a picture:
    http://www.fotos-hochladen.net/view/landandcity1hjbk4qy3.jpg in green
    you see the potential agricultural land and the black point is a
    city....

    Thanks a lot

    Martin

    Moritz Lennert schrieb:
    > On 22/04/09 20:39, Martin Schweizer wrote:
    >> Hi
    >>
    >> I have a question which is a bit complex. Hope i can describe
    it ;-).
    >>
    >> I have a point-vector layer (the citis) and a raster layer with
    1 and
    >> ZERO cells (The potenial agricultural land). One categorie in
    the vector
    >> layer is the land (Squaremeter) that hast to be cultivated for each
    >> point (city). The question is now: How can I calculate and display,
    >> which cells of the raster map (potential agricultural land)
    hast to be
    >> cultivated? Must be some sort of buffer or neighbourhood.....?
    >
    > Assuming that this agricultural land is the same in all
    directions of
    > the city, create a column which contains the radius of the
    circle that
    > encompasses the land needed (i.e. if my memories of geometry are
    > correct: sqrt(surface/pi) and feed the name of this column to the
    > bufcol= parameter of v.buffer (or feed the formula directly to the
    > bufcol parameter, but this only works if you use a db-backend which
    > has a sqrt function, i.e. PostgreSQL).
    >
    > Moritz
    >

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

On 24/04/09 16:40, Martin Schweizer wrote:

Annalisa
Thanks for your help, but there is a little problem: I calculate the
agricultural land around a city, then i buffer the vector, transform it
into a raster map and subtract all the "not possible land". At the end,
there is less agricultural land than I calculated. There must be a
buffering operation which excludes already the NULL values of the "agri
map" in the calculation.... is there something like that?

No.

I think you will have to script with some looping. You could start with v.buffer and than for those areas where cutting out the not-possible land leaves less than the necessary area, loop through e.g. r.grow and cutting off the non-available land, then check the size and continue growing+cutting until you reach that size.

Or you could probably cook something up in r.mapcalc.

Moritz

Thanks a lot

Martin

Annalisa Minelli schrieb:

Martin,
after you have done the buffering operation (as Moritz said), and
transformed vector map (buffer_areas) in raster (v.to <http://v.to>
rast), you can easily extract only the interested areas by using a
mapalgebra operation.. for example:

if "agri" is the map of your agricultural areas (green map)
and "buff" is the map of the buffer around the vector points

you can type:

r.mapcalc "interested_areas = agri * buff"

all cells with a not-zero value are the interested areas..
(I usually prefer to use NULL rather than ZERO.. if you prefer it too,
you can use r.null to transform ZERO to NULL values)

Hope this helps!

Annalisa

2009/4/23 Martin Schweizer <schweizermartin@students.unibe.ch
<mailto:schweizermartin@students.unibe.ch>>

    Hi Moritz

    Thanks for your help. The problem is, that not each pixel around a
    point
    (city) can be used as agricultural land. So I can't simply buffer the
    cities with a circle. To concretize what i mean, i made a picture:
    http://www.fotos-hochladen.net/view/landandcity1hjbk4qy3.jpg in green
    you see the potential agricultural land and the black point is a
    city....

    Thanks a lot

    Martin

    Moritz Lennert schrieb:
    > On 22/04/09 20:39, Martin Schweizer wrote:
    >> Hi
    >>
    >> I have a question which is a bit complex. Hope i can describe
    it ;-).
    >>
    >> I have a point-vector layer (the citis) and a raster layer with
    1 and
    >> ZERO cells (The potenial agricultural land). One categorie in
    the vector
    >> layer is the land (Squaremeter) that hast to be cultivated for each
    >> point (city). The question is now: How can I calculate and display,
    >> which cells of the raster map (potential agricultural land)
    hast to be
    >> cultivated? Must be some sort of buffer or neighbourhood.....?
    >
    > Assuming that this agricultural land is the same in all
    directions of
    > the city, create a column which contains the radius of the
    circle that
    > encompasses the land needed (i.e. if my memories of geometry are
    > correct: sqrt(surface/pi) and feed the name of this column to the
    > bufcol= parameter of v.buffer (or feed the formula directly to the
    > bufcol parameter, but this only works if you use a db-backend which
    > has a sqrt function, i.e. PostgreSQL).
    >
    > Moritz
    >

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

If I got it right - You need to fill possible agriculture land till it
reaches required area.
I think You can use mapcalc sample provided in r.lake documentation.
Just replace ${variables} with Your map name and calculate resulting
map area after every run. Mask nonagriculture land with MASK and it
will not be used.
Like (pseudocode):
while $area<$target:
r.mapcalc newmap={code from r.lake docs}
area = r.report newmap area

If You need additional help, drop a note.
Maris.