AustralianAntarcticDivision / SOmap

Southern Ocean round maps
https://australianantarcticdivision.github.io/SOmap/
24 stars 6 forks source link

Will `SOmap` be updated to use `sf` and `terra`? #111

Closed lidefi87 closed 8 months ago

lidefi87 commented 1 year ago

Hi there,

When installing SOmap, I noticed that it depends on sp and raster. I was wondering if there are any plans to update dependencies to sf and terra.

I am interested in this because I may be using this as part of a tutorial and I am trying to find out if it would be still good to keep this package in the content, or remove it.

Thanks!

mdsumner commented 1 year ago

uh yes, good idea I'll do this 🤘

lidefi87 commented 1 year ago

Amazing! Thanks for that 😊

mdsumner commented 1 year ago

actually it already does use sf and terra, but "it's complicated" - what actual features are most important? i.e. should we accept sf and terra objects to functions, or return them? if you could tell me which functionality you see where it should be terra I'll do that first and it might not take much.

lidefi87 commented 1 year ago

I am looking at updating this notebook here: https://github.com/SCAR/EGABIcourse19/blob/master/50_Mapping.Rmd

There is a section called SOmap showing how to use this package. One of the things it does is plot a raster over a stereographic map. Maybe it would be easier to transform SOmap outputs into ggplot objects as it is shown further down the notebook. I noticed this feature after I posted here.

mdsumner commented 1 year ago

it's going ok to accept terra objects in SOmap_auto(), SOplot(), and SOproj() - I just convert them to raster or to sf and let it go.

I think sf is already supported enough?

there were some fixes needed for the background data too which should be ok.

it's a bit of mess now, and a few things I have figured out how to do better but not sure when we'll get to a full review. Can you try out the changes with

devtools::install_github("AustralianAntarcticDivision/SOmap@terra-1")

here's how I would create that fake raster with terra:

library(terra)
xr <- rast(ext(99.875, 140.125, -65.05, -44.95), res = c(0.25, 0.1), crs= "OGC:CRS84")

xr <- setValues(temp, sqrt((xFromCell(temp, 1:ncell(temp)) - 120)^2/3 + (yFromCell(temp, 1:ncell(temp)) - -40)^2/5))

ellie <- SOmap_data$mirounga_leonina
## construct and plot the map
SOmap_auto(ellie$lon, ellie$lat)

SOmap_auto(ellie$lon, ellie$lat, input_points = FALSE, input_lines = FALSE)

SOmap_auto(xr)

SOmap_auto(xr)
my_cmap <- colorRampPalette(c("#4D4140", "#596F7E", "#168B98",
                              "#ED5B67", "#E27766", "#DAAD50", "#EAC3A6"))(51)
SOplot(xr, col = my_cmap)

SOproj() is a bit weird in that it will return a raster or sf for rast or vect, but again this should be unpicked so that a general tool handles all the formats and SOmap uses that (or something)

lidefi87 commented 1 year ago

Amazing! I am at a conference this week, but I will trying this when I get back home next week. I will let you know how it goes. Thanks!

janjansen86 commented 9 months ago

Not sure if part of this issue, or a new one, but there seems to be a SOmap dependency on rgdal, which is no longer available. Got around it by downloading and installing an archived version of rgdal...

mdsumner commented 9 months ago

oops, that's on me, will try to fix next week - happy to help with rgdal if anyone else needs

Maschette commented 8 months ago

Hey @mdsumner How did you go with this? I tried to install it for Luke Brokensha and its still throwing rgdal issues.

Cheers, Dale

mdsumner commented 8 months ago

keep prodding me I'll get to it

mdsumner commented 8 months ago

... I'll get this

mdsumner commented 8 months ago

I think this immediate need is fixed :)

There will be a broader rewrite, but there's too many balls to juggle atm.

Please submit new issues for specifics. Thanks!