AustralianAntarcticDivision / SOmap

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

Wanted: Check data is within SOmap_auto for SOplot #98

Open Maschette opened 3 years ago

Maschette commented 3 years ago

When using SOmap_auto because of the projection in some instances the points added using SOplot fall outside the plot bounds and are not plotted. It would be good if there was a way to check the window to see if it will not be plotted and give a warning.

library(SOmap)
#> Loading required package: raster
#> Loading required package: sp
#this works fine: 
SOmap_auto(x=c(175, -175), y=c(-60, -50))
#> old-style crs object detected; please recreate object with a recent sf::st_crs()
#> Warning in image.default(x = x, y = y, z = value, useRaster = useRaster, :
#> unsorted 'breaks' will be sorted before use
#This does not for the first dot 
SOplot(x=c(175, 178, -175), y=c(-50, -50, -60), col=2)
#> No projection provided, assuming longlat

Created on 2021-11-16 by the reprex package (v2.0.1)

raymondben commented 1 year ago

Notes - this doesn't fully solve the problem:

I think to solve #98 we'd have to keep the current plot extent as a polygon, and test for points in polygon. We can't just keep the projected extent of the map, because for a standard SOmap() in polar projection, the projected extent of the underlying bathy layer includes areas masked by the white mask, so those points won't be plotted. We'd have to construct the visible plot region as an extra object. For what is essentially a convenience function for the user, I am not sure it's worth the effort.