Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wanted: Check data is within SOmap_auto for SOplot #98

Open
Maschette opened this issue Nov 16, 2021 · 1 comment
Open

Wanted: Check data is within SOmap_auto for SOplot #98

Maschette opened this issue Nov 16, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@Maschette
Copy link

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
Copy link
Member

raymondben commented Feb 2, 2023

Notes - this doesn't fully solve the problem:

  • in the above example, the longlat bounds returned by SOextent() are c(-175, 175, -60, -50), so point (175, -50) lies inside that extent but still won't be plotted because it's outside the plot xlim, ylim
  • point (180, -50) is outside the SOextent() and triggers a warning but will be plotted, because of the jolly gosh darned dateline issue

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants