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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
|
R version 4.0.2 (2020-06-22) -- "Taking Off Again"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
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.
> suppressPackageStartupMessages(library(sf))
> options(rgdal_show_exportToProj4_warnings = "none")
> suppressWarnings(st_crs(-1))
Coordinate Reference System: NA
> suppressWarnings(st_crs(999999))
Coordinate Reference System: NA
> inherits(try(st_crs("error"), silent = TRUE), "try-error")
[1] TRUE
> str = "+proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000 +ellps=bessel +towgs84=565.4171,50.3319,465.5524,-0.398957388243134,0.343987817378283,-1.87740163998045,4.0725 +units=m +no_defs"
> x <- st_crs(str)
> x<- st_crs(3857)
> str = st_crs(3857)$proj4string
> st_crs(3857)$units
[1] "m"
> x = st_crs("+proj=longlat +datum=WGS84")
> x = st_crs(4326)
> x = st_crs("+proj=laea") # no EPSG
>
> x = st_sfc(st_point(0:1))
> y = st_crs(x, parameters = TRUE)
> st_crs(x) = 4326
> y = st_crs(x, parameters = TRUE)
>
> from = st_crs(4326)$proj4string
> to = st_crs(3857)$proj4string
> ret = sf_project(from, to, rbind(c(0,0), c(1,1)))
> round(ret, 7)
[,1] [,2]
[1,] 0.0 0.0
[2,] 111319.5 111325.1
> # create Inf points: #1227/#1228
> suppressWarnings(
+ sf_project("+proj=longlat", "+proj=lcc +lat_1=30 +lat_2=60", cbind(c(0,0),c(-80,-90)), keep = TRUE)
+ )
[,1] [,2]
[1,] 0 -53554590
[2,] NA NA
> sf_project(to, from, ret)
[,1] [,2]
[1,] 0 0
[2,] 1 1
> suppressWarnings(
+ sf_project("+proj=longlat", "+proj=lcc +lat_1=30 +lat_2=60", cbind(c(0,0),c(-80,-90)), keep = TRUE)
+ )
[,1] [,2]
[1,] 0 -53554590
[2,] NA NA
> st_transform(st_sfc(st_point(c(0,0)), st_point(c(1,1)), crs = 4326), 3857)
Geometry set for 2 features
geometry type: POINT
dimension: XY
bbox: xmin: 0 ymin: 0 xmax: 111319.5 ymax: 111325.1
projected CRS: WGS 84 / Pseudo-Mercator
POINT (0 0)
POINT (111319.5 111325.1)
> if (Sys.getenv("USER") %in% c("edzer", "travis")) { # causes memory leaks:
+ stopifnot(inherits(try(sf_project("+proj=longlat", "+proj=bar", matrix(1:4,2)), silent = TRUE), "try-error"))
+ stopifnot(inherits(try(sf_project("+proj=foo", "+proj=longlat", matrix(1:4,2)), silent = TRUE), "try-error"))
+ }
>
> if (sf_extSoftVersion()["USE_PROJ_H"] == "true" || sf_proj_info("have_datum_files")) {
+ "datum files installed"
+ } else {
+ "datum files not installed"
+ }
[1] "datum files installed"
>
> x = st_crs(sp::CRS("+proj=longlat +ellps=WGS84 +no_defs"))
>
> # https://github.com/r-spatial/sf/issues/1170
> g = st_as_sfc("POLYGON ((-61.66957 10.69214, -61.565 10.75728, -61.37453 10.77654, -61.40721 10.60681, -61.66957 10.69214))")
> d = st_as_sf(data.frame(id=1, geometry=g), crs=4326)
> st_area(d)
349128207 [m^2]
> st_area(st_transform(d, 2314))
349124497 [m^2]
>
> st_axis_order()
[1] FALSE
> if (sf_extSoftVersion()["GDAL"] >= "2.5.0")
+ st_axis_order(TRUE)
> st_axis_order(FALSE)
>
> proc.time()
user system elapsed
0.818 0.076 0.885
|