Skip to content

Fixing errors with calculating pressures  #35

Description

@jules32

Here are two errors recently encountered when running CalculateAll() during the pressures calculation, and how we troubleshooted them. Both errors were due to data layers that were missing from the layers/ folder or not registered to layers.csv because it was not obvious that the Toolbox would need them. We try to improve the ohicore code to safe-guard against these sorts of problems but as a general guide, please do not remove layers from layers.csv from the spatial or weighting categories.

1. Error in UseMethod("select_")

There are 6 pressures subcategories: pollution, alien_species, habitat_destruction, fishing_pressure, climate_change, social 
Error in UseMethod("select_") : 
  no applicable method for 'select_' applied to an object of class "NULL"

This error turned out to be due to the rgn_global layer not being registered. Adding this back to layers.csv fixed this error.

2. Error in filter_impl(.data, quo)

There are 6 pressures subcategories: pollution, alien_species, habitat_destruction, fishing_pressure, climate_change, social 
Error in filter_impl(.data, quo) : 
  Evaluation error: object 'id_num' not found.

This error was because of three layers that were not registered in layers.csv or saved to the layers/ folder:

  • element_wts_cs_km2_x_storage
  • element_wts_cp_km2_x_protection
  • element_wts_hab_pres_abs

These layers are a bit confusing (and honestly, a bit unideal), but important for goals that have data for specific elements within them (in this case, habitats). These layers exist as .csv files but are actually blank except for the headers. They are calculated from within the CS, CP, and HAB goal models in functions.R and saved as an object for calculations but not as a .csv (because they will be overwritten each time CalculateAll is run.

The error was fixed by adding these (headers-only) csv files back to the layers/ folder and registering them in layers.csv.

We have also updated ohicore to include warning messages to warn for the need for these files in the future.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions