BayAreaMetro / bayarea_urbansim

Bay Area Version of the UrbanSim Model
http://bayareametro.github.io/bayarea_urbansim
13 stars 11 forks source link

Use PARCEL_ID to fix mangled geom_ids on initial read #367

Closed drewlevitt closed 5 months ago

drewlevitt commented 5 months ago

Quick update to datasources.py to overwrite the as-received geom_ids (which were mangled, probably in Excel, at some point) with freshly calculated geom_ids based on PARCEL_IDs.

Also, I didn't make these changes in utils.py but a couple things caught my eye there.

  1. Why does geom_id_to_parcel_id return a DF but parcel_id_to_geom_id returns a Series? One or the other of the function names is misleading.
  2. Another way to write parcel_id_to_geom_id would be like the following:
    def parcel_id_to_geom_id(s, parcels):
    parcel_to_geom_dict = dict(zip(parcels.index, parcels.geom_id))
    return s.map(parcel_to_geom_dict)

    I'm not sure this would work exactly as written (because I'm not sure whether orca tables have a .index attribute like pandas DataFrames do) but something like this seems cleaner than the way this function is written now.

akselx commented 5 months ago

Agree, the two should return a proper mapping or at least a series. This looks good.