简体   繁体   中英

Polygone to one polyline in R

I have a shape file from: https://earthworks.stanford.edu/catalog/stanford-yt100my8913 about Waters in Mozambique as Polygones.

I would like to have the Zambesze River as an Polyline. In the original file it is represented by two polygones. Which line (left, right, middle) exactly, I actually don't care but I want to have it as an single line.

I'm working with R. Reading Data as

River1 <- st_read("inwatera_moz.shp")
Subset_River1 <- "R. Zambeze"
River1<-  subset(River1,nam %in% Subset_River1)
plot(st_geometry(River1), col = "red", add = TRUE)

anyone have an Approach how I could manage?

If all you need is Zambezi river as a line (instead of a polygon) and your use case allows such a cavalier approach as you describe I then suggest using other data sources than the Stanford dataset.

Open Street Map may be a good start. Consider this piece of code; it utilizes the {nominatimlite} to access the OSM data.

library(sf)

zambezi <- nominatimlite::geo_lite_sf("Zambezi river", points_only = F)

st_geometry_type(zambezi)
# [1] MULTILINESTRING
# 18 Levels: GEOMETRY POINT LINESTRING POLYGON MULTIPOINT ... TRIANGLE

mapview::mapview(zambezi)

东非地图上的赞比西河

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM