ETC centers are spatially contiguous but possibly nested (center-B may be wholly enclosed with center-A).
IMERG features are not always spatially contiguous (i.e., disjoint), but are never nested or overlapping.
The spatial relationship between contemporaneous ETC centers and IMERG features is thus Many-to-Many:
A relationship between sets (dataframes) with two properties:
Members of one set (dataframe row) can potentially link to any member (row) of the other set.
a. Each ETC center needs to be checked against each IMERG feature.
A member of one set (row) can potentially link to no, one or multiple members (rows) of the other set.
a. An ETC center may intersect with no, one or many IMERG features, and likewise, an IMERG feature may intersect with no, one or many ETC centers.
Example solution using placeholder data.
mcms_data = {'uci': ["uci-a", "uci-b"], 'vert_poly_geo': ["poly-a", "poly-b"], 'sids': ["sids-a", "sids-b"], 'cover': ["cover-a", "cover-b"], 'trixels': ["trixels-a", "trixels-b"]}
mcms_sdf_now = pandas.DataFrame.from_dict(mcms_data)
imerg_data = {"label": [87, 91], "sids": ["sids-87", "sids-91"], "cover": ["cover-87", "cover-91"], "trixels": ["trixels-87", "trixels-91"]}
imerg_sdf_now = pandas.DataFrame.from_dict(imerg_data)
# Merge so info about each IMERG feature is available for each ETC center (uci)
combined = mcms_sdf_now.merge(imerg_sdf_now, how='cross', suffixes=('_mcms', '_imerg'))
Now I can check the combined DF for spatial intersection between the columns "sids_mcms" and "sids_imerg" for each row, storing the intersecting SIDs (if any) in a new column "sids_st". I guess I could also make a "cover_st" and "trixels_st" column based on "sids_st" as well.
Then I can plot the ETC trixels, the full IMERG trixels or the space-time intersecting (st) IMERG trixels as required.
I know how to brute force this using loops and starepandas [stare_intersection(), to_trixels() and stare_dissolve()], but is there a simple DF set of operations to so this last part?
STAREPandas DFs restricted to the same timestamp (i.e., contemporaneous via temporal intersection).
From DFs with all timestamps:
This give something like this for each a_time:
The problem
Property differences:
The spatial relationship between contemporaneous ETC centers and IMERG features is thus Many-to-Many:
Example solution using placeholder data.
Now I can check the combined DF for spatial intersection between the columns "sids_mcms" and "sids_imerg" for each row, storing the intersecting SIDs (if any) in a new column "sids_st". I guess I could also make a "cover_st" and "trixels_st" column based on "sids_st" as well.
Then I can plot the ETC trixels, the full IMERG trixels or the space-time intersecting (st) IMERG trixels as required.
I know how to brute force this using loops and starepandas [stare_intersection(), to_trixels() and stare_dissolve()], but is there a simple DF set of operations to so this last part?