Skip to content
Prev 27650 / 29559 Next

dissolve internal borders of polygons using st_union and group_by

On Thu, 17 Oct 2019, Marta Rufino wrote:

            
Please state all versions:

sessionInfo()
sf_extSoftVersion()

With an updated system, most of your code just does not work for me. You 
are looking for sf::aggregate():

kk <- aggregate(world_map, list(world_map$continent), head, n=1)

plot(st_geometry(kk))

shows that although the country boundaries are largely removed, the 
underlying data are not properly aligned, so slivers remain, some on 
continent boundaries, some as holes in land masses.

Contributions welcome to remove the artefacts.

Using tidyverse really occludes analysis here.

Note that EPSG 42310 simply does not exist in PROJ 6, it is retrievable 
from:

kk1 <- st_transform(kk, crs = paste0("+proj=merc +lat_ts=0 +lon_0=0",
  " +k=1.000000 +x_0=0 +y_0=0 +ellps=GRS80 +datum=WGS84 +units=m"))
plot(st_geometry(kk1))

and should never be used for obvious reasons.

kk2 <- st_transform(kk, crs=3857)
plot(st_geometry(kk2))

is not much better (Web Mercator).

Hope this clarifies,

Roger