Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: add parcel development risk #547

Open
nlebovits opened this issue Apr 19, 2024 · 0 comments
Open

Feature request: add parcel development risk #547

nlebovits opened this issue Apr 19, 2024 · 0 comments
Assignees
Labels

Comments

@nlebovits
Copy link
Collaborator

Some users are interested in the likelihood that a vacant property will be developed in the near future. We could build a model to predict this, but the number of building permits issued in the past year in the Census block group in which the parcel sits is a pretty good proxy. To that end, we should add these data in an interpretable way.

Describe the solution you'd like
We should add a count of the building permits issued per block group in the past year; classify it into high, medium, and low using Jenks breaks; and spatially join this to properties.

Describe alternatives you've considered
Alternatively, we could build some kind of predictive model for this, but that's outside the immediate scope of this project and more effort than it's worth for our purposes.

Additional context
Code to implement this is here:

import pandas as pd
import geopandas as gpd
import matplotlib.pyplot as plt
import requests
from datetime import datetime, timedelta
import jenkspy



census_bgs_url = 'https://opendata.arcgis.com/datasets/2f982bada233478ea0100528227febce_0.geojson'
census_bgs_gdf = gpd.read_file(census_bgs_url)


base_url = "https://phl.carto.com/api/v2/sql"

one_year_ago = (datetime.now() - timedelta(days=365)).strftime('%Y-%m-%d')

query = f"""
         SELECT
         permitissuedate,
         the_geom,
         ST_AsGeoJSON(the_geom)::json AS the_geom_geojson
         FROM permits
         WHERE permitissuedate >= '{one_year_ago}'
         """

response = requests.get(f"{base_url}?q={query}&format=GeoJSON")

permits_gdf = gpd.GeoDataFrame.from_features(response.json(), crs='EPSG:4326')

if census_bgs_gdf.crs != permits_gdf.crs:
    permits_gdf = permits_gdf.to_crs(census_bgs_gdf.crs)

joined_gdf = gpd.sjoin(permits_gdf, census_bgs_gdf, how="inner", op='within')

permit_counts = joined_gdf.groupby('index_right').size()

census_bgs_gdf['permit_count'] = census_bgs_gdf.index.map(permit_counts)
census_bgs_gdf['permit_count'] = census_bgs_gdf['permit_count'].fillna(0)

breaks = jenkspy.jenks_breaks(census_bgs_gdf['permit_count'], n_classes=3)
census_bgs_gdf['dev_rank'] = pd.cut(census_bgs_gdf['permit_count'],
                        bins=breaks,
                        labels=['low', 'medium', 'high'])
@nlebovits nlebovits self-assigned this Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Backlog
Development

No branches or pull requests

1 participant