Skip to content

Add support to crs "local" (recently defined in terra) #64

@aloboa

Description

@aloboa

Please add support to crs "local"
rspatial/terra#797

Given:

r <- rast(nrows=4, ncols=4)
values(r) <- 1:ncell(r)
r <- c(r,r,r)

The following works as expected:

crs(r) <- "epsg:25831"
ggplot() + geom_spatraster_rgb(data = r)
ggplot() + geom_spatraster_rgb(data = stretch(r))
crs(r) <- ""
ggplot() + geom_spatraster_rgb(data = stretch(r))
ggplot() + geom_spatraster_rgb(data = stretch(r)) + coord_fixed(ratio = 1)
ggplot() + geom_spatraster_rgb(data = stretch(r))
ggplot() + geom_spatraster_rgb(data = stretch(r)) + coord_fixed(ratio = 1)

But:

 crs(r) <- "local"
 ggplot() + geom_spatraster_rgb(data = stretch(r))
Error in CPL_transform(x, crs, aoi, pipeline, reverse, desired_accuracy,  : 
  OGRCreateCoordinateTransformation(): transformation not available
In addition: Warning message:
In CPL_transform(x, crs, aoi, pipeline, reverse, desired_accuracy,  :
  GDAL Error 6: Cannot find coordinate operations from `ENGCRS["Cartesian (Meter)",EDATUM["Local Datum"],CS[Cartesian,2],AXIS["x",east,ORDER[1],LENGTHUNIT["Meter",1]],AXIS["y",north,ORDER[2],LENGTHUNIT["Meter",1]]]' to `ENGCRS["Cartesian (Meter)",EDATUM["Local Datum"],CS[Cartesian,2],AXIS["x",east,ORDER[1],LENGTHUNIT["Meter",1]],AXIS["y",north,ORDER[2],LENGTHUNIT["Meter",1]]]'

ggplot() + geom_spatraster_rgb(data = stretch(r)) + coord_fixed(ratio = 1)
Error in `reproject_raster_on_stat()`:
! geom_spatraster_*() on SpatRasters with crs must be used with coord_sf().
Run `rlang::last_error()` to see where the error occurred.

Metadata

Metadata

Assignees

No one assigned

    Labels

    📊 ggplot2Issues related with the implementation of ggplot2 functionalities

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions