ArgoCanada / argoFloats

Tools for analyzing collections of oceanographic Argo floats
https://argocanada.github.io/argoFloats/index.html
17 stars 7 forks source link

Subset by polygon should have an error message when only 2 lat/lon points are provided #566

Closed j-harbin closed 2 years ago

j-harbin commented 2 years ago

As shown below, if the user does the following, we get an error:

library(argoFloats)
data(index)
lonp <- c(-77.492, -78.219)
latp <- c( 26.244,  25.247)
indexPolygon <- subset(index, polygon=list(longitude=lonp, latitude=latp))
#> Error: Error in subset,argoFloats-method():
#>   polygon is invalid, because of NA

Created on 2022-04-28 by the reprex package (v2.0.1)

This is really because if a user only gives two points for a polygon, it's just a line and not possible for the polygon method to work as nothing is "inside" of the polygon.

dankelley commented 2 years ago

You might want to see why it says NA for the reason. It ought to be displaying a more useful message. If I recall correctly, we were using a function to look up the error but maybe that's being done incorrectly.

j-harbin commented 2 years ago

Done in commit 44a5e8d5aa6d7bd626c48f4e336582d7b8ee75fc of develop.