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 not working properly #541

Closed j-harbin closed 2 years ago

j-harbin commented 2 years ago

The following video explains the bug in subset by polygon. I've also included the code here but be mindful that it uses the locator function, which must be interactively completed.

https://user-images.githubusercontent.com/58750538/148401313-b5570760-e0bd-4880-a1cd-7eb315e03473.mp4

library(argoFloats)
library(oce)
ai <- getIndex(age=30)
index1 <- subset(ai, rectangle=list(longitude=c(110,155), latitude=c(-46,-10)))
plot(index1, bathymetry=FALSE)
a <- locator(type="l", col="red")
index2 <- subset(index1, polygon=list(longitude=a$x, latitude=a$y))
plot(index2, bathymetry=FALSE)
dankelley commented 2 years ago

Suggestion: after you do a<-locator() do dput(a). That will give you code you can include in an R file that will make for a reprex that will work for others.

j-harbin commented 2 years ago

Thanks for that tip. The new code is attached here.

library(argoFloats)
library(oce)
ai <- getIndex(age=30)
index1 <- subset(ai, rectangle=list(longitude=c(110,155), latitude=c(-46,-10)))
plot(index1, bathymetry=FALSE)
a <- list(x = c(143.130277118339, 140.09112546443, 140.496345684952, 
                143.535497338861, 147.992919764594, 152.652952300587, 152.652952300587, 
                147.587699544073, 144.143327669642), y = c(-37.7676183592338, 
                                                           -39.3776653415251, -41.8821828695338, -43.6711239609686, -44.0289121792555, 
                                                           -42.2399710878207, -38.6620889049512, -36.5153595952295, -35.9786772677991
                ))
index2 <- subset(index1, polygon=list(longitude=a$x, latitude=a$y))
plot(index2, bathymetry=FALSE)
dankelley commented 2 years ago

code from our zcall

library(argoFloats)
library(oce)
par(mfrow=c(1,2), mar=c(2,2,1,1))
ai <- getIndex(age=30)
index1 <- subset(ai, rectangle=list(longitude=c(110,155), latitude=c(-46,-10)))
plot(index1, bathymetry=FALSE, col=1, pch=20,cex=1/4)
a <- list(x = c(143.130277118339, 140.09112546443, 140.496345684952, 
                143.535497338861, 147.992919764594, 152.652952300587, 152.652952300587, 
                147.587699544073, 144.143327669642), y = c(-37.7676183592338, 
                                                           -39.3776653415251, -41.8821828695338, -43.6711239609686, -44.0289121792555, 
                                                           -42.2399710878207, -38.6620889049512, -36.5153595952295, -35.9786772677991
                ))
lines(a$x,a$y,col=2)
index2 <- subset(index1, polygon=list(longitude=a$x, latitude=a$y))
plot(index2, bathymetry=FALSE, col=1, pch=20,cex=1/4)
j-harbin commented 2 years ago

Closing this issue as it is not a bug. Changing the size of the symbols made it a lot clearer to see what was going on.