R Under development (unstable) (2023-09-30 r85239 ucrt) -- "Unsuffered Consequences" Copyright (C) 2023 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") > library(sp) The legacy packages maptools, rgdal, and rgeos, underpinning the sp package, which was just loaded, were retired in October 2023. Please refer to R-spatial evolution reports for details, especially https://r-spatial.org/r/2023/05/15/evolution4.html. It may be desirable to make the sf package available; package maintainers should consider adding sf to Suggests:. > data(meuse) > x = meuse[1:10, ] # limit the output > coordinates(x) = c("x", "y") # names > bbox(x) min max x 181025 181390 y 333168 333611 > is.projected(x) [1] NA > dimensions(x) [1] 2 > x coordinates cadmium copper lead zinc elev dist om ffreq soil 1 (181072, 333611) 11.7 85 299 1022 7.909 0.00135803 13.6 1 1 2 (181025, 333558) 8.6 81 277 1141 6.983 0.01222430 14.0 1 1 3 (181165, 333537) 6.5 68 199 640 7.800 0.10302900 13.0 1 1 4 (181298, 333484) 2.6 81 116 257 7.655 0.19009400 8.0 1 2 5 (181307, 333330) 2.8 48 117 269 7.480 0.27709000 8.7 1 2 6 (181390, 333260) 3.0 61 137 281 7.791 0.36406700 7.8 1 2 7 (181165, 333370) 3.2 31 132 346 8.217 0.19009400 9.2 1 2 8 (181027, 333363) 2.8 29 150 406 8.490 0.09215160 9.5 1 1 9 (181060, 333231) 2.4 37 133 347 8.668 0.18461400 10.6 1 1 10 (181232, 333168) 1.6 24 80 183 9.049 0.30970200 6.3 1 2 lime landuse dist.m 1 1 Ah 50 2 1 Ah 30 3 1 Ah 150 4 0 Ga 270 5 0 Ah 380 6 0 Ga 470 7 0 Ah 240 8 0 Ab 120 9 0 Ab 240 10 0 W 420 > > x = meuse[1:10, ] > coordinates(x) = c(1, 2) # coordinate column numbers > x coordinates cadmium copper lead zinc elev dist om ffreq soil 1 (181072, 333611) 11.7 85 299 1022 7.909 0.00135803 13.6 1 1 2 (181025, 333558) 8.6 81 277 1141 6.983 0.01222430 14.0 1 1 3 (181165, 333537) 6.5 68 199 640 7.800 0.10302900 13.0 1 1 4 (181298, 333484) 2.6 81 116 257 7.655 0.19009400 8.0 1 2 5 (181307, 333330) 2.8 48 117 269 7.480 0.27709000 8.7 1 2 6 (181390, 333260) 3.0 61 137 281 7.791 0.36406700 7.8 1 2 7 (181165, 333370) 3.2 31 132 346 8.217 0.19009400 9.2 1 2 8 (181027, 333363) 2.8 29 150 406 8.490 0.09215160 9.5 1 1 9 (181060, 333231) 2.4 37 133 347 8.668 0.18461400 10.6 1 1 10 (181232, 333168) 1.6 24 80 183 9.049 0.30970200 6.3 1 2 lime landuse dist.m 1 1 Ah 50 2 1 Ah 30 3 1 Ah 150 4 0 Ga 270 5 0 Ah 380 6 0 Ga 470 7 0 Ah 240 8 0 Ab 120 9 0 Ab 240 10 0 W 420 > > x = meuse[1:10, ] > coordinates(x) = ~x+y # coordinates formula > x coordinates cadmium copper lead zinc elev dist om ffreq soil 1 (181072, 333611) 11.7 85 299 1022 7.909 0.00135803 13.6 1 1 2 (181025, 333558) 8.6 81 277 1141 6.983 0.01222430 14.0 1 1 3 (181165, 333537) 6.5 68 199 640 7.800 0.10302900 13.0 1 1 4 (181298, 333484) 2.6 81 116 257 7.655 0.19009400 8.0 1 2 5 (181307, 333330) 2.8 48 117 269 7.480 0.27709000 8.7 1 2 6 (181390, 333260) 3.0 61 137 281 7.791 0.36406700 7.8 1 2 7 (181165, 333370) 3.2 31 132 346 8.217 0.19009400 9.2 1 2 8 (181027, 333363) 2.8 29 150 406 8.490 0.09215160 9.5 1 1 9 (181060, 333231) 2.4 37 133 347 8.668 0.18461400 10.6 1 1 10 (181232, 333168) 1.6 24 80 183 9.049 0.30970200 6.3 1 2 lime landuse dist.m 1 1 Ah 50 2 1 Ah 30 3 1 Ah 150 4 0 Ga 270 5 0 Ah 380 6 0 Ga 470 7 0 Ah 240 8 0 Ab 120 9 0 Ab 240 10 0 W 420 > > x = meuse[1:10, ] > coordinates(x) = meuse[1:10, c("x", "y")] # coords, as data.frame > x coordinates x y cadmium copper lead zinc elev dist 1 (181072, 333611) 181072 333611 11.7 85 299 1022 7.909 0.00135803 2 (181025, 333558) 181025 333558 8.6 81 277 1141 6.983 0.01222430 3 (181165, 333537) 181165 333537 6.5 68 199 640 7.800 0.10302900 4 (181298, 333484) 181298 333484 2.6 81 116 257 7.655 0.19009400 5 (181307, 333330) 181307 333330 2.8 48 117 269 7.480 0.27709000 6 (181390, 333260) 181390 333260 3.0 61 137 281 7.791 0.36406700 7 (181165, 333370) 181165 333370 3.2 31 132 346 8.217 0.19009400 8 (181027, 333363) 181027 333363 2.8 29 150 406 8.490 0.09215160 9 (181060, 333231) 181060 333231 2.4 37 133 347 8.668 0.18461400 10 (181232, 333168) 181232 333168 1.6 24 80 183 9.049 0.30970200 om ffreq soil lime landuse dist.m 1 13.6 1 1 1 Ah 50 2 14.0 1 1 1 Ah 30 3 13.0 1 1 1 Ah 150 4 8.0 1 2 0 Ga 270 5 8.7 1 2 0 Ah 380 6 7.8 1 2 0 Ga 470 7 9.2 1 2 0 Ah 240 8 9.5 1 1 0 Ab 120 9 10.6 1 1 0 Ab 240 10 6.3 1 2 0 W 420 > > x = meuse[1:10, ] > coordinates(x) = as.matrix(meuse[1:10, c("x", "y")]) # coords, as matrix > x coordinates x y cadmium copper lead zinc elev dist 1 (181072, 333611) 181072 333611 11.7 85 299 1022 7.909 0.00135803 2 (181025, 333558) 181025 333558 8.6 81 277 1141 6.983 0.01222430 3 (181165, 333537) 181165 333537 6.5 68 199 640 7.800 0.10302900 4 (181298, 333484) 181298 333484 2.6 81 116 257 7.655 0.19009400 5 (181307, 333330) 181307 333330 2.8 48 117 269 7.480 0.27709000 6 (181390, 333260) 181390 333260 3.0 61 137 281 7.791 0.36406700 7 (181165, 333370) 181165 333370 3.2 31 132 346 8.217 0.19009400 8 (181027, 333363) 181027 333363 2.8 29 150 406 8.490 0.09215160 9 (181060, 333231) 181060 333231 2.4 37 133 347 8.668 0.18461400 10 (181232, 333168) 181232 333168 1.6 24 80 183 9.049 0.30970200 om ffreq soil lime landuse dist.m 1 13.6 1 1 1 Ah 50 2 14.0 1 1 1 Ah 30 3 13.0 1 1 1 Ah 150 4 8.0 1 2 0 Ga 270 5 8.7 1 2 0 Ah 380 6 7.8 1 2 0 Ga 470 7 9.2 1 2 0 Ah 240 8 9.5 1 1 0 Ab 120 9 10.6 1 1 0 Ab 240 10 6.3 1 2 0 W 420 > > x = meuse[1:20,] > coordinates(x) = c("x", "y") # coordinate column names > print(summary(x)) Object of class SpatialPointsDataFrame Coordinates: min max x 180555 181390 y 332707 333611 Is projected: NA proj4string : [NA] Number of points: 20 Data attributes: cadmium copper lead zinc Min. : 1.400 Min. :24.00 Min. : 80.0 Min. : 183.0 1st Qu.: 2.475 1st Qu.:30.50 1st Qu.:126.8 1st Qu.: 278.0 Median : 3.100 Median :64.50 Median :142.5 Median : 455.0 Mean : 5.465 Mean :56.95 Mean :171.7 Mean : 569.7 3rd Qu.: 8.625 3rd Qu.:81.00 3rd Qu.:215.2 3rd Qu.: 806.8 Max. :12.900 Max. :95.00 Max. :299.0 Max. :1141.0 elev dist om ffreq soil lime Min. :6.860 Min. :0.000000 Min. : 6.300 1:20 1:14 0:11 1st Qu.:7.280 1st Qu.:0.009508 1st Qu.: 8.625 2: 0 2: 6 1: 9 Median :7.795 Median :0.108480 Median :10.050 3: 0 3: 0 Mean :7.952 Mean :0.128719 Mean :11.285 3rd Qu.:8.705 3rd Qu.:0.199601 3rd Qu.:14.200 Max. :9.073 Max. :0.364067 Max. :16.200 landuse dist.m Ah :7 Min. : 10.0 W :6 1st Qu.: 17.5 Ab :2 Median :140.0 Ga :2 Mean :174.5 Ag :1 3rd Qu.:277.5 (Other):1 Max. :470.0 NA's :1 > > x[1:10] # first 10 columns coordinates cadmium copper lead zinc elev dist om ffreq soil 1 (181072, 333611) 11.7 85 299 1022 7.909 0.00135803 13.6 1 1 2 (181025, 333558) 8.6 81 277 1141 6.983 0.01222430 14.0 1 1 3 (181165, 333537) 6.5 68 199 640 7.800 0.10302900 13.0 1 1 4 (181298, 333484) 2.6 81 116 257 7.655 0.19009400 8.0 1 2 5 (181307, 333330) 2.8 48 117 269 7.480 0.27709000 8.7 1 2 6 (181390, 333260) 3.0 61 137 281 7.791 0.36406700 7.8 1 2 7 (181165, 333370) 3.2 31 132 346 8.217 0.19009400 9.2 1 2 8 (181027, 333363) 2.8 29 150 406 8.490 0.09215160 9.5 1 1 9 (181060, 333231) 2.4 37 133 347 8.668 0.18461400 10.6 1 1 10 (181232, 333168) 1.6 24 80 183 9.049 0.30970200 6.3 1 2 11 (181191, 333115) 1.4 25 86 189 9.015 0.31511600 6.4 1 2 12 (181032, 333031) 1.8 25 97 251 9.073 0.22812300 9.0 1 1 13 (180874, 333339) 11.2 93 285 1096 7.320 0.00000000 15.4 1 1 14 (180969, 333252) 2.5 31 183 504 8.815 0.11393200 8.4 1 1 15 (181011, 333161) 2.0 27 130 326 8.937 0.16833600 9.1 1 1 16 (180830, 333246) 9.5 86 240 1032 7.702 0.00000000 16.2 1 1 17 (180763, 333104) 7.0 74 133 606 7.160 0.01222430 16.0 1 1 18 (180694, 332972) 7.1 69 148 711 7.100 0.01222430 16.0 1 1 19 (180625, 332847) 8.7 69 207 735 7.020 0.00000000 13.7 1 1 20 (180555, 332707) 12.9 95 284 1052 6.860 0.00000000 14.8 1 1 lime 1 1 2 1 3 1 4 0 5 0 6 0 7 0 8 0 9 0 10 0 11 0 12 0 13 1 14 0 15 0 16 1 17 1 18 1 19 1 20 1 > x[, 1:10] # first 10 columns coordinates cadmium copper lead zinc elev dist om ffreq soil 1 (181072, 333611) 11.7 85 299 1022 7.909 0.00135803 13.6 1 1 2 (181025, 333558) 8.6 81 277 1141 6.983 0.01222430 14.0 1 1 3 (181165, 333537) 6.5 68 199 640 7.800 0.10302900 13.0 1 1 4 (181298, 333484) 2.6 81 116 257 7.655 0.19009400 8.0 1 2 5 (181307, 333330) 2.8 48 117 269 7.480 0.27709000 8.7 1 2 6 (181390, 333260) 3.0 61 137 281 7.791 0.36406700 7.8 1 2 7 (181165, 333370) 3.2 31 132 346 8.217 0.19009400 9.2 1 2 8 (181027, 333363) 2.8 29 150 406 8.490 0.09215160 9.5 1 1 9 (181060, 333231) 2.4 37 133 347 8.668 0.18461400 10.6 1 1 10 (181232, 333168) 1.6 24 80 183 9.049 0.30970200 6.3 1 2 11 (181191, 333115) 1.4 25 86 189 9.015 0.31511600 6.4 1 2 12 (181032, 333031) 1.8 25 97 251 9.073 0.22812300 9.0 1 1 13 (180874, 333339) 11.2 93 285 1096 7.320 0.00000000 15.4 1 1 14 (180969, 333252) 2.5 31 183 504 8.815 0.11393200 8.4 1 1 15 (181011, 333161) 2.0 27 130 326 8.937 0.16833600 9.1 1 1 16 (180830, 333246) 9.5 86 240 1032 7.702 0.00000000 16.2 1 1 17 (180763, 333104) 7.0 74 133 606 7.160 0.01222430 16.0 1 1 18 (180694, 332972) 7.1 69 148 711 7.100 0.01222430 16.0 1 1 19 (180625, 332847) 8.7 69 207 735 7.020 0.00000000 13.7 1 1 20 (180555, 332707) 12.9 95 284 1052 6.860 0.00000000 14.8 1 1 lime 1 1 2 1 3 1 4 0 5 0 6 0 7 0 8 0 9 0 10 0 11 0 12 0 13 1 14 0 15 0 16 1 17 1 18 1 19 1 20 1 > x[1:10,] # rows 1-10 coordinates cadmium copper lead zinc elev dist om ffreq soil 1 (181072, 333611) 11.7 85 299 1022 7.909 0.00135803 13.6 1 1 2 (181025, 333558) 8.6 81 277 1141 6.983 0.01222430 14.0 1 1 3 (181165, 333537) 6.5 68 199 640 7.800 0.10302900 13.0 1 1 4 (181298, 333484) 2.6 81 116 257 7.655 0.19009400 8.0 1 2 5 (181307, 333330) 2.8 48 117 269 7.480 0.27709000 8.7 1 2 6 (181390, 333260) 3.0 61 137 281 7.791 0.36406700 7.8 1 2 7 (181165, 333370) 3.2 31 132 346 8.217 0.19009400 9.2 1 2 8 (181027, 333363) 2.8 29 150 406 8.490 0.09215160 9.5 1 1 9 (181060, 333231) 2.4 37 133 347 8.668 0.18461400 10.6 1 1 10 (181232, 333168) 1.6 24 80 183 9.049 0.30970200 6.3 1 2 lime landuse dist.m 1 1 Ah 50 2 1 Ah 30 3 1 Ah 150 4 0 Ga 270 5 0 Ah 380 6 0 Ga 470 7 0 Ah 240 8 0 Ab 120 9 0 Ab 240 10 0 W 420 > x["zinc"] # column zinc + coords coordinates zinc 1 (181072, 333611) 1022 2 (181025, 333558) 1141 3 (181165, 333537) 640 4 (181298, 333484) 257 5 (181307, 333330) 269 6 (181390, 333260) 281 7 (181165, 333370) 346 8 (181027, 333363) 406 9 (181060, 333231) 347 10 (181232, 333168) 183 11 (181191, 333115) 189 12 (181032, 333031) 251 13 (180874, 333339) 1096 14 (180969, 333252) 504 15 (181011, 333161) 326 16 (180830, 333246) 1032 17 (180763, 333104) 606 18 (180694, 332972) 711 19 (180625, 332847) 735 20 (180555, 332707) 1052 > x[, "zinc"] # idem coordinates zinc 1 (181072, 333611) 1022 2 (181025, 333558) 1141 3 (181165, 333537) 640 4 (181298, 333484) 257 5 (181307, 333330) 269 6 (181390, 333260) 281 7 (181165, 333370) 346 8 (181027, 333363) 406 9 (181060, 333231) 347 10 (181232, 333168) 183 11 (181191, 333115) 189 12 (181032, 333031) 251 13 (180874, 333339) 1096 14 (180969, 333252) 504 15 (181011, 333161) 326 16 (180830, 333246) 1032 17 (180763, 333104) 606 18 (180694, 332972) 711 19 (180625, 332847) 735 20 (180555, 332707) 1052 > x[1:10, "zinc"] # idem coordinates zinc 1 (181072, 333611) 1022 2 (181025, 333558) 1141 3 (181165, 333537) 640 4 (181298, 333484) 257 5 (181307, 333330) 269 6 (181390, 333260) 281 7 (181165, 333370) 346 8 (181027, 333363) 406 9 (181060, 333231) 347 10 (181232, 333168) 183 > x[1:10, c("zinc", "cadmium")] # idem coordinates zinc cadmium 1 (181072, 333611) 1022 11.7 2 (181025, 333558) 1141 8.6 3 (181165, 333537) 640 6.5 4 (181298, 333484) 257 2.6 5 (181307, 333330) 269 2.8 6 (181390, 333260) 281 3.0 7 (181165, 333370) 346 3.2 8 (181027, 333363) 406 2.8 9 (181060, 333231) 347 2.4 10 (181232, 333168) 183 1.6 > x[["zinc"]] [1] 1022 1141 640 257 269 281 346 406 347 183 189 251 1096 504 326 [16] 1032 606 711 735 1052 > x[["lnzinc"]] <- log(x[["zinc"]]) > x coordinates cadmium copper lead zinc elev dist om ffreq soil 1 (181072, 333611) 11.7 85 299 1022 7.909 0.00135803 13.6 1 1 2 (181025, 333558) 8.6 81 277 1141 6.983 0.01222430 14.0 1 1 3 (181165, 333537) 6.5 68 199 640 7.800 0.10302900 13.0 1 1 4 (181298, 333484) 2.6 81 116 257 7.655 0.19009400 8.0 1 2 5 (181307, 333330) 2.8 48 117 269 7.480 0.27709000 8.7 1 2 6 (181390, 333260) 3.0 61 137 281 7.791 0.36406700 7.8 1 2 7 (181165, 333370) 3.2 31 132 346 8.217 0.19009400 9.2 1 2 8 (181027, 333363) 2.8 29 150 406 8.490 0.09215160 9.5 1 1 9 (181060, 333231) 2.4 37 133 347 8.668 0.18461400 10.6 1 1 10 (181232, 333168) 1.6 24 80 183 9.049 0.30970200 6.3 1 2 11 (181191, 333115) 1.4 25 86 189 9.015 0.31511600 6.4 1 2 12 (181032, 333031) 1.8 25 97 251 9.073 0.22812300 9.0 1 1 13 (180874, 333339) 11.2 93 285 1096 7.320 0.00000000 15.4 1 1 14 (180969, 333252) 2.5 31 183 504 8.815 0.11393200 8.4 1 1 15 (181011, 333161) 2.0 27 130 326 8.937 0.16833600 9.1 1 1 16 (180830, 333246) 9.5 86 240 1032 7.702 0.00000000 16.2 1 1 17 (180763, 333104) 7.0 74 133 606 7.160 0.01222430 16.0 1 1 18 (180694, 332972) 7.1 69 148 711 7.100 0.01222430 16.0 1 1 19 (180625, 332847) 8.7 69 207 735 7.020 0.00000000 13.7 1 1 20 (180555, 332707) 12.9 95 284 1052 6.860 0.00000000 14.8 1 1 lime landuse dist.m lnzinc 1 1 Ah 50 6.929517 2 1 Ah 30 7.039660 3 1 Ah 150 6.461468 4 0 Ga 270 5.549076 5 0 Ah 380 5.594711 6 0 Ga 470 5.638355 7 0 Ah 240 5.846439 8 0 Ab 120 6.006353 9 0 Ab 240 5.849325 10 0 W 420 5.209486 11 0 Fh 400 5.241747 12 0 Ag 300 5.525453 13 1 W 20 6.999422 14 0 Ah 130 6.222576 15 0 Ah 220 5.786897 16 1 W 10 6.939254 17 1 W 10 6.406880 18 1 W 10 6.566672 19 1 W 10 6.599870 20 1 10 6.958448 > > print(summary(x[1:10, "zinc"])) # check bbox Object of class SpatialPointsDataFrame Coordinates: min max x 181025 181390 y 333168 333611 Is projected: NA proj4string : [NA] Number of points: 10 Data attributes: zinc Min. : 183.0 1st Qu.: 272.0 Median : 346.5 Mean : 489.2 3rd Qu.: 581.5 Max. :1141.0 > print(summary(x["zinc"])) # compare bbox Object of class SpatialPointsDataFrame Coordinates: min max x 180555 181390 y 332707 333611 Is projected: NA proj4string : [NA] Number of points: 20 Data attributes: zinc Min. : 183.0 1st Qu.: 278.0 Median : 455.0 Mean : 569.7 3rd Qu.: 806.8 Max. :1141.0 > > data(meuse.grid) > coordinates(meuse.grid) = ~x+y > gridded(meuse.grid) = TRUE > plot(meuse.grid) > > proc.time() user system elapsed 0.75 0.10 0.84