8

Is it possible to create buffers (in my case, but polygons in general also) that would create a boundary at their point of contact ? (so that they don't overlap on each other).

Like this (from left to right)

enter image description here

I am trying to solve this question where I need to join points representing addresses to their nearby parcel without including points related to adjacent parcels or parcels on the other side of the street.

It seems to me that there are two main options: either using voronoi/thiessen diagram but based on polygons, not points, or creating many buffers (making sure they overlap with the address points outside on the street), and then making these new polygons crop each other at the medium of their intersection line (which would be the median line of the street for street facing vertices, and the property boundary line for the vertice between two adjacent parcels/plots of land).

Spatially join attributes from point to polygon side in QGIS3 with numerous contiguous polygons and numerous adjacent points

8
  • Basically a tool to "grow" the polygons until they find each other's limits. Not sure if this exists. Sep 6, 2020 at 19:53
  • I think I could use something called Thiessen polygons if this applies also to polygons and not just to points. Sep 6, 2020 at 20:13
  • 1
    May I ask why do you comment under your question instead of editing your question with nesting those comments or setting up a chat?
    – Taras
    Sep 7, 2020 at 8:57
  • 3
    Good question!!
    – menes
    Sep 7, 2020 at 10:11
  • 2
    Try to focus your efforts on 3 main details: 1) Work only with the outer edges, creating a combined one-way buffer; 2) Work only with the inner central horizontal edges and create a central line from them, which will separate the inner polygon; 3) Work with the inner vertical lines, increasing them to the buffer edges and cross them; 4) Collect the necessary buffers, combining them if necessary ... somehow.... Sep 7, 2020 at 18:30

1 Answer 1

2

This is an approach to this problem using that strategy of the 'inner central horizontal edge'. In resume:

  1. Create buffers of the polygons.
  2. Intersection of buffers to get overlaping zones.
  3. Extract intersection coords to create the new medium edge.
  4. Clip buffers with lines and assign the parcel ID.

Here are the layers to try out.

Here is the code:

library(sf)
library(mapview)

# read data
pol <- st_read('./data/Parcels.gpkg')
mapview(pol)

enter image description here

# make the buffer
polbuf <- st_buffer(pol, 10, 0)
mapview(pol)+mapview(st_buffer(pol, 10, 0), alpha.regions=0.1)

enter image description here

# get intersection points
p_intersect <- gIntersection(as(as_Spatial(polbuf)[1,], "SpatialLines"), as_Spatial(polbuf))
mapview(p_intersect)

# extract intersection coordinates
# adapted from: https://stackoverflow.com/questions/55106950/r-sf-intersect-lines-with-the-borders-of-multipolygons-extract-coordinates-of
line_1 <- st_as_sf(as(as_Spatial(polbuf), "SpatialLines"))
poly_1 <- st_as_sf(as(as_Spatial(polbuf), "SpatialLines"))
pnts   <- st_intersection(line_1, st_cast(poly_1, "MULTILINESTRING", group_or_split = FALSE))

# catch points and get unique (as they will be duplicated...)
ps <- unique(pnts[st_geometry_type(pnts)=='MULTIPOINT',])
mapview(ps)+mapview(pol)+mapview(st_buffer(pol, 10, 0), alpha.regions=0.1)

enter image description here

# Create clipping lines with this points
# catched here: https://gis.stackexchange.com/questions/270725/r-sf-package-points-to-multiple-lines-with-st-cast
ls <- st_cast(ps, "LINESTRING")
mapview(ls)+mapview(ps)+mapview(pol)+mapview(st_buffer(pol, 10, 0), alpha.regions=0.1)

enter image description here

# split buffers with lines and consolidate
# cathed here: https://stackoverflow.com/questions/5726297/cut-polygons-using-contour-line-beneath-the-polygon-layers
library(rgeos)
lpi <- gIntersection(as_Spatial(polbuf), as_Spatial(ls))
blpi <- gBuffer(lpi, width = 0.000001)
dpi <- gDifference(as_Spatial(polbuf), blpi)
mapview(dpi)

enter image description here

# Asign parcel to each polygon
polbuf2 <- st_join(st_cast(st_as_sf(dpi), 'POLYGON'), pol)
mapview(pol)+mapview(polbuf2, alpha.regions = 0.2)

enter image description here

1
  • Thank you very much! I will try this, it seems exactly what I wanted to do Mar 9, 2021 at 19:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.