Last active
February 15, 2018 18:09
-
-
Save mtreg/8a3780575f1570d4f889a55d8f586268 to your computer and use it in GitHub Desktop.
Import , NYC Comm Dist boundaries, Community Profiles, Join them, and Map them
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
#Import community district boundaries | |
#relies on sf package | |
#ggplot2 plotting should also work, but needs dev version to deal with sf objects | |
cds <- sf::st_read("https://data.cityofnewyork.us/resource/jp9i-3b7y.GeoJSON") | |
#import community profile data - note, you can adjust this line to select specific variables [all are imported by default as written] | |
cdprofiles <- read.csv("https://planninglabs.carto.com/api/v2/sql?format=csv&q=SELECT%20cartodb_id,the_geom,the_geom_webmercator,shared_puma,future_fp_mhhi,current_fp_mhhi,cd_tot_resunits,future_fp_resunits,future_fp_bldg,current_fp_resunits,cd_tot_bldgs,current_fp_bldg,moe_under18_rate_nyc,moe_under18_rate_boro,total_lot_area,lot_area_other_no_data,lot_area_parking,lot_area_open_space,lot_area_public_facility_institution,lot_area_transportation_utility,lot_area_industrial_manufacturing,lot_area_commercial_office,lot_area_mixed_use,lot_area_res_multifamily_elevator,lot_area_res_multifamily_walkup,lot_area_res_1_2_family_bldg,lots_total,lots_other_no_data,lots_vacant,lots_parking,lots_open_space,lots_public_facility_institution,lots_transportation_utility,lots_industrial_manufacturing,lots_commercial_office,lots_mixed_use,lots_res_multifamily_elevator,lots_res_multifamily_walkup,lots_res_1_2_family_bldg,pct_served_parks,count_public_schools,count_libraries,count_hosp_clinic,count_parks,crime_count_nyc,crime_count_boro,crime_count,pct_clean_strts_nyc,pop_11_15_acs,pop_2010,pop_2000,puma,borocd,future_fp_pop,current_fp_pop,lot_area_vacant,cb_email,cb_website,acs_tooltip,neighborhoods,son_issue_3,son_issue_2,son_issue_1,cd_son_fy2018,shared_puma_cd,cd_short_title,cd_full_title,future_fp_cost_burden,current_fp_cost_burden,future_fp_rent_burden,current_fp_rent_burden,future_fp_permortg,current_fp_permortg,future_fp_ownerocc,current_fp_ownerocc,future_fp_openspace,current_fp_openspace,future_fp_area,current_fp_area,pct_hispanic,pct_other_nh,pct_asian_nh,pct_black_nh,pct_white_nh,female_85_over,male_85_over,female_80_84,male_80_84,female_75_79,male_75_79,female_70_74,male_70_74,female_65_69,male_65_69,female_60_64,male_60_64,female_55_59,male_55_59,female_50_54,male_50_54,female_45_49,male_45_49,female_40_44,male_40_44,female_35_39,male_35_39,female_30_34,male_30_34,female_25_29,male_25_29,female_20_24,male_20_24,female_15_19,male_15_19,female_10_14,male_10_14,female_5_9,male_5_9,female_under_5,male_under_5,moe_over65_rate_nyc,over65_rate_nyc,moe_over65_rate_boro,over65_rate_boro,moe_over65_rate,over65_rate,under18_rate_nyc,under18_rate_boro,moe_under18_rate,under18_rate,moe_lep_rate_nyc,lep_rate_nyc,moe_lep_rate_boro,lep_rate_boro,moe_lep_rate,lep_rate,moe_foreign_born,pct_foreign_born,pct_lot_area_other_no_data,pct_lot_area_vacant,pct_lot_area_parking,pct_lot_area_open_space,pct_lot_area_public_facility_institution,pct_lot_area_transportation_utility,pct_lot_area_industrial_manufacturing,pct_lot_area_commercial_office,pct_lot_area_mixed_use,pct_lot_area_res_multifamily_elevator,pct_lot_area_res_multifamily_walkup,pct_lot_area_res_1_2_family_bldg,crime_per_1000_nyc,crime_per_1000_boro,crime_per_1000,pct_clean_strts_boro,pct_clean_strts,moe_hh_rent_burd_nyc,pct_hh_rent_burd_nyc,moe_hh_rent_burd_boro,pct_hh_rent_burd_boro,moe_hh_rent_burd,pct_hh_rent_burd,moe_mean_commute_nyc,mean_commute_nyc,moe_mean_commute_boro,mean_commute_boro,moe_mean_commute,mean_commute,moe_unemnployment,unemployment_nyc,moe_unemployment_boro,unemployment_boro,moe_unemployment_cd,unemployment_cd,moe_bach_deg_nyc,pct_bach_deg_nyc,moe_bach_deg_boro,pct_bach_deg_boro,moe_bach_deg,pct_bach_deg,poverty_rate_nyc,poverty_rate_boro,moe_poverty_rate,poverty_rate,pop_change_00_10,area_sqmi,acres%20FROM%20community_district_profiles&filename=Queens-7-indicators.csv") | |
## For some easier understanding of the data, data dictionary: | |
cdprofile.datadic <- read.csv("https://communityprofiles.planning.nyc.gov/data/cd_profile_data_dictionary.csv") | |
## Merge the two datasets [spatial and tabular] | |
cd.cp <- merge(cds, cdprofiles, by.x="boro_cd", by.y="borocd") | |
plot(cd.cp["pct_hh_rent_burd"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment