Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • A airGRmaps
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Issues 7
    • Issues 7
    • List
    • Boards
    • Service Desk
    • Milestones
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Analytics
    • Analytics
    • Value stream
  • Activity
  • Create a new issue
  • Issue Boards
Collapse sidebar

La forge gitlab.irstea.fr sera définitivement arrêtée le 30 juin 2026. Nous vous invitons à migrer vos projets vers la forge INRAE. Vous trouverez plus de détails sur le blog de la forge INRAE.

  • HYCAR-HydroHYCAR-Hydro
  • airGRgalaxy
  • airGRmaps
  • Issues
  • #27
Closed
Open
Issue created Mar 20, 2026 by Delaigue Olivier@olivier.delaigueOwner

Migrate spatial backend from {raster} to {terra}

The goal of this task is to replace the legacy {raster} package with the modern {terra} package to improve performance, memory management, and long-term maintainability of the application.

Key Changes

  • Data Loading (global.R): Replace raster::brick() with terra::rast() and update CRS assignment using terra::crs()
  • Spatial Operations (server.R):
    • Replace raster::crop() and raster::extent() with terra::crop() and terra::ext()
    • Switch from raster::rasterToPolygons() to terra::as.polygons()
    • Note: Use aggregate = FALSE in as.polygons() to maintain 1:1 parity with the legacy pixel-based grid
  • Coordinate Transformation: Standardize on sf::st_transform() for WGS84 (EPSG:4326) projections required by Leaflet

Implementation Logic

To ensure a safe transition, a side-by-side validation was performed using suffix 2 variables (e.g., X12, raster_tmp2) to compare:

  1. Bounding Boxes: Ensuring perfect geographic alignment
  2. Extracted Values: Verifying that parameter values match between packages

Benefits

  • Significant speed increase in polygon generation
  • Reduced memory footprint during cropping operations
  • Compatibility with modern R-Spatial standards
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking