Mixing points and sf objects
On Thu, 3 Mar 2022, Patrick Giraudoux wrote:
Dear listers, Just for curiosity, using one sf object (depts) and one classical data.frame with two columns bearing coordinates, I wonder why this sequence works (points and department limits are correctly drawn): plot(chbrut[,5:6],asp=1) plot(st_geometry(depts),add=TRUE) .. but not this one (points of chbrut are not projected - or projected somewhere else, and are not visible on the map) plot(st_geometry(depts),reset=FALSE) points(chbrut[,5:6],pch=19,col=cols)
Sorry, cannot reproduce:
library(sf)
nc <- st_read(system.file("gpkg/nc.gpkg", package="sf"))
nc_xy <- st_transform(nc, "EPSG:32019")
set.seed(1)
pts <- as.data.frame(st_coordinates(st_sample(nc_xy, 100)))
plot(pts, asp=1)
plot(st_geometry(nc_xy), add=TRUE)
and
plot(st_geometry(nc_xy))
points(pts)
seem the same. reset= is irrelevant if the plot method for sfc objects is
used, I think it applies to sf objects only, when multiple maps may be
displayed with keys.
Hope this helps,
Roger
Best, Patrick [[alternative HTML version deleted]]
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-geo&data=04%7C01%7CRoger.Bivand%40nhh.no%7C5d59728741d046dc88ab08d9fcf204c5%7C33a15b2f849941998d56f20b5aa91af2%7C0%7C0%7C637818938783874996%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=KxQmoTdwqh0IhlHnHeXmtX0DTIf2kGceX2INux47%2FHM%3D&reserved=0
Roger Bivand Emeritus Professor Department of Economics, Norwegian School of Economics, Postboks 3490 Ytre Sandviken, 5045 Bergen, Norway. e-mail: Roger.Bivand at nhh.no https://orcid.org/0000-0003-2392-6140 https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en