R Under development (unstable) (2024-11-06 r87293 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > options(rgdal_show_exportToProj4_warnings = "none") > if (suppressPackageStartupMessages(require(sp, quietly = TRUE))) { + demo(meuse) + # remove +init=xxx + meuse@proj4string = CRS( + "+proj=sterea +lat_0=52.1561605555556 +lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000 +ellps=bessel +units=m +no_defs" + ) + meuse.grid@proj4string = CRS( + "+proj=sterea +lat_0=52.1561605555556 +lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000 +ellps=bessel +units=m +no_defs" + ) + + suppressPackageStartupMessages(library(stars)) + (m = st_as_stars(meuse)) + (gr = st_as_stars(meuse.grid)) + + m2 = as(m, "Spatial") + summary(m2) + gr2 = as(gr, "Spatial") + summary(gr2) + + all.equal(meuse, m2, check.attributes = FALSE) + fullgrid(meuse.grid) = TRUE + all.equal(meuse.grid, gr2, check.attributes = FALSE) + + #all.equal(meuse, m2) + #all.equal(meuse.grid, gr2) + } demo(meuse) ---- ~~~~~ > require(sp) > crs = CRS("EPSG:28992") > data("meuse") > coordinates(meuse) <- ~x+y > proj4string(meuse) <- crs > data("meuse.grid") > coordinates(meuse.grid) <- ~x+y > gridded(meuse.grid) <- TRUE > proj4string(meuse.grid) <- crs > data("meuse.riv") > meuse.riv <- SpatialPolygons(list(Polygons(list(Polygon(meuse.riv)),"meuse.riv"))) > proj4string(meuse.riv) <- crs > data("meuse.area") > meuse.area = SpatialPolygons(list(Polygons(list(Polygon(meuse.area)), "area"))) > proj4string(meuse.area) <- crs [1] TRUE > > proc.time() user system elapsed 1.42 0.35 1.76