Skip to content

Commit

Permalink
Combine raw data sources
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicwhite committed Nov 13, 2019
1 parent 7169262 commit 123efa2
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions data/transform_to_tabular.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
library(tidyverse)
library(sf)

tract_pop_raw <- read_sf('data/raw/tract_level_population.gpkg')
st_geometry(tract_nativity_raw) <- NULL
tract_nativity_raw <- read_sf('data/raw/tract_level_nativity.gpkg')
st_geometry(tract_nativity_raw) <- NULL
tract_combined <- full_join(tract_pop_raw, tract_nativity_raw, by = c("GEOID" = "GEOID"))
tract_divided <- tract_combined %>%
select(-ends_with("M")) %>%
mutate_at(vars(TotalForeignBornE:Other.Northern.AmericaE), ~.*100/TotalPopE)


planning_static <- read_csv("data/static/dc_planning_database_subset.csv",
col_types = cols(
GIDBG = col_character(),
Flag = col_integer()
))
planning_df <- planning_static %>%
separate(GIDBG, "tract_id", 11, remove=FALSE)

planning_and_pop <- full_join(planning_df, tract_divided, by = c("tract_id" = "GEOID"))


bg_pop_raw <- read_sf('data/raw/bg_level_population.gpkg')
combined_bg <- full_join(planning_and_pop, bg_pop_raw, by = c("GIDBG" = "GEOID"))

# combined_bg_sf <- st_as_sf(combined_bg)

st_write(combined_bg, "data/transformed/combined_tabular.gpkg")


Binary file added data/transformed/combined_tabular.gpkg
Binary file not shown.

0 comments on commit 123efa2

Please sign in to comment.