Skip to content

Commit

Permalink
Adding ability to extract unstructured grids
Browse files Browse the repository at this point in the history
  • Loading branch information
natgeo-wong committed Jul 16, 2024
1 parent fb46565 commit e7272f4
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/extract/extract.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,36 @@ function RegionGrid(

end

function RegionGrid(
geo :: GeoRegion,
lon :: Vector{<:Real},
lat :: Vector{<:Real}
)

@info "$(modulelog()) - Creating a RegionMask for the $(geo.name) GeoRegion based on an array of longitude and latitude points"

if eltype(lon) <: AbstractFloat
FT = eltype(lon)
end

if length(lon) != length(lat)
error("$(modulelog()) - The size of the longitude and latitude arrays are not the same.")
end

mask = zeros(length(lon))

for ii in eachindex(lon)
ipnt = Point2(lon[ii],lat[ii])
if isinGeoRegion(ipnt,geo,throw=false)
mask[ii] = 1
else; mask[ii] = NaN
end
end

return RegionMask{FT}(lon,lat,mask)

end

function RectGrid(
geo :: RectRegion,
lon :: Vector{<:Real},
Expand Down

0 comments on commit e7272f4

Please sign in to comment.