Open mdsumner opened 1 year ago
things have moved on a lot, there's an internal "grat()" for something that might replace {graticule}, this example just compares the points added by s2 (assuming a tesselation value so you get uniform density) with those added by bigcurve, because the lines needed more vertices to represet them in a given projection.
I haven't unpacked s2 yet so it's hard to hack the projections.
library(s2)
lons = seq(-0, 140, by = 10);
lats = seq(-60, -40, by = 5)
proj <-"+proj=laea +lat_0=-50"
plot(grct <- wk::as_rct(wk::grd(wk::rct(min(lons), min(lats), max(lons), max(lats)), dx = 10, dy = 5)))
s2_ortho <- function(x) {
centre <- as.numeric(s2:::last_plot_env$centre);
sprintf("+proj=ortho +lon_0=%f +lat_0=%f +R=6378137", centre[1], centre[2])
}
s2_proj <- function(x) {
terra::project(as.matrix(x), to = s2_ortho(), from = "OGC:CRS84")/6378137
}
s2_plot(
geog <- s2_geog_from_wkb(
wk::as_wkb(grct),
planar = TRUE,
tessellate_tol_m = 1e3
),
border = "red"
)
s2_plot(s2_data_countries(), add = TRUE)
points(s2_proj(wk::wk_coords(geog)[, c("x", "y")]))
g <- bigcurve:::grat(lons = seq(-0, 140, by = 10), lats = seq(-60, -40, by = 10), proj = "+proj=laea +lat_0=-50 +lon_0=0 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs")
#> [1] 204956.8 749263.0
#> [1] 291010424691 400398718039
plot(g)
points(wk::wk_coords(g)[, c("x", "y")])
Created on 2023-06-19 with reprex v2.0.2
motivation is the graticule package, and the various pieces are linked in this issue: https://github.com/hypertidy/textures/issues/12
and Dewey's example (a good one for describing why we want loxodromes and when)