MikkoVihtakari/ggOceanMaps

dist2land does not work for decimal degree CRS

Closed this issue · 1 comments

library(ggOceanMaps)
#> Loading required package: ggplot2
#> Loading required package: ggspatial
#> ggOceanMaps: Setting data download folder to a temporary folder
#> /var/folders/9v/b70pd53x04d3jjmlrbcgp4_w0000gv/T//Rtmp1Svylt. This
#> means that any downloaded map data need to be downloaded again when you
#> restart R. To avoid this problem, change the default path to a
#> permanent folder on your computer. Add following lines to your
#> .Rprofile file: {.ggOceanMapsenv <- new.env(); .ggOceanMapsenv$datapath
#> <- 'YourCustomPath'}. You can use usethis::edit_r_profile() to edit the
#> file.'~/Documents/ggOceanMapsLargeData'would make it in a writable
#> folder on most operating systems.
DF <- data.frame(longitude = c(-150, -120), latitude = c(30, 35))
dist2land(DF)
#> Used longitude and latitude as input coordinate column names in data
#> Using DecimalDegree as land shapes.
#> Calculating distances with parallel processing...
#>   longitude latitude      ldist
#> 1      -150       30 0.01098418
#> 2      -120       35 0.00000000

DF <- data.frame(longitude = c(-150, -120), latitude = c(30, 65))
dist2land(DF)
#> Used longitude and latitude as input coordinate column names in data
#> Using ArcticStereographic as land shapes.
#> Calculating distances with parallel processing...
#>   longitude latitude    ldist
#> 1      -150       30 1608.964
#> 2      -120       65    0.000

Created on 2023-05-23 with reprex v2.0.2

Fixed with the shift to sf: 2d4af66

library(ggOceanMaps)
#> Loading required package: ggplot2
#> ggOceanMaps: Setting data download folder to a temporary folder
#> /var/folders/9v/b70pd53x04d3jjmlrbcgp4_w0000gv/T//Rtmp6T43Jn. This
#> means that any downloaded map data need to be downloaded again when you
#> restart R. To avoid this problem, change the default path to a
#> permanent folder on your computer. Add following lines to your
#> .Rprofile file: {.ggOceanMapsenv <- new.env(); .ggOceanMapsenv$datapath
#> <- 'YourCustomPath'}. You can use usethis::edit_r_profile() to edit the
#> file.'~/Documents/ggOceanMapsLargeData'would make it in a writable
#> folder on most operating systems.
packageVersion("ggOceanMaps")
#> [1] '1.4.0'
DF <- data.frame(longitude = c(-150, -120), latitude = c(30, 35))
dist2land(DF)
#> Used longitude and latitude as input coordinate column names in data
#> Using DecimalDegree as land shapes.
#> Calculating distances...
#> Returning great circle spherical distances from land as kilometers.
#>   longitude latitude    ldist
#> 1      -150       30 1185.697
#> 2      -120       35    0.000

DF <- data.frame(longitude = c(-150, -120), latitude = c(30, 65))
dist2land(DF)
#> Used longitude and latitude as input coordinate column names in data
#> Using DecimalDegree as land shapes.
#> Calculating distances...
#> Returning great circle spherical distances from land as kilometers.
#>   longitude latitude    ldist
#> 1      -150       30 1185.697
#> 2      -120       65    0.000

Created on 2023-06-26 with reprex v2.0.2