6

Is there an R function to create a centerline of a polygon? Similar to these methods in ArcGIS and Python?

Here's code to generate a dummy polygon -- where for this simple example we'd basically just want a line down the middle.

library(rgeos)
sdf <- data.frame(id=1:10, lat = 1:10, lon=1)
coordinates(sdf) <- ~lon+lat
sdf <- gBuffer(sdf, width=2, byid=F)

dummy polygon

1
  • I actually didn't find anything from a first look. You could try looking at the Python source of that package and copying some logic; it seems to rely on the Voronoi tessellation which you can do in R with (for example, there are others) sf::st_voronoi
    – Calum You
    Jul 16, 2019 at 21:42

0

Your Answer

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

Browse other questions tagged or ask your own question.