MikkoVihtakari / ggOceanMaps

Plot oceanographic research data on maps using ggplot2
GNU General Public License v3.0
45 stars 7 forks source link

dist2land not working properly #26

Closed Miguelbirostris closed 1 year ago

Miguelbirostris commented 1 year ago
dist2land function not working when binary=F. >remotes::install_github("MikkoVihtakari/ggOceanMapsData") Skipping install of 'ggOceanMapsData' from a github remote, the SHA1 (4392a331) has not changed since last install. Use `force = TRUE` to force installation > packageVersion("ggOceanMapsData") [1] ‘1.4’ > remotes::install_github("MikkoVihtakari/ggOcean") > packageVersion("ggOceanMaps") [1] ‘1.3.7’ > dt <- data.frame(lon = seq(-20, 80, length.out = 41), lat = 50:90) > dt <- dist2land(dt, cores = 1, verbose = FALSE, binary = F) > \|== \| 2%Error in h(simpleError(msg, call)) : error in evaluating the argument 'obj' in selecting a method for function 'is.projected': undefined columns selected -- > | > > When I use the argument binary=T the function works as expected, but I would like to have distance estimates instead of just True False values
MikkoVihtakari commented 1 year ago

The function has been revised in the 2.0 version of ggOceanMaps which will appear on CRAN once I have fixed all the issues:

library(ggOceanMaps);library(ggplot2)
#> Loading required package: ggplot2
#> ggOceanMaps: Setting data download folder to a temporary folder
#> /var/folders/9v/b70pd53x04d3jjmlrbcgp4_w0000gv/T//Rtmp9K3mh9. 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] '2.0.0'

dt <- data.frame(lon = seq(-20, 80, length.out = 41), lat = 50:90)
dt <- dist2land(dt)
#> Used lon and lat as input coordinate column names in data
#> Using DecimalDegree as land shapes.
#> Calculating distances...
#> Returning great circle spherical distances from land as kilometers.
qmap(dt, color = ldist) + scale_color_viridis_c()

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

You can try the new version here: https://github.com/MikkoVihtakari/ggOceanMaps/tree/sf-version

Please reopen if the issue remains in the new version.