[GRASS-user] square buffeer

Hello,

I am looking for a way to create a square buffer for a point vector so that
each point is in the end the centroid of a square with defined side length.

I though about r.mapcalc statements to grow north-south and west-east and then
somehow create an area from this square. But I have no idea how to do it
without a lot of hand-work.

Any idea how to achieve that? Or hints where to find relevant documents.

Martin

Martin,
I think using vectors and some scripting will be the way to go here.

A simple script should be something like this:
1. create a new polygon vector with v.edit
2. for each point in your points vector get the x and y coords (v.to.db or maybe v.report)
3. calculate the vertices of your polygon based on the x and y coords.
4. Add new feature with v.edit
5. add vertices to feature with v.edit.
6. repeat for each point in points vector layer.

You can also use postgres/postgis functions and create the layer in postgis, you won’t need a script but you have to learn some about postgis.

Hope this helps.

Jonathan Aguero-Valverde
PhD. Candidate
The Thomas D. Larson
Pennsylvania Transportation Institute
The Pennsylvania State University

----- Original Message ----- From: "Martin Wegmann" <wegmann@biozentrum.uni-wuerzburg.de>
To: <grass-user@lists.osgeo.org>
Sent: Monday, June 16, 2008 10:18 AM
Subject: [GRASS-user] square buffeer

Hello,

I am looking for a way to create a square buffer for a point vector so that
each point is in the end the centroid of a square with defined side length.

I though about r.mapcalc statements to grow north-south and west-east and then
somehow create an area from this square. But I have no idea how to do it
without a lot of hand-work.

Any idea how to achieve that? Or hints where to find relevant documents.

Martin

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

I would rather rasterize at different grain size the same vector layer and then vectorize it. Just using g.region, v.to.rast, and r.to.vect respectively

Best

On Mon, Jun 16, 2008 at 10:10 AM, Jonathan Aguero-Valverde <jua130@psu.edu> wrote:

Martin,
I think using vectors and some scripting will be the way to go here.

A simple script should be something like this:

  1. create a new polygon vector with v.edit
  2. for each point in your points vector get the x and y coords (v.to.db or maybe v.report)
  3. calculate the vertices of your polygon based on the x and y coords.
  4. Add new feature with v.edit
  5. add vertices to feature with v.edit.
  6. repeat for each point in points vector layer.

You can also use postgres/postgis functions and create the layer in postgis, you won’t need a script but you have to learn some about postgis.

Hope this helps.

Jonathan Aguero-Valverde
PhD. Candidate
The Thomas D. Larson
Pennsylvania Transportation Institute
The Pennsylvania State University

----- Original Message ----- From: “Martin Wegmann” <wegmann@biozentrum.uni-wuerzburg.de>
To: <grass-user@lists.osgeo.org>
Sent: Monday, June 16, 2008 10:18 AM
Subject: [GRASS-user] square buffeer

Hello,

I am looking for a way to create a square buffer for a point vector so that
each point is in the end the centroid of a square with defined side length.

I though about r.mapcalc statements to grow north-south and west-east and then
somehow create an area from this square. But I have no idea how to do it
without a lot of hand-work.

Any idea how to achieve that? Or hints where to find relevant documents.

Martin


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


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


Pedro Camilo Alcántara Concepción
Department of Forest and Wildlife Ecology
Rm. 120 Russell Labs
1630 Linden Dr.
Madison WI 53706-1598
Phone +1/608/265-9219
http:/silvis.forest.wisc.edu


hello,

because doing it by hand or with already existing GRASS commands ist too
tedious, Elshad Shirinov programmed a small module for me which fullfills
this purpose.

The problem was, that coordinates which has been taken from a corner or center
of a sampling plot represent in fact a 50x50m or 50x200m plot/transect.

This module (r.buffer.rect) creates an area around the coordinate with defined
x and y side length and with defined position of the input coordinate.

e.g.: you sampled a 50x50m plot but you took the coordinate (x) of the
bottom-right corner, hence you need the actual area of your plot (1), that is
what r.buffer.rect does:

1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 x

hope this module will help other people as well, Martin

P.S.: I will add it to the GRASS add-on Wiki in the near future, when we
setup the *.html manual page.

Usage:
r.buffer.rect input=string output=string keyval=value x=value y=value
   alignment=string [title="phrase"] [--overwrite] [--verbose] [--quiet]

Flags:
--o Allow output files to overwrite existing files
--v Verbose module output
--q Quiet module output

Parameters:
      input Name of existing raster file
     output Name for the output raster file
     keyval Value of relevant pixels in the input raster
          x Width of the area
          y Height of the area
  alignment Alignment of the pixel relative to the rectangle
              options: center,top-left,top-right,bottom-left,bottom-right
      title Title of the output raster file

On Montag, 16. Juni 2008 16:18:49 Martin Wegmann wrote:

Hello,

I am looking for a way to create a square buffer for a point vector so that
each point is in the end the centroid of a square with defined side length.

I though about r.mapcalc statements to grow north-south and west-east and
then somehow create an area from this square. But I have no idea how to do
it without a lot of hand-work.

Any idea how to achieve that? Or hints where to find relevant documents.

Martin

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

(attachments)

main.c (6.12 KB)
Makefile (176 Bytes)
buffer.c (985 Bytes)
local_proto.h (355 Bytes)