Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions products/knownprojects/.envrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
source_up

export BUILD_ENGINE_DB=kpdb
export DATASET=knownprojects

# Load local .env if it exists
if [ -f .env ]; then
dotenv .env
watch_file .env
fi

export BUILD_ENGINE=$(echo_build_engine)
4 changes: 3 additions & 1 deletion products/knownprojects/bash/01_dataloading.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ python3 -m python.extractors esd_projects
python3 -m python.extractors edc_projects
python3 -m python.extractors edc_dcp_inputs
python3 -m python.extractors dcp_n_study
python3 -m python.extractors dcp_n_study_future
# There are no future neighborhood studies at the momemnt
# python3 -m python.extractors dcp_n_study_future
python3 -m python.extractors dcp_n_study_projected
python3 -m python.extractors hpd_rfp
python3 -m python.extractors dcp_planneradded
python3 -m python.extractors dcp_knownprojects
python3 -m python.extractors dcp_hudsonsquare

# Load corrections tables
run_sql_file sql/create_corrections.sql
Expand Down
6 changes: 4 additions & 2 deletions products/knownprojects/python/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@
"edc_projects": "2022.11.18 EDC inputs for DCP housing projections.xlsx",
"edc_dcp_inputs": "edc_shapefile_20250225.zip",
"dcp_n_study": "nstudy_rezoning_commitments_shapefile_20250430.zip",
"dcp_n_study_future": "future_neighborhoodstudies_20250304.zip",
"dcp_n_study_projected": "past_neighborhoodstudies_20250304.zip",
# There are no future neighborhood studies at the momemnt
# "dcp_n_study_future": "future_neighborhoodstudies_20250304.zip",
"dcp_n_study_projected": "past_neighborhoodstudies_20260305.zip",
"hpd_rfp": "HPD_RFPs_20250110.xlsx",
"dcp_planneradded": "dcp_planneradded_2025_04_30.csv",
"dcp_hudsonsquare": "HudsonSquare_P2012M0255_4326.zip",
}
DCP_HOUSING_CORRECTIONS_FILENAMES = {
"corrections_dob": "corrections_dob.csv",
Expand Down
11 changes: 11 additions & 0 deletions products/knownprojects/python/extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,17 @@ def dcp_n_study_projected(filename: str) -> gpd.GeoDataFrame:
return df


@ETL
def dcp_hudsonsquare(filename: str) -> gpd.GeoDataFrame:
# df = gpd.read_file(f"zip://{RAW_DATA_PATH}/{filename}")

filename_prefix = f"{filename}".split(".")[0]
with zipfile.ZipFile(f"{RAW_DATA_PATH}/{filename}", "r") as zip_ref:
zip_ref.extractall(f"{RAW_DATA_PATH}")
df = gpd.read_file(f"{RAW_DATA_PATH}/{filename_prefix}/{filename_prefix}.shp")
return df


@ETL
def hpd_rfp(filename: str) -> pd.DataFrame:
df = pd.read_excel(f"{RAW_DATA_PATH}/{filename}", dtype=str)
Expand Down
11 changes: 11 additions & 0 deletions products/knownprojects/recipe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,24 @@ inputs:
- name: dcp_dcpprojectteams
version_env_var: ZAP_VERSION
- name: dcp_mappluto_wi
version: 25v1.1
- name: dcp_boroboundaries
version: 25a
- name: dcp_housing
version: 24Q4
- name: dcp_zoningmapamendments
version: 20250331
- name: doe_eszones
version: 20240313
- name: doe_school_subdistricts
# version: 2017
- name: dcp_school_districts
version: 25a
- name: dcp_ct2020_wi
version: 25a
- name: dcp_nta2020
version: 25a
- name: dcp_cdta2020
version: 25a
- name: dcp_cdboundaries_wi
version: 25a
5 changes: 4 additions & 1 deletion products/knownprojects/sql/combine.sql
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ _dcp_planneradded AS (
flag_senior_housing(a::text) AS senior_housing
FROM dcp_planneradded AS a
),

/* There are no future neighborhood studies at the momemnt
_dcp_n_study_future AS (
SELECT
'Future Neighborhood Studies' AS source,
Expand All @@ -189,6 +189,7 @@ _dcp_n_study_future AS (
record_nam || ' ' || 'Future Rezoning Development' AS record_name
FROM dcp_n_study_future
),
*/

_dcp_n_study_projected AS (
SELECT
Expand Down Expand Up @@ -415,6 +416,7 @@ FROM (
record_id_input,
st_makevalid(geom) AS geom
FROM _dcp_n_study
/* There are no future neighborhood studies at the momemnt
UNION
SELECT
source,
Expand All @@ -435,6 +437,7 @@ FROM (
record_id_input,
st_makevalid(geom) AS geom
FROM _dcp_n_study_future
*/
UNION
SELECT
source,
Expand Down
16 changes: 15 additions & 1 deletion products/knownprojects/sql/dcp_application.sql
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,20 @@ geom_ulurp AS (
) AS a LEFT JOIN dcp_zoningmapamendments AS zma
ON a.dcp_ulurpnumber = zma.ulurpno
GROUP BY a.record_id, a.geom
),

-- Correcting geometry for Hudson Square project (P2012M0255) while using old ZAP data
geom_corrections AS (
SELECT
a.record_id,
CASE
WHEN a.record_id = 'P2012M0255'
THEN b.geometry
ELSE a.geom
END AS geom
FROM geom_ulurp AS a
LEFT JOIN dcp_hudsonsquare AS b
ON a.record_id = b.projectid
)

-- Main table with the geometry lookup
Expand All @@ -355,5 +369,5 @@ SELECT
b.geom
INTO dcp_application
FROM _dcp_application AS a
LEFT JOIN geom_ulurp AS b
LEFT JOIN geom_corrections AS b
ON a.record_id = b.record_id;
Loading