Loading and Saving Land-Sea Mask Datasets

The Land-Sea Dataset can be obtained using the function getLandSea(). See end of the page for the API

Setup

using NASAPrecipitation
using DelimitedFiles
using CairoMakie

download("https://raw.githubusercontent.com/natgeo-wong/GeoPlottingData/main/coastline_resl.txt","coast.cst")
coast = readdlm("coast.cst",comments=true)
clon  = coast[:,1]
clat  = coast[:,2]
nothing

Retrieving IMERG and TRMM Land-Sea Mask over Java

First, we must define the NASAPrecipitation datasets, and the GeoRegion of interest.

npd_imerg = IMERGDummy(path=pwd())
npd_trmm  = TRMMDummy(path=pwd())
geo  = RectRegion("JAV","GLB","Java",[-5.5,-9,115,105],savegeo=false)
The Rectilinear Region JAV has the following properties:
    Region ID    (ID) : JAV
    Parent ID   (pID) : GLB
    Name      (name)  : Java
    Bounds  (N,S,E,W) : [-5.5, -9.0, 115.0, 105.0]
        (is180,is360) : (false, true)

Then, we retrieve the IMERG LandSea Dataset

lsd_imerg = getLandSea(npd_imerg,geo)
The Land-Sea Dataset (no Topography) has the following properties:
    Longitude Points    (lon) : Float32[105.05, 105.15, 105.25, 105.35, 105.45, 105.55, 105.65, 105.75, 105.85, 105.95  …  114.05, 114.15, 114.25, 114.35, 114.45, 114.55, 114.65, 114.75, 114.85, 114.95]
    Latitude Points     (lat) : Float32[-8.95, -8.85, -8.75, -8.65, -8.55, -8.45, -8.35, -8.25, -8.15, -8.05  …  -6.45, -6.35, -6.25, -6.15, -6.05, -5.95, -5.85, -5.75, -5.65, -5.55]
    Region Size (nlon * nlat) : 100 lon points x 35 lat points

And then the TRMM LandSea Dataset

lsd_trmm  = getLandSea(npd_trmm ,geo)
The Land-Sea Dataset (no Topography) has the following properties:
    Longitude Points    (lon) : Float32[105.125, 105.375, 105.625, 105.875, 106.125, 106.375, 106.625, 106.875, 107.125, 107.375  …  112.625, 112.875, 113.125, 113.375, 113.625, 113.875, 114.125, 114.375, 114.625, 114.875]
    Latitude Points     (lat) : Float32[-8.875, -8.625, -8.375, -8.125, -7.875, -7.625, -7.375, -7.125, -6.875, -6.625, -6.375, -6.125, -5.875, -5.625]
    Region Size (nlon * nlat) : 40 lon points x 14 lat points

And we plot them below for comparison:

fig = Figure()
slon,slat = coordGeoRegion(geo)
aspect = (maximum(slon)-minimum(slon))/(maximum(slat)-minimum(slat))

ax1 = Axis(
    fig[1,1],width=750,height=750/aspect,
    title="IMERG Land-Sea Mask",ylabel="Latitude / º",
    limits=(minimum(slon)-0.5,maximum(slon)+0.5,minimum(slat)-0.5,maximum(slat)+0.5)
)
contourf!(
    ax1,lsd_imerg.lon,lsd_imerg.lat,lsd_imerg.lsm,colormap=:delta,
    levels=range(0.05,0.95,length=19),extendlow=:auto,extendhigh=:auto
)
lines!(ax1,slon,slat,linewidth=5)

ax2 = Axis(
    fig[2,1],width=750,height=750/aspect,
    title="TRMM Land-Sea Mask",xlabel="Longitude / º",ylabel="Latitude / º",
    limits=(minimum(slon)-0.5,maximum(slon)+0.5,minimum(slat)-0.5,maximum(slat)+0.5)
)
contourf!(
    ax2,lsd_trmm.lon,lsd_trmm.lat,lsd_trmm.lsm,colormap=:delta,
    levels=range(0.05,0.95,length=19),extendlow=:auto,extendhigh=:auto
)
lines!(ax2,slon,slat,linewidth=5)

resize_to_layout!(fig)
fig
Example block output

We see that, as expected, the IMERG LandSea dataset is of a higher resolution than that of TRMM, which also explains the gap between the border of the GeoRegion and the data, because in GPM IMERG and TRMM TMPA datasets, the grid edges start at [ N,S,E,W ] = [ 90,-90,360,0 ], not the grid centers.

API

GeoRegions.getLandSeaFunction
getLandSea(
    geo  :: GeoRegion = GeoRegion("GLB");
    path :: AbstractString = homedir(),
    resolution :: Int = 60,
    bedrock   :: Bool = false,
    geoid     :: Bool = false,
    returnlsd :: Bool = false,
    savelsd   :: Bool = false,
    smooth    :: Bool = false,
    σlon :: Int = 0,
    σlat :: Int = 0,
    iterations :: Int = 100,
    FT = Float32
) -> LandSea

Retrieve ETOPO 2022 data for a GeoRegion from OPeNDAP servers

Arguments

  • geo : The GeoRegion of interest

Keyword Arguments

  • path :: The path to which an ETOPO folder is created within and ETOPO LandSea data saved into
  • resolution : The resolution of the dataset to be downloaded, in units of arc-seconds. Possible values are 15, 30 and 60, default is 60.
  • bedrock, geoid : The type of ETOPO data (bedrock, geoid, ice-surface) to be downloaded. Bedrock has priority over geoid, so if both are true, the bedrock is downloaded.
  • savelsd : Save LandSea dataset into a local NetCDF file.
  • returnlsd : If savelsd = true, you can choose to simply save the data into the NetCDF file, or load return it as a LandSea dataset. Otherwise, if savelsd = false, you always return the LandSea dataset.
  • smooth : If smooth = true, then you can smooth the land-sea mask using the Gaussian Filter of ImageFiltering.jl such that the coastline (i.e. the separation between land and ocean) becomes blurred.
  • σlon : Smooth in the longitude direction (every increase of 1 in σlon roughly corresponds to 8 pixels)
  • σlat : Smooth in the latitude direction (every increase of 1 in σlat roughly corresponds to 8 pixels)
  • iterations : Iterations of gausssian smoothing, the higher, the closer the smoothing follows a semi-log. 50-100 iterations is generally enough.
source
getLandSea(
    npd :: NASAPrecipitationDataset,
    geo :: GeoRegion = GeoRegion("GLB");
    returnlsd = true,
    FT = Float32
) -> LandSea

Retrieve the Land-Sea Mask data for the NASAPrecipitationDataset specified.

Arguments

  • npd : The NASAPrecipitationDataset specified, can be either IMERG or TRMM, the function will download the relevant Land-Sea mask without needing further specification.
  • geo : The GeoRegion of interest

Keyword Arguments

  • returnlsd : If true return the data as a LandSea dataset. Otherwise, the data is simply saved into the npd.maskpath directory.
source