PIK-LPJmL / LandInG

The Land Input Generator (LandInG) contains a collection of scripts to derive basic input datasets for terrestrial ecosystem models from diverse and partially conflicting data sources.
https://doi.org/10.5194/gmd-16-3375-2023
GNU Affero General Public License v3.0
7 stars 1 forks source link

Error: Code assignment #4

Closed AdrienDams closed 3 months ago

AdrienDams commented 4 months ago

I am trying to run GADM with the default grid and the last GADM files (4.10).

While running 6_map_districts_to_grid_collection.R, I have this error:

The following region codes in level_df could not be found in region_list: ‘NA’, ‘NA’, ‘NA’, ‘NA’, ‘NA’, ‘NA’, ‘NA’, ‘NA’, ‘NA’

The following district codes in level_df could not be found in district_list: ‘NA’, ‘NA’, ‘NA’, ‘NA’, ‘NA’, ‘NA’, ‘NA’, ‘NA’, ‘NA’, ‘Z06.6_1’, ‘Z06.6_1’, ‘Z06.6_1’, ‘Z06.6_1’, ‘Z06.6_1’, ‘Z06.6_1’, ‘Z06.6_1’, ‘Z06.6_1’, ‘Z06.6_1’, ‘Z06.6_1’, ‘Z06.6_1’, ‘Z06.6_1’, ‘Z02.28_1’, ‘Z06.6_1’, ‘Z06.6_1’, ‘Z06.6_1’, ‘Z06.6_1’, ‘Z06.6_1’, ‘Z06.6_1’, ‘Z06.6_1’, ‘Z06.6_1’, ‘Z03.28_1’, ‘Z03.28_1’, ‘Z03.28_1’, ‘Z06.6_1’, ‘Z06.6_1’, ‘Z06.6_1’, ‘Z06.6_1’, ‘Z06.6_1’, ‘Z06.6_1’, ‘Z06.6_1’, ‘Z01.14_1’, ‘Z03.28_1’, ‘Z03.28_1’, ‘Z03.28_1’, ‘Z03.28_1’, ‘Z01.14_1’, ‘Z06.1_1’, ‘Z06.6_1’, ‘Z06.6_1’, ‘Z06.6_1’, ‘Z01.14_1’, ‘Z01.14_1’, ‘Z01.14_1’, ‘Z01.14_1’, ‘Z03.28_1’, ‘Z03.28_1’, ‘Z03.28_1’, ‘Z06.1_1’, ‘Z01.14_1’, ‘Z01.14_1’, ‘Z01.14_1’, ‘Z01.14_1’, ‘Z01.14_1’, ‘Z01.14_1’, ‘Z01.14_1’, ‘Z01.14_1’, ‘Z01.14_1’, ‘Z01.14_1’, ‘Z03.29_1’, ‘Z06.1_1’, ‘Z01.14_1’, ‘Z01.14_1’, ‘Z01.14_1’, ‘Z01.14_1’, ‘Z01.14_1’, ‘Z01.14_1’, ‘Z01.14_1’, ‘Z01.14_1’, ‘Z01.14_1’, ‘Z01.14_1’, ‘Z06.1_1’, ‘Z01.14_1’, ‘Z01.14_1’, ‘Z01.14_1’, ‘Z01.14_1’, ‘Z01.14_1’, ‘Z01.14_1’, ‘Z01.14_1’, ‘Z01.14_1’, ‘Z01.14_1’, ‘Z01.14_1’, ‘Z01.14_1’, ‘Z01.14_1’, ‘Z01.14_1’, ‘Z01.14_1’, ‘Z01.14_1’, ‘Z01.14_1’, ‘Z07.3_1’, ‘Z07.3_1’, ‘Z07.3_1’, ‘Z07.3_1’, ‘Z07.3_1’, ‘Z07.3_1’, ‘Z07.3_1’, ‘Z07.3_1’, ‘Z07.3_1’, ‘Z07.3_1’, ‘Z07.3_1’, ‘Z07.3_1’, ‘Z07.3_1’, ‘Z07.3_1’, ‘Z07.3_1’, ‘Z07.3_1’, ‘Z07.3_1’, ‘Z07.3_1’, ‘Z07.3_1’, ‘Z07.3_1’, ‘Z07.3_1’, ‘Z07.3_1’, ‘Z07.3_1’, ‘Z07.3_1’, ‘Z07.3_1’, ‘Z07.3_1’, ‘CHN.HKG’, ‘CIV.14_1’, ‘NA’, ‘NA’, ‘NA’, ‘NA’, ‘NA’, ‘NA’

Error: Code assignment

Should I ignore it? I didn't get any error messages in the previous steps (using sf_use_s2(FALSE))

sostberg commented 4 months ago

The error means that the script has not finished successfully. The files created by step 6 are used in other parts of LandInG to create land-use related inputs. If you do not plan on creating these land-use related inputs you can ignore the error. However, if you plan to create land-use related inputs you will need to finish step 6 successfully.

sostberg commented 3 months ago

I have done a test run using GADM 4.1 and can reproduce your error. The problem seem to be at least some problems with the GADM data. There are polygons with missing attributes. For example, in Great Britain there are polygons that have a NAME_1, GID_2 and NAME_2 attribute, but no GID_1 attribute. Or there are polygons with a GID_2 attribute but no corresponding NAME_2 attribute. Or polygons with GID_1 and GID_2 but without NAME_1 and NAME_2. There are probably similar inconsistencies for other countries as well.

These errors lead to various assignment errors in the step-6 script. I need to investigate how to work around these problems in GADM but I do not really have time for that at the moment.

You could try if you can get the process to finish with an earlier version of GADM. I have used GADM 3.6 during the development. I have not tested GADM 4.0, which is also available on the GADM website.

Ideally, the GADM team would fix these errors on their side so that LandInG does not need work-arounds.

AdrienDams commented 3 months ago

Everything is working fine with GADM 3.6.

I am closing this issue, feel free to reopen it if you found a solution for newer versions.