Grist-Data-Desk / land-grab-2

Code and methodology to produce the dataset in Grist's Misplaced Trust investigation
https://grist.org/project/indigenous/land-grant-universities-indigenous-lands-fossil-fuels
Creative Commons Zero v1.0 Universal
14 stars 2 forks source link

fix: One-off edit to perform "correct" (I hope) translations of activities. #57

Closed parkerziegler closed 9 months ago

parkerziegler commented 9 months ago

A bit of a clunker of a PR, but I believe it gets the job done. The crux of debugging this issue lied in pursuing a deeper exploration of translate_state_activity_code. In the cases of AZ, MT, and WA, passing the value of activity.name as the activity_name argument is important; for those states, activity.name will correspond to one of the keys in AZ_KEY, MT_KEY, and WA_KEY, respectively (for certain Shapefiles). For WI, however, we need to pass the value of appendage_col_value, since translation of state codes occurs on this secondary column.

In short, I think a huge source of the issues in this area of the codebase is that WI performs the translation on the values in the appendage column, not the primary activity column. In fact, it's the only state satisfying both of the following criteria:

  1. Has configs with use_name_ as_activity=True and non-None activity_name_appendage_col.
  2. Has a lookup table for translating state codes.

WI's persistent problems also probably made it easier for us to think the problem was fixed once WI's values looked correct. With this change, we start to see positive signs of correction:

I also verified the AZ and MT lookups are appearing as expected.