| 1 |
options("rgdal_show_exportToProj4_warnings"="none") |
| 2 |
source("utils/print.R") |
| 3 |
|
| 4 |
library(sp) |
| 5 |
data(meuse) |
| 6 |
x = meuse[1:10, ] # limit the output |
| 7 |
coordinates(x) = c("x", "y") # names |
| 8 |
bbox(x) |
| 9 |
is.projected(x) |
| 10 |
dimensions(x) |
| 11 |
x |
| 12 |
|
| 13 |
x = meuse[1:10, ] |
| 14 |
coordinates(x) = c(1, 2) # coordinate column numbers |
| 15 |
x |
| 16 |
|
| 17 |
x = meuse[1:10, ] |
| 18 |
coordinates(x) = ~x+y # coordinates formula |
| 19 |
x |
| 20 |
|
| 21 |
x = meuse[1:10, ] |
| 22 |
coordinates(x) = meuse[1:10, c("x", "y")] # coords, as data.frame |
| 23 |
x |
| 24 |
|
| 25 |
x = meuse[1:10, ] |
| 26 |
coordinates(x) = as.matrix(meuse[1:10, c("x", "y")]) # coords, as matrix |
| 27 |
x |
| 28 |
|
| 29 |
x = meuse[1:20,] |
| 30 |
coordinates(x) = c("x", "y") # coordinate column names |
| 31 |
print(summary(x)) |
| 32 |
|
| 33 |
x[1:10] # first 10 columns |
| 34 |
x[, 1:10] # first 10 columns |
| 35 |
x[1:10,] # rows 1-10 |
| 36 |
x["zinc"] # column zinc + coords |
| 37 |
x[, "zinc"] # idem |
| 38 |
x[1:10, "zinc"] # idem |
| 39 |
x[1:10, c("zinc", "cadmium")] # idem |
| 40 |
x[["zinc"]] |
| 41 |
x[["lnzinc"]] <- log(x[["zinc"]]) |
| 42 |
x |
| 43 |
|
| 44 |
print(summary(x[1:10, "zinc"])) # check bbox |
| 45 |
print(summary(x["zinc"])) # compare bbox |
| 46 |
|
| 47 |
data(meuse.grid) |
| 48 |
coordinates(meuse.grid) = ~x+y |
| 49 |
gridded(meuse.grid) = TRUE |
| 50 |
plot(meuse.grid) |