iiasa / ibis.iSDM

Modelling framework for creating Integrated SDMS
https://iiasa.github.io/ibis.iSDM/
Creative Commons Attribution 4.0 International
20 stars 2 forks source link

Unclear warning log message with `distribution()` #91

Closed jeffreyhanson closed 7 months ago

jeffreyhanson commented 7 months ago

I'm trying to fit a species distribution model using data in the projection EPSG:26917 (https://epsg.io/26917). When I initialize the model using distribution(), I see receive this output:

> ibis.iSDM::distribution(env_grid_data)
#> [Setup] 2024-01-31 10:47:12.454835 | Provide a background with a valid projection!
#> [Setup] 2024-01-31 10:47:12.470958 | Creating distribution object...
#> <Biodiversity distribution model>
#> Background extent: 
#>      xmin: 364994.676, xmax: 4656984.291,
#>      ymin: 545494.676, ymax: 4877484.291
#>    projection: +proj=utm +zone=17 +datum=NAD83 +units=m +no_defs
#>  --------- 
#> Biodiversity data:
#>    None
#>  --------- 
#>   predictors:     None
#>   priors:         <Default>
#>   latent:         None
#>   log:            <Console>
#>   engine:         <NONE>

I'm sorry, maybe I'm missing something obvious - but it's not obvious to me why this projection is not valid? Initially, I thought I must have mistakenly specified a CRS with decimal degree units instead of meters. However, that's not the case. Looking into the source code, I see this:

    # Check that provided background has a valid crs
    if(!is.na(terra::crs(background,describe=TRUE)[['code']])){
      if(getOption('ibis.setupmessages')) myLog('[Setup]','red','Provide a background with a valid projection!')
    }

My understanding is that this code would trigger this log warning (I assume red text is warning text?) if the projection has an EPSG or ESRI code? I'm sorry, I don't understand why that would be an issue. My understanding is that there are plenty of coordinate reference systems with defined EPSG/ESRI codes that are suitable for distribution modelling. Perhaps terra::is.lonlat() might be a more useful check here to throw a warning if users try do species distribution modelling on data that aren't in a projected coordinate system?

mhesselbarth commented 7 months ago

I stumbled across the same message the other day and talked to Martin about it already. In general, I as currently written the message doesn't really make sense. I also don't see why an existing ESRI code should trigger a warning?

In general, as long as there is a CRS (which is identical with alter predictors, biodiv, etc.) there shouldn't be a problem, right?

Martin-Jung commented 7 months ago

Indeed. Max, if you can push that change to the dev branch, that would be much appreciated. Sorry for the confusing warning messages.

mhesselbarth commented 7 months ago

✍️ 📓 Will do!

jeffreyhanson commented 7 months ago

No worries - thanks for the quick response!