-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #962 from CodeForPhilly/lebovits/fix-phs-propertie…
…s-flitch Fix for a glitch caused by changes to PHS data
- Loading branch information
Showing
3 changed files
with
23 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,33 @@ | ||
from classes.featurelayer import FeatureLayer | ||
from constants.services import PHS_LAYERS_TO_LOAD | ||
|
||
def phs_properties(primary_featurelayer: FeatureLayer) -> FeatureLayer: | ||
""" | ||
Perform a spatial join between the primary feature layer and the PHS properties layer, | ||
then update the primary feature layer with a new column 'phs_care_program' indicating | ||
if the property is part of the PHS care program. | ||
def phs_properties(primary_featurelayer): | ||
Args: | ||
primary_featurelayer (FeatureLayer): The primary feature layer to join with the PHS properties layer. | ||
Returns: | ||
FeatureLayer: The updated primary feature layer with the 'phs_care_program' column. | ||
""" | ||
|
||
phs_properties = FeatureLayer( | ||
name="PHS Properties", esri_rest_urls=PHS_LAYERS_TO_LOAD, cols=["BRT_ID"] | ||
name="PHS Properties", esri_rest_urls=PHS_LAYERS_TO_LOAD, cols=["program"] | ||
) | ||
|
||
phs_properties.gdf.loc[:, "phs_partner_agency"] = "PHS" | ||
|
||
primary_featurelayer.opa_join( | ||
phs_properties.gdf, | ||
"brt_id", | ||
) | ||
# Perform spatial join between primary feature layer and PHS properties | ||
primary_featurelayer.spatial_join(phs_properties) | ||
|
||
primary_featurelayer.gdf.loc[:, "phs_partner_agency"] = primary_featurelayer.gdf[ | ||
"phs_partner_agency" | ||
].fillna("None") | ||
# Initialize 'phs_care_program' column with default "no" for all rows | ||
primary_featurelayer.gdf["phs_care_program"] = "no" | ||
|
||
# Set 'phs_care_program' to "yes" for matched rows | ||
primary_featurelayer.gdf.loc[primary_featurelayer.gdf["phs_care_program"] != "no", "phs_care_program"] = "yes" | ||
|
||
# Rebuild the GeoDataFrame after updates | ||
primary_featurelayer.rebuild_gdf() | ||
|
||
return primary_featurelayer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters