[GRASS-user] Retaining holes in buffers

Roger Bivand Roger.Bivand at nhh.no
Mon Jan 25 10:20:00 EST 2010

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:

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.


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 at nhh.no

More information about the grass-user mailing list