Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing errors with calculating pressures #35

Open
jules32 opened this issue Sep 6, 2018 · 0 comments
Open

Fixing errors with calculating pressures #35

jules32 opened this issue Sep 6, 2018 · 0 comments

Comments

@jules32
Copy link
Contributor

jules32 commented Sep 6, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant