[R-sig-Geo] st_segmentize across east and west hemispheres

Amanda Rehbein @m@nd@@rehbe|n @end|ng |rom u@p@br
Wed Dec 30 19:57:34 CET 2020


Hi,

Thanks for your response.

Dear Ákos, many thanks for your comment, I tried changing the projection
using Robinson and Miller. The best results were using +long_0=-90 as shown
here https://mgimond.github.io/Spatial/coordinate-systems-in-r.html

lcc <- "+proj=robin +lat_0=0 +lon_0=-90 +x_0=0 +y_0=0 +ellps=WGS84
+datum=WGS84 +units=m +no_defs"
seg3 <- st_transform(seg, lcc)
plot(seg3, axes = T)


Dear Edzer, many thanks for your comment, st_wrap_dateline did not work for
me, maybe I should update my gdal and sf version. Below my session info.

sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.10

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.10.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] sf_0.9-6

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.5         class_7.3-17       crayon_1.3.4       dplyr_1.0.2

 [5] grid_4.0.3         R6_2.5.0           lwgeom_0.2-5
lifecycle_0.2.0
 [9] DBI_1.1.0          magrittr_2.0.1     e1071_1.7-4        units_0.6-7

[13] pillar_1.4.7       KernSmooth_2.23-17 rlang_0.4.9
 rstudioapi_0.11
[17] ellipsis_0.3.1     vctrs_0.3.5        generics_0.1.0     tools_4.0.3

[21] glue_1.4.2         purrr_0.3.4        compiler_4.0.3
pkgconfig_2.0.3
[25] classInt_0.4-3     tidyselect_1.1.0   tibble_3.0.4


Best,
Amanda

Em ter., 29 de dez. de 2020 às 09:54, Edzer Pebesma <
edzer.pebesma using uni-muenster.de> escreveu:

> You may want to look into st_wrap_dateline(), which cuts LINESTRING and
> POLYGON geometries in multi-part equivalents where parts do not cross
> the antimeridian.
>
> As in:
>
> seg2 <- st_segmentize(st_wrap_dateline(sf), units::set_units(1000, km))
>
>
> On 29/12/2020 00:24, Amanda Rehbein wrote:
> > Dear r-sig-geo list,
> >
> > I have a package called raytracing for calculating atmospheric Rossby
> wave
> > paths.
> > I need to get segments of the great circle or routes from some
> geographical
> > coordinates. st_segmentize is calculating them correctly. However, when I
> > need to connect two points in different hemispheres, east and west, it
> > creates an unwanted horizontal line, as shown in the following example.
> Is
> > it possible (and correct) to avoid or remove this horizontal line?
> >
> >
> > library(sf)
> > m <- rbind(c(100,-50),
> >             c(-100,50))
> > sf <- st_sf(a=1,
> >             geom=st_sfc(st_linestring(m)),
> >             crs = 4326)
> > seg <- st_segmentize(sf, units::set_units(1000, km))
> > plot(seg, axes = TRUE, reset = FALSE, type = "p", pch = 16)
> > plot(seg$geom, add = TRUE, col = "red")
> > text(x = m[, 1], y = m[, 2] - 7, label = 1:2, col = "blue")
> >
> > Many thanks.
> >
> >       [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > R-sig-Geo using r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>


-- 
*Amanda Rehbein*
MSc Atmospheric Sciences
Department of Atmospheric Sciences,
University of São Paulo
Group of Climate Studies (GrEC) | http://www.grec.iag.usp.br
Rua do Matão, 1226 - Cidade Universitária, São Paulo - SP - Brazil -
05508-090
Skype: amanda_rehbein1 | Phone: +55 11 3091-2852

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list