Open ecophilina opened 1 month ago
Looks like conversion from NAD83 to WGS84 which will be possible (they are almost idenical anyway)
Look here: https://r-spatial.github.io/sf/reference/st_transform.html
The CRS for WGS84 is 4326 which is what's in this function I wrote for plotting the hake overview map, you can use ggplot to plot these sf objects:
sf also has functions to transform POINT to and from POLYGON data sets
Thanks Philina, I hadn't realised these were different. I can probably figure out a function for this, based on some of the conversions from Travis that I've been adapting for the new HOTSSea Salish Sea model. I'm away next week and might not have time this week, but will try.
@ecophilina For clarity, you mean you are looking for the same data format (long vs wide, with time as columns) rather than matching the same spatial resolution/pixel extents?
You can project to BC Albers (epsg 3005) or back to epsg 4326, and to rearrange the OISST data it's likely a good use for tidyr::pivot_wider()
I have functions written that extract averages for certain spatial areas from the bccm data and I would like to be able to use the same functions with oisst data. I'm assuming some kind of interpolation step would be required to get the resolutions from the point data to match the polygon grid that bccm uses?
So no, I think I do want the same spatial resolution/pixel extents as the BCCM data that is stored with the package. I realize that the original data for both differ in resolution.
Ultimately, I need to be able to project all variables to identical grids---usually as averages (though min, max, sd are also potentially useful) for polygon cells (which often later get defined by their centroid coordinates).
Can't you use what's in the OISST vignette? https://htmlpreview.github.io/?https://github.com/pbs-assess/pacea/blob/main/vignettes/oisst.html Sounds like what you want is already in there with functions.
For today, I can probably modify something from there. But it means writing a whole new function, because I need the output to match the output for the ones I wrote for the bccm data. Since, long-term I will need projected grids that are in identical formates for all variables to be used in spatial models. Converting it first to match the bccm gridded data would save a step.
I think is the way to do it (Philina, following our chat) - Kelsey did it properly for the depth data: https://github.com/pbs-assess/pacea/blob/687267f223009de25f0726aae9bbee111b3669d6/data-raw/depth/depth.R#L35
@schckngs - thanks for the pivot_wider()
tip; worked like a charm!
If the data types match (iosst is poly instead of pts) it might be enough to resolve @ecophilina's issue? Not necessarily a common grid needed.
I've done this in a new vignette oisst_to_grid26.Rmd
but haven't pushed it as it's not really a vignette (it was easier to adapt an existing vignette). Sent Philina the .rds file, which is good for now.
Could be worth trying to write those calculations as a function, which will help with #62 (or just mean that users can map OISST to any grid, and we just keep saving the values as we have been, on the original grid they come on).
I had actually pushed the .Rmd, just on the dev-andy
branch.
_full
BCCM domain.
It would be useful if there was a version of the oisst monthly data (or a conversion function to create one) that matched the format of the bccm variables. Despite overlapping in time and space, it's not obvious at the moment how one could get them into matching formats.
Currently oisst_month is:
while the bccm_surface_temperature() object is: