Skip to content

Support geographic CRS via terra::cellSize() for area calculations #16

@NewGraphEnvironment

Description

@NewGraphEnvironment

Problem

drift assumes projected CRS (metre-based terra::res()) for area calculations. This blocks use on geographic CRS rasters like climate data (WorldClim, PRISM, ERA5) which ship in EPSG:4326 at coarse resolution over large extents that cross UTM zones.

#15 adds a guard that errors on geographic CRS. This issue tracks the enhancement to support it.

Proposed Solution

Use terra::cellSize() to compute true per-cell area in m² when the CRS is geographic. This handles:

  • Geographic CRS (degree-based pixels with varying area by latitude)
  • Cross-UTM-zone projected rasters (minor distortion at zone edges)

Implementation options:

  1. Auto-detect geographic CRS and switch to cellSize() internally
  2. Add a parameter (e.g., exact_area = FALSE) that users opt into for large/geographic rasters

Option 1 is more user-friendly. cellSize() adds computation but is negligible compared to STAC fetch.

Affected functions: dft_rast_transition(), dft_rast_summarize().

Context

Climate data use case: comparing last 10 years of max temp / annual precip to the preceding 65 years across large watersheds. These AOIs routinely cross UTM zones, making single-zone projection inadequate.

Relates to #15

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