MikkoVihtakari / ggOceanMaps

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

Curvilinear map at lower latitudes #19

Closed h2ugo24 closed 1 year ago

h2ugo24 commented 1 year ago

Hello,

I'm no expert in map projections so this maybe some ignorance on my part. if I run basemap with limits = c(-50,0,40,60) I have a curvilinear aspect, yet if I set the limits towards south (e.g. c(-50,0,30,50)) it loses this aspect, and the warning message "PROJ support is provided by the sf and terra packages among others" does not appear. Is it possible to have a curvilinear map at lower latitudes?

Thanks in advance!

MikkoVihtakari commented 1 year ago

The projections are hardcoded (see this: https://mikkovihtakari.github.io/ggOceanMaps/articles/ggOceanMaps.html#projections), hence you cannot change the default projection without changing the package. You can clone it and change the behavior using this file, incase you want to experiment: https://github.com/MikkoVihtakari/ggOceanMaps/blob/master/R/define_shapefiles.R

Alternatively, you can use custom shapefiles and make the map you want: https://mikkovihtakari.github.io/ggOceanMaps/articles/ggOceanMaps.html#custom-shapefiles

h2ugo24 commented 1 year ago

I've noticed that the maximum longitude (in my case 10º E) defines the straight line on the right side of the plot. I would like to have the map centered on the 20ºW meridian (i.e. having this meridian as a straight line in the center of the map), keeping the projection. Is this possible?

MikkoVihtakari commented 1 year ago

You'll need to use the projected coordinates to define the limits if you want them to exact positions (or then go south enough as you suggested above to use decimal degrees instead of projected coordinates. https://mikkovihtakari.github.io/ggOceanMaps/articles/ggOceanMaps.html#limits

MikkoVihtakari commented 1 year ago

You can do:

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

basemap(c(-50,0,30,50), shapefiles = "Arctic")

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