Skip to content

cd_extract(): an area on sea cells only returns NaN without a warning #153

Open

Description

@NewGraphEnvironment

Problem

cd_extract() returns NaN with no warning for an area that falls entirely on ERA5-Land's sea cells. ERA5-Land has no values over the ocean (10,835 of the 31,581 cells in the live tmean_annual COG are NA), and cd_crop() (terra::crop(snap = "out", mask = TRUE), R/cd_crop.R:36) followed by global(mean, na.rm = TRUE) (R/cd_extract.R:77) gives NaN when every cell is NA.

Measured on the live catalog: a 0.02° polygon on Triangle Island (-129.08, 50.86) returns NaN for every year, silently. A 0.01° polygon inland near Squamish returns a value, because a polygon smaller than a cell picks up the cell it touches.

cd_extract_daily() already handles the point case: a point in a sea cell moves to the nearest land cell and is flagged cell_moved.

Proposed

Warn, naming the area, when an extract has no land cells; or follow cd_extract_daily() and take the nearest land cell, flagged. Found while reviewing the README tagline for #142.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions