def get_singleyr_data(fc_tripshedpoly, projtyp, analysis_year, out_dict_base={}): fc_pcl_pt = params.parcel_pt_fc_yr(analysis_year) fc_pcl_poly = params.parcel_poly_fc_yr(analysis_year) print("getting accessibility data for base...") accdata = acc.get_acc_data(fc_tripshedpoly, params.accdata_fc, projtyp, get_ej=False) print("getting ag acreage data for base...") ag_acres = GetLandUseArea(fc_tripshedpoly, projtyp, fc_pcl_poly).get_lu_acres(params.lutype_ag) # total job + du density (base year only, for state-of-good-repair proj eval only) print("getting ILUT data for base...") job_du_dens = LandUseBuffCalcs( fc_pcl_pt, fc_tripshedpoly, projtyp, [params.col_emptot, params.col_du], params.ilut_sum_buffdist).point_sum_density() comb_du_dens = sum(list(job_du_dens.values())) job_du_dens['job_du_perNetAcre'] = comb_du_dens # get EJ data print("getting EJ data for base...") ej_data = LandUseBuffCalcs(fc_pcl_pt, fc_tripshedpoly, projtyp, [params.col_pop_ilut], params.ilut_sum_buffdist, params.col_ej_ind, case_excs_list=[]).point_sum() ej_flag_dict = { 0: "Pop_NonEJArea", 1: "Pop_EJArea" } # rename keys from 0/1 to more human-readable names ej_data = utils.rename_dict_keys(ej_data, ej_flag_dict) ej_data["Pct_PopEJArea"] = ej_data["Pop_EJArea"] / sum( list(ej_data.values())) accdata_ej = acc.get_acc_data(fc_tripshedpoly, params.accdata_fc, projtyp, get_ej=True) # EJ accessibility data ej_data.update(accdata_ej) # for base dict, add items that only have a base year value (no future year values) for d in [accdata, ag_acres, job_du_dens, ej_data]: out_dict_base.update(d) outdf = pd.DataFrame.from_dict(out_dict_base, orient='index') return outdf
def get_singleyr_data(fc_project, projtyp, adt, posted_speedlim, out_dict={}): pcl_pt_fc = p.parcel_pt_fc_yr(2016) pcl_poly_fc = p.parcel_poly_fc_yr(2016) accdata = acc.get_acc_data(fc_project, p.accdata_fc, projtyp, get_ej=False) collision_data = coll.get_collision_data(fc_project, projtyp, p.collisions_fc, adt) complete_street_score = {'complete_street_score': -1} if projtyp == p.ptype_fwy else \ cs.complete_streets_idx(pcl_pt_fc, fc_project, projtyp, posted_speedlim, p.trn_svc_fc) truck_route_pct = {'pct_proj_STAATruckRoutes': 1} if projtyp == p.ptype_fwy else \ linex.get_line_overlap(fc_project, p.freight_route_fc, p.freight_route_fc) # all freeways are STAA truck routes ag_acres = luac.get_lutype_acreage(fc_project, projtyp, pcl_poly_fc, p.lutype_ag) pct_adt_truck = {"pct_truck_aadt": -1} if projtyp != p.ptype_fwy else truck_fwy.get_tmc_truck_data(fc_project, projtyp) intersxn_data = intsxn.intersection_density(fc_project, p.intersections_base_fc, projtyp) npmrds_data = npmrds.get_npmrds_data(fc_project, projtyp) transit_data = trnsvc.transit_svc_density(fc_project, p.trn_svc_fc, projtyp) bikeway_data = bnmi.get_bikeway_mileage_share(fc_project, p.ptype_sgr) infill_status = urbn.projarea_infill_status(fc_project, p.comm_types_fc) # total job + du density (base year only, for state-of-good-repair proj eval only) job_du_dens = lu_pt_buff.point_sum_density(pcl_pt_fc, fc_project, projtyp, [p.col_emptot, p.col_du], p.ilut_sum_buffdist) comb_du_dens = sum(list(job_du_dens.values())) job_du_dens['job_du_perNetAcre'] = comb_du_dens # get EJ data ej_data = lu_pt_buff.point_sum(pcl_pt_fc, fc_project, projtyp, [p.col_pop_ilut], p.ilut_sum_buffdist, p.col_ej_ind, case_excs_list=[]) ej_flag_dict = {0: "Pop_NonEJArea", 1: "Pop_EJArea"} # rename keys from 0/1 to more human-readable names ej_data = utils.rename_dict_keys(ej_data, ej_flag_dict) ej_data["Pct_PopEJArea"] = ej_data["Pop_EJArea"] / sum(list(ej_data.values())) accdata_ej = acc.get_acc_data(fc_project, p.accdata_fc, projtyp, get_ej=True) # EJ accessibility data ej_data.update(accdata_ej) # for base dict, add items that only have a base year value (no future year values) for d in [accdata, collision_data, complete_street_score, truck_route_pct, pct_adt_truck, ag_acres, intersxn_data, npmrds_data, transit_data, bikeway_data, infill_status, job_du_dens, ej_data]: out_dict_base.update(d) outdf = pd.DataFrame.from_dict(out_dict_base, orient='index') return outdf
def get_multiyear_data(project_fc, project_type, base_df, analysis_year): ilut_val_fields = [p.col_pop_ilut, p.col_du, p.col_emptot, p.col_k12_enr, p.col_empind, p.col_persntrip_res] \ + p.ilut_ptrip_mode_fields fc_pcl_pt = p.parcel_pt_fc_yr(year) fc_pcl_poly = p.parcel_poly_fc_yr(year) fc_modelhwylinks = p.model_links_fc(year) year_dict = {} # get data on pop, job, k12 totals # point_sum(fc_pclpt, fc_project, project_type, val_fields, buffdist, case_field=None, case_excs_list=[]) ilut_buff_vals = lu_pt_buff.point_sum(fc_pcl_pt, project_fc, project_type, ilut_val_fields, p.ilut_sum_buffdist, case_field=None, case_excs_list=[]) ilut_indjob_share = {"{}_jobshare".format(p.col_empind): ilut_buff_vals[p.col_empind] / ilut_buff_vals[p.col_emptot]} ilut_buff_vals.update(ilut_indjob_share) ilut_mode_split = {"{}_share".format(modetrp): ilut_buff_vals[modetrp] / ilut_buff_vals[p.col_persntrip_res] for modetrp in p.ilut_ptrip_mode_fields} ilut_buff_vals.update(ilut_mode_split) # cleanup to remove non-percentage mode split values, if we want to keep output CSV from getting too long. # for trip_numcol in p.ilut_ptrip_mode_fields: del ilut_buff_vals[trip_numcol] # job + du total job_du_tot = {"SUM_JOB_DU": ilut_buff_vals[p.col_du] + ilut_buff_vals[p.col_emptot]} # model-based vehicle occupancy veh_occ_data = link_occ.get_linkoccup_data(project_fc, project_type, fc_modelhwylinks) # land use diversity index mix_index_data = mixidx.get_mix_idx(fc_pcl_pt, project_fc, project_type) # housing type mix housing_mix_data = lu_pt_buff.point_sum(fc_pcl_pt, project_fc, project_type, [p.col_du], p.du_mix_buffdist, p.col_housing_type, case_excs_list=['Other']) # acres of "natural resources" (land use type = forest or agriculture) nat_resources_data = urbn.nat_resources(project_fc, project_type, fc_pcl_poly, year) # combine into dict for d in [ilut_buff_vals, job_du_tot, veh_occ_data, mix_index_data, housing_mix_data, nat_resources_data]: year_dict.update(d) # make dict into dataframe df_year_out = pd.DataFrame.from_dict(year_dict, orient='index') return df_year_out
for row in cur: pclarea_inbuff_ft2 += row[0] if row[1] == lutype: lutype_intersect_ft2 += row[0] # get share of on-parcel land within buffer that is of specified land use type pct_lutype = lutype_intersect_ft2 / pclarea_inbuff_ft2 if pclarea_inbuff_ft2 > 0 else 0 # convert to acres buff_acre = pclarea_inbuff_ft2 / params.ft2acre lutype_intersect_acres = lutype_intersect_ft2 / params.ft2acre return { 'total_net_pcl_acres': buff_acre, 'net_{}_acres'.format(lutype): lutype_intersect_acres, 'pct_{}_inbuff'.format(lutype): pct_lutype } if __name__ == '__main__': arcpy.env.workspace = r'I:\Projects\Darren\PPA_V2_GIS\PPA_V2.gdb' parcel_featclass = params.parcel_poly_fc_yr( in_year=2016) # 'parcel_data_polys_2016' project_featclass = r'I:\Projects\Darren\PPA_V2_GIS\PPA_V2.gdb\Polylines_1' lutype_in = 'Agriculture' out_pcl_data = GetLandUseArea(project_featclass, params.ptype_sgr, parcel_featclass).get_lu_acres(lutype_in) print(out_pcl_data)
pct_adt_truck, ag_acres, intersxn_data, npmrds_data, transit_data, bikeway_data, infill_status, job_du_dens, ej_data ]: out_dict_base.update(d) outdf_base = pd.DataFrame.from_dict(out_dict_base, orient='index') # --------------------------------------------------------------------------------------------------------- # outputs that use both base year and future year values ilut_val_fields = [p.col_pop_ilut, p.col_du, p.col_emptot, p.col_k12_enr, p.col_empind, p.col_persntrip_res] \ + p.ilut_ptrip_mode_fields for year in analysis_years: fc_pcl_pt = p.parcel_pt_fc_yr(year) fc_pcl_poly = p.parcel_poly_fc_yr(year) fc_modelhwylinks = p.model_links_fc(year) year_dict = {} # get data on pop, job, k12 totals # point_sum(fc_pclpt, fc_project, project_type, val_fields, buffdist, case_field=None, case_excs_list=[]) ilut_buff_vals = lu_pt_buff.point_sum(fc_pcl_pt, project_fc, project_type, ilut_val_fields, p.ilut_sum_buffdist, case_field=None, case_excs_list=[]) ilut_indjob_share = { "{}_jobshare".format(p.col_empind):
nat_resource_ac = 0 # pdb.set_trace() pcl_buff_intersect = GetLandUseArea(fc_project, projtyp, fc_pcl_poly) for lutype in params.lutypes_nat_resources: lutype_ac_dict = pcl_buff_intersect.get_lu_acres(lutype) lutype_acres = lutype_ac_dict['net_{}_acres'.format(lutype)] nat_resource_ac += lutype_acres return {"nat_resource_acres": nat_resource_ac} if __name__ == '__main__': arcpy.env.workspace = r'I:\Projects\Darren\PPA_V2_GIS\PPA_V2.gdb' # input fc of parcel data--must be polygons! in_pcl_base_fc = params.parcel_poly_fc_yr(in_year=2016) # in_pcl_future_tbl = # in_ctypes_fc = # input line project for basing spatial selection project_fc = r'I:\Projects\Darren\PPA_V2_GIS\PPA_V2.gdb\Polylines_1' # infill_status_dict = projarea_infill_status(project_fc, params.comm_types_fc) # print(infill_status_dict) nat_resources_dict = nat_resources(project_fc, params.ptype_arterial, in_pcl_base_fc) print(nat_resources_dict)
def get_multiyear_data(fc_tripshedpoly, projtyp, base_df, analysis_year): print("getting multi-year data for {}...".format(analysis_year)) ilut_val_fields = [params.col_pop_ilut, params.col_du, params.col_emptot, params.col_k12_enr, params.col_empind, params.col_persntrip_res] \ + params.ilut_ptrip_mode_fields fc_pcl_pt = params.parcel_pt_fc_yr(analysis_year) fc_pcl_poly = params.parcel_poly_fc_yr(analysis_year) year_dict = {} # get data on pop, job, k12 totals # point_sum(fc_pclpt, fc_tripshedpoly, projtyp, val_fields, buffdist, case_field=None, case_excs_list=[]) ilut_buff_vals = LandUseBuffCalcs(fc_pcl_pt, fc_tripshedpoly, projtyp, ilut_val_fields, params.ilut_sum_buffdist, case_field=None, case_excs_list=[]).point_sum() ilut_indjob_share = { "{}_jobshare".format(params.col_empind): ilut_buff_vals[params.col_empind] / ilut_buff_vals[params.col_emptot] } ilut_buff_vals.update(ilut_indjob_share) ilut_mode_split = { "{}_share".format(modetrp): ilut_buff_vals[modetrp] / ilut_buff_vals[params.col_persntrip_res] for modetrp in params.ilut_ptrip_mode_fields } ilut_buff_vals.update(ilut_mode_split) # cleanup to remove non-percentage mode split values, if we want to keep output CSV from getting too long. # for trip_numcol in params.ilut_ptrip_mode_fields: del ilut_buff_vals[trip_numcol] # job + du total job_du_tot = { "SUM_JOB_DU": ilut_buff_vals[params.col_du] + ilut_buff_vals[params.col_emptot] } # land use diversity index mix_index_data = mixidx.get_mix_idx(fc_pcl_pt, fc_tripshedpoly, projtyp) # housing type mix housing_mix_data = LandUseBuffCalcs(fc_pcl_pt, fc_tripshedpoly, projtyp, [params.col_du], params.du_mix_buffdist, params.col_housing_type, case_excs_list=['Other']).point_sum() # acres of "natural resources" (land use type = forest or agriculture) nat_resources_data = urbn.nat_resources(fc_tripshedpoly, projtyp, fc_pcl_poly, analysis_year) # combine into dict for d in [ ilut_buff_vals, job_du_tot, mix_index_data, housing_mix_data, nat_resources_data ]: year_dict.update(d) # make dict into dataframe df_year_out = pd.DataFrame.from_dict(year_dict, orient='index') return df_year_out