Skip to content

Latest commit

 

History

History
83 lines (60 loc) · 3.65 KB

ReadMe.md

File metadata and controls

83 lines (60 loc) · 3.65 KB

OceanBasins.jl

A set of simple functions to determine which ocean basin a (lat,lon) coordinate is in.

OceanBasins.jl essentially provides functions to algorithmically determine if a (lat,lon) coordinate lies in a specific ocean or sea. (It was developed to mask regions of interest for my personal research endeavours, i.e., global marine biogeochemical modelling with AIBECS.jl.)

Usage

To load the ocean/sea polygons, start with

OCEANS = oceanpolygons()

Note that the first time you call oceanpolygons(), it will download the Limits of oceans and seas in digitized, machine readable dataset and store it in a safe place using DataDeps.jl.

You can then test if a given lat,lon coordinate is, e.g., in the Pacific, via

ispacific(lat, lon, OCEANS)

The image at the top was produced by using ispacific-like functions (and GMT.jl for the plotting):

using Libdl
push!(Libdl.DL_LOAD_PATH, "/usr/local/Cellar/gmt/6.0.0_5/lib")
using GMT
coast(region=:d, proj=:Robinson, frame=:g, res=:crude, area=10000, land=:lemonchiffon1, water=:lightsteelblue1, figsize=12)
using OceanBasins
const OCEANS = oceanpolygons()
N = 2000
lons = 360rand(N) .- 180
lats = 180rand(N) .- 90
isocns = [ispacific, isatlantic, isindian, isarctic, ismediterranean, isantarctic] # <- these functions
colors = [sum(iocn * isocns[iocn](lat,lon,OCEANS) for iocn in 1:length(isocns)) for (lat,lon) in zip(lats,lons)]
scatter!(lons, lats, title="Which ocean basin?", marker=:c, size=0.1, zcolor=colors, show=1, savefig="demo.png")

I made this package for myself so it likely has some bugs. PRs welcome!


Warning

This package does not determine if a coordinate is on land. This is because the polygons from the Limits of oceans and seas in digitized, machine readable dataset overlap with land. For example, this

is the Atlantic basin, plotted via

coast(region=:d, proj=:Robinson, frame=:g, res=:crude, area=10000, land=:lemonchiffon1, water=:lightsteelblue1, figsize=12)
x = [P.lon for P in OCEANS[85].polygon] # Atlantic is 85th
y = [P.lat for P in OCEANS[85].polygon]
plot!(x,y, lw=1, lc=:red, title="Atlantic polygon", show=true, savefig="ATL.png")