Skip to content

Missing CRS on some outputs

Example on get_soil_awc:

sf <- sf::read_sf(
  system.file("extdata/study_area/test.shp", package = "RADIS")
)
# Info & Sols source (90 m raster)
awc_infosols <- get_soil_awc(sf = sf, source = "Info&Sols",
                             overlay_mode = "extent",
                             output_format = "raster")
class      : RasterLayer 
dimensions : 2, 3, 6  (nrow, ncol, ncell)
resolution : 59.99837, 44.99818  (x, y)
extent     : 770292.8, 770472.8, 6283413, 6283503  (xmin, xmax, ymin, ymax)
crs        : NA 
source     : memory
names      : layer 
values     : 67.75197, 95.77362  (min, max)

crs is NA... and it's problematic:

library(tmap)
tm_basemap("OpenStreetMap.France") + tm_shape(awc_infosols) + tm_raster()
Error in `if (isproj) ...`:
! missing value where TRUE/FALSE needed

Possible issues:

  • Soil AWC API is not sending CRS
  • get_soil_awc on Info&Sols doesn't get CRS on raster stack reading (can be solved by #44 (closed) if using terra?)

However, spatial_combination is supposed to return same CRS as the sf input mask. So it should at least warn if there is no CRS in the data input.

Edited by David Dorchies