This function creates a water mask for maps with geolight_map already run.
The mask is based on coastline data from Natural Earth and is stored as
map$mask_water as a boolean matrix where TRUE indicates water and
FALSE indicates land.
A pixel is marked as land if any land exists within it (using the conservative
touches=TRUE approach in rasterization), which is important for detecting small
islands; the mask then flags the remaining pixels as water.
Arguments
- map
a GeoPressureR
mapobject fromgeolight_map.- ne_scale
Natural Earth resolution passed to
rnaturalearth::ne_countries(scale = ...). Valid values are"small","medium","large"orc(110, 50, 10). Default is"medium".- land_threshold
Numeric threshold used to classify pixels as water from the rasterized land fraction. Pixels with land fraction at or below
land_thresholdare marked as water. Use0for a conservative mask where any land in a pixel makes it land.
Details
The coastline data is rasterized to match the map's grid (defined by extent and
scale from the map). land_threshold controls how much land can be present
in a pixel before it is treated as land in map$mask_water. For "large"/10
resolution, rnaturalearthhires is used by rnaturalearth when available.
See also
Other map:
map_create(),
print.map(),
rast.map()
Examples
if (FALSE) {
withr::with_dir(system.file("extdata", package = "GeoPressureR"), {
tag <- tag_create("18LX", quiet = TRUE) |>
tag_label(quiet = TRUE) |>
tag_set_map(
extent = c(-16, 23, 0, 50),
scale = 4,
known = data.frame(
stap_id = 1,
known_lon = 17.05,
known_lat = 48.9
)
) |>
twilight_create() |>
twilight_label_read() |>
geolight_map(quiet = TRUE)
# Create water mask
tag$map_light <- map_add_mask_water(tag$map_light)
# View the mask
image(tag$map_light$mask_water)
})
}
