File: retiring_rgdal_geos_1.R

package info (click to toggle)
r-cran-sp 1%3A2.2-0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,856 kB
  • sloc: ansic: 1,091; sh: 14; makefile: 2
file content (45 lines) | stat: -rw-r--r-- 1,663 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
## ----echo=FALSE---------------------------------------------------------------
knitr::opts_chunk$set(comment = "")

## ----setup, include=FALSE-----------------------------------------------------
knitr::opts_chunk$set(echo = TRUE, paged.print=FALSE)

## -----------------------------------------------------------------------------
library(sp)
getMethod("$", "SpatialPoints")

## -----------------------------------------------------------------------------
data(meuse)
names(meuse)

## -----------------------------------------------------------------------------
coordinates(meuse) <- ~ x + y
names(meuse)

## -----------------------------------------------------------------------------
colnames(slot(meuse, "coords"))

## -----------------------------------------------------------------------------
str(meuse$x)

## -----------------------------------------------------------------------------
run <- requireNamespace("sf", quietly = TRUE)

## ----eval=run-----------------------------------------------------------------
meuse_rt <- as(sf::st_as_sf(meuse), "Spatial")
names(meuse_rt)

## ----eval=run-----------------------------------------------------------------
colnames(slot(meuse_rt, "coords"))

## ----echo=FALSE---------------------------------------------------------------
run <- requireNamespace("terra", quietly=TRUE)
run <- run && require("raster", quietly=TRUE)

## ----eval=run-----------------------------------------------------------------
v <- terra::vect(matrix(c(0, 0), nrow=1), crs="OGC:CRS84")

## ----eval=run-----------------------------------------------------------------
library(raster)
slot(as(v, "Spatial"), "proj4string")