[GRASS-user] Retaining holes in buffers

,

This problem arose in comparing vector and raster buffering on a recent course. Using 6.4.0RC5 v.to.rast for a line, then buffering with r.buffer gave a plausible outcome, but we wished to look at the vector equivalent. In addition, we wanted to cookie-cut a raster with the vector buffer, to match using r.mapcalc on the raster workflow, in R taking the cell centres as representative points.

The problem is that while the internal vector representation of the buffer has a hole, the hole is filled with an island on export (using either shapefile or GML OGR drivers). The setup in R for a test dataset is:

library(rgdal)
L1 <- Line(cbind(c(1, 2, 3, 5), c(1, 3, 5, 10)))
L2 <- Line(cbind(c(2, 1.5, 3), c(3, 4, 5)))
LA <- Lines(list(L1, L2), ID="A")
LB <- Lines(list(Line(cbind(c(4, 6), c(3, 1)))), ID="B")
SL <- SpatialLines(list(LA, LB))
SLDF <- SpatialLinesDataFrame(SL, data=data.frame(ID=c("A", "B"),
  row.names=c("", "B"))))
writeOGR(SLDF, ".", "buff_island", driver="ESRI Shapefile")

(also on: http://spatial.nhh.no/misc/buff_island.zip).

then in GRASS (using wx) v.in.ogr to a new location, v.buffer with distance 0.25, display (OK, 2 centroids), export as area as shapefile or GML (visual inspection of the GML shows that the hole gets filled on export), import back, and the hole is filled (three centroids). I'm sure I'm missing something, but my cookie-cutter was cutting the island too, and should have avoided the hole.

I'd be very grateful for leads.

Roger

PS. Where is v.to.rast on the wx menu system?

--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand@nhh.no

When exporting areas with v.out.ogr, you need to set the -c flag if holes should stay holes. That changed in GRASS7, there the meaning of the -c flag is reversed and must be set to export features without category (because you are not the only one having this problem with v.out.ogr).

Markus M

Roger Bivand wrote:

This problem arose in comparing vector and raster buffering on a recent course. Using 6.4.0RC5 v.to.rast for a line, then buffering with r.buffer gave a plausible outcome, but we wished to look at the vector equivalent. In addition, we wanted to cookie-cut a raster with the vector buffer, to match using r.mapcalc on the raster workflow, in R taking the cell centres as representative points.

The problem is that while the internal vector representation of the buffer has a hole, the hole is filled with an island on export (using either shapefile or GML OGR drivers). The setup in R for a test dataset is:

library(rgdal)
L1 <- Line(cbind(c(1, 2, 3, 5), c(1, 3, 5, 10)))
L2 <- Line(cbind(c(2, 1.5, 3), c(3, 4, 5)))
LA <- Lines(list(L1, L2), ID="A")
LB <- Lines(list(Line(cbind(c(4, 6), c(3, 1)))), ID="B")
SL <- SpatialLines(list(LA, LB))
SLDF <- SpatialLinesDataFrame(SL, data=data.frame(ID=c("A", "B"),
row.names=c("", "B"))))
writeOGR(SLDF, ".", "buff_island", driver="ESRI Shapefile")

(also on: http://spatial.nhh.no/misc/buff_island.zip).

then in GRASS (using wx) v.in.ogr to a new location, v.buffer with distance 0.25, display (OK, 2 centroids), export as area as shapefile or GML (visual inspection of the GML shows that the hole gets filled on export), import back, and the hole is filled (three centroids). I'm sure I'm missing something, but my cookie-cutter was cutting the island too, and should have avoided the hole.

I'd be very grateful for leads.

Roger

PS. Where is v.to.rast on the wx menu system?

Roger wrote:

PS. Where is v.to.rast on the wx menu system?

in the wx GUI try:

Help -> Show menu tree
  then
Search: [command]
  then type in v.to.rast

or have a look in the module synopsis PDF
  http://grass.osgeo.org/gdp/grassmanuals/grass64_module_list.pdf

there is an open wish to add the menu location between the
option summary and the description.html part of the module help
pages. It's doable, it just takes some Makefile magic.

Hamish

On Mon, 25 Jan 2010, Hamish wrote:

Roger wrote:

PS. Where is v.to.rast on the wx menu system?

in the wx GUI try:

Help -> Show menu tree
then
Search: [command]
then type in v.to.rast

Regretably, on my 6.4.0RC5, there are only GRASS GIS Help, GRASS GIS GUI Help, and About GRASS GIS to choose from.

or have a look in the module synopsis PDF
http://grass.osgeo.org/gdp/grassmanuals/grass64_module_list.pdf

Yes, that is: File > Map type conversions > Vector to raster

I'd been looking under Vector > for obvious reasons.

Thanks,

Roger

there is an open wish to add the menu location between the
option summary and the description.html part of the module help
pages. It's doable, it just takes some Makefile magic.

Hamish

--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand@nhh.no