-
Notifications
You must be signed in to change notification settings - Fork 13
/
Census_Data_HOLC_Polygons.py
37 lines (27 loc) · 3.76 KB
/
Census_Data_HOLC_Polygons.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# -*- coding: utf-8 -*-
"""
Generated by ArcGIS ModelBuilder on : 2021-10-01 09:46:07
"""
import arcpy
from sys import argv
def HOLC(NHGIS_Census_Boundaries, HOLC_Polygons="holc_ad_data", Output_Location="C:\\Users\\jmadron\\Documents\\ArcGIS\\Projects\\Census_HOLC\\Census_HOLC.gdb\\Intersect_Dissolve", Dissolve_Field_s_=["GISJOIN", "neighborho"], Statistics_Field_s_=[["Perc", "SUM"], ["holc_grade", "FIRST"]]): # Census Data & HOLC Polygons
# To allow overwriting outputs change overwriteOutput option to True.
arcpy.env.overwriteOutput = False
arcpy.ImportToolbox(r"c:\program files\arcgis\pro\Resources\ArcToolbox\toolboxes\Data Management Tools.tbx")
# Process: Add Fields (multiple) (Add Fields (multiple)) (management)
tracts_trim_2_ = arcpy.management.AddFields(in_table=NHGIS_Census_Boundaries, field_description=[["orig_area", "DOUBLE", "", "", "", ""], ["new_area", "DOUBLE", "", "", "", ""], ["Perc", "DOUBLE", "", "", "", ""]])[0]
# Process: Calculate Geometry Attributes (Calculate Geometry Attributes) (management)
tracts_trim_3_ = arcpy.management.CalculateGeometryAttributes(in_features=tracts_trim_2_, geometry_property=[["orig_area", "AREA_GEODESIC"]], length_unit="", area_unit="SQUARE_MILES_US", coordinate_system="PROJCS[\"USA_Contiguous_Albers_Equal_Area_Conic\",GEOGCS[\"GCS_North_American_1983\",DATUM[\"D_North_American_1983\",SPHEROID[\"GRS_1980\",6378137.0,298.257222101]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Albers\"],PARAMETER[\"False_Easting\",0.0],PARAMETER[\"False_Northing\",0.0],PARAMETER[\"Central_Meridian\",-96.0],PARAMETER[\"Standard_Parallel_1\",29.5],PARAMETER[\"Standard_Parallel_2\",45.5],PARAMETER[\"Latitude_Of_Origin\",37.5],UNIT[\"Meter\",1.0]]", coordinate_format="SAME_AS_INPUT")[0]
# Process: Intersect (Intersect) (analysis)
Intersect_3_ = "C:\\Users\\jmadron\\Documents\\ArcGIS\\Projects\\Census_HOLC\\Census_HOLC.gdb\\Intersect"
arcpy.analysis.Intersect(in_features=[[tracts_trim_2_, ""], [HOLC_Polygons, ""]], out_feature_class=Intersect_3_, join_attributes="ALL", cluster_tolerance="", output_type="INPUT")
# Process: Calculate Geometry Attributes (2) (Calculate Geometry Attributes) (management)
tracts_trim_4_ = arcpy.management.CalculateGeometryAttributes(in_features=Intersect_3_, geometry_property=[["new_area", "AREA_GEODESIC"]], length_unit="", area_unit="SQUARE_MILES_US", coordinate_system="PROJCS[\"USA_Contiguous_Albers_Equal_Area_Conic\",GEOGCS[\"GCS_North_American_1983\",DATUM[\"D_North_American_1983\",SPHEROID[\"GRS_1980\",6378137.0,298.257222101]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Albers\"],PARAMETER[\"False_Easting\",0.0],PARAMETER[\"False_Northing\",0.0],PARAMETER[\"Central_Meridian\",-96.0],PARAMETER[\"Standard_Parallel_1\",29.5],PARAMETER[\"Standard_Parallel_2\",45.5],PARAMETER[\"Latitude_Of_Origin\",37.5],UNIT[\"Meter\",1.0]]", coordinate_format="SAME_AS_INPUT")[0]
# Process: Calculate Field (Calculate Field) (management)
tracts_trim_5_ = arcpy.management.CalculateField(in_table=tracts_trim_4_, field="Perc", expression="(!new_area! / !orig_area!)", expression_type="PYTHON3", code_block="", field_type="TEXT", enforce_domains="NO_ENFORCE_DOMAINS")[0]
# Process: Dissolve (Dissolve) (management)
arcpy.management.Dissolve(in_features=Intersect_3_, out_feature_class=Output_Location, dissolve_field=Dissolve_Field_s_, statistics_fields=Statistics_Field_s_, multi_part="MULTI_PART", unsplit_lines="DISSOLVE_LINES")
if __name__ == '__main__':
# Global Environment settings
with arcpy.EnvManager(scratchWorkspace=r"C:\Users\jmadron\Documents\ArcGIS\Projects\Census_HOLC\Census_HOLC.gdb", workspace=r"C:\Users\jmadron\Documents\ArcGIS\Projects\Census_HOLC\Census_HOLC.gdb"):
HOLC(*argv[1:])