-
Notifications
You must be signed in to change notification settings - Fork 3
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
Can throw=false
be the default when using in
?
#11
Comments
in
?throw=false
be the default when using in
?
Would you also consider to add a function that would allow to test a tuple of longitude, latitude (without creating a Point2) to be inside a GeoRegion? For example: # in addition to this:
A = Point2(-20,5)
geo = GeoRegion("AR6_EAO")
A in geo
# allow a tuple of lon/lat
(-20,5) in geo
# currenly a "no method" error Defining the following method would suffice: import Base: in
Base.in(lonlat::NTuple{2,T},geo::PolyRegion) where T<:Number = in(Point2(lonlat...),geo,throw=false)
(-20,5) in geo
# returns true With this additional method one could in future combine GeoRegions and CommonDataModel.select: name = "AR6_EAO"
geo_EAO = GeoRegion(name)
# local example file with the 2D global surface topography
fname = "/home/abarth/workspace/divaonweb-test-data/DivaData/Global/gebco_30sec_2.nc"
ds = NCDataset(fname);
v = ds["bat"];
# similar to filter(in(1:3),1:10)
v_in = geo_select(v,(:lon,:lat) => in(geo_EAO))
# selecting the data outside of an area is similar easy
# similar to filter(!in(1:3),1:10)
v_out = geo_select(v,(:lon,:lat) => !in(geo_EAO)) The function All this would work without making NCDatasets or CommonDataModel explicitly dependent on GeoRegions. |
Hi @Alexander-Barth, currently away for a workshop, so that's why I haven't gotten back yet. But the changes look interesting. I think it should be easy to incorporate them, but I will think about setting |
Thanks for looking into it. (Note that |
Hi @Alexander-Barth, I think that it has been implemented, you are free to check! Also, there are major breaking changes to v7 onwards (I took out |
Great, thanks a lot @natgeo-wong ! |
This is a follow-up to the PR: #8
In julia
1 in 3:10
(or1 in 3..10
for IntervalSets.jl) just returnsfalse
, while in GeoRegions (current main version), it returns an error:Error message:
Would you reconsider to change the default of throw to
false
here?https://github.com/JuliaClimate/GeoRegions.jl/blob/main/src/isin/isingeoregion.jl#L26
As far as I know, this feature is not released yet, so we would not break any user code.
This would help to more easily integrate GeoRegions.jl with NCDatasets/CommonDataModel.
Thanks again for this nice package!
PS: I can make a PR with a test for this change :-)
The text was updated successfully, but these errors were encountered: