Dear list members, I hope this message finds you well. I submit to you a problem with which I have been struggling for several days without finding the beginning of a solution.
I need (i) to convert the geom column of a sf object into text and transform the sf object into a dataframe, (ii) then convert this dataframe back into an sf object. My problem is that this only operation changes the shape of the original polygons. I guess the problem lies with the layer itself, but so far I haven't been able to find the cause (the crs seems O.K., the geometry seems valid). Please find attached a test layer containing only three contiguous polygons and, below, the code needed to reproduce the problem : test <- sf::st_read("Please add your path/polygons.gpkg") # Converting the sf object into a dataframe with geom as text test_chr <- test |> dplyr::mutate(geom = sf::st_as_text(geom, EWKT = TRUE)) |> as.data.frame() # Converting back to a sf object test_new <- test_chr |> dplyr::mutate(geom = sf::st_as_sfc(geom)) |> sf::st_sf() # Comparing the original ('test') and the new ('test_new') sf objects plot(test$geom, lwd = 1, border = "blue") plot(test_new$geom, lwd = 2, lty = 2, border = "red", add = TRUE) Thank you in advance for your help. Cheers, Loïc
<<attachment: polygons.zip>>
_______________________________________________ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo