-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b4e0896
commit 18285df
Showing
10 changed files
with
172 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.Rproj.user | ||
.Rhistory | ||
.RData | ||
.Ruserdata | ||
hamilton_landcover/ |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
library(tidyverse) | ||
library(sf) | ||
library(terra) | ||
|
||
hc <- cincy::county_7cc_2010 |> filter(county_name == "Hamilton") | ||
|
||
# nlcd | ||
nlcd_tif <- s3::s3_get(glue::glue("s3://geomarker/nlcd_cog/nlcd_landcover_2019.tif")) | ||
nlcd <- terra::rast(nlcd_tif) | ||
nlcd_hc_2019 <- terra::crop(nlcd, hc) | ||
terra::writeRaster(nlcd_hc_2019, "rasters/nlcd_hc_2019.tif") | ||
fs::dir_delete("s3_downloads") | ||
|
||
# impervious | ||
impervious_tif <- s3::s3_get(glue::glue("s3://geomarker/nlcd_cog/nlcd_impervious_2019.tif")) | ||
impervious <- terra::rast(impervious_tif) | ||
impervious_hc_2019 <- terra::crop(impervious, hc) | ||
terra::writeRaster(impervious_hc_2019, "rasters/impervious_hc_2019.tif") | ||
fs::dir_delete("s3_downloads") | ||
|
||
# tree canopy | ||
tree_tif <- s3::s3_get(glue::glue("s3://geomarker/nlcd_cog/nlcd_treecanopy_2016.tif")) | ||
treecanopy <- terra::rast(tree_tif) | ||
treecanopy_hc_2016 <- terra::crop(treecanopy, hc) | ||
terra::writeRaster(treecanopy_hc_2016, "rasters/treecanopy_hc_2016.tif") | ||
fs::dir_delete("s3_downloads") | ||
|
||
# evi | ||
evi_tif <- s3::s3_get(glue::glue("s3://geomarker/modis_evi_ndvi/evi_June_2018_5072.tif")) | ||
evi <- terra::rast(evi_tif) | ||
evi_hc_2018 <- terra::crop(evi, hc) | ||
terra::writeRaster(evi_hc_2018, "rasters/evi_hc_2018.tif") | ||
fs::dir_delete("s3_downloads") |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
library(tidyverse) | ||
library(sf) | ||
library(terra) | ||
library(CODECtools) | ||
source("nlcd_legend.R") | ||
|
||
tract <- terra::vect(cincy::tract_tigris_2010) | ||
|
||
# NLCD - greenspace | ||
nlcd_hc_2019 <- terra::rast("rasters/nlcd_hc_2019.tif") | ||
|
||
pct_green <- | ||
terra::extract(nlcd_hc_2019, | ||
tract) |> | ||
rename(value = Layer_1) |> | ||
left_join(nlcd_legend, by = "value") |> | ||
group_by(ID) |> | ||
summarize(pct_green_2019 = round(sum(green) / n() * 100)) |> | ||
select(-ID) | ||
|
||
tract_nlcd <- bind_cols(cincy::tract_tigris_2010, pct_green) | ||
|
||
# NLCD - impervious | ||
impervious_hc_2019 <- terra::rast("rasters/impervious_hc_2019.tif") | ||
|
||
pct_impervious <- | ||
terra::extract(impervious_hc_2019, | ||
tract, | ||
fun = "mean") |> | ||
rename(value = Layer_1) |> | ||
summarize(pct_impervious_2019 = round(value)) | ||
|
||
tract_nlcd <- bind_cols(tract_nlcd, pct_impervious) | ||
|
||
# NLCD - treecanopy | ||
treecanopy_hc_2016 <- terra::rast("rasters/treecanopy_hc_2016.tif") | ||
|
||
pct_treecanopy <- | ||
terra::extract(treecanopy_hc_2016, | ||
tract, | ||
fun = "mean") |> | ||
rename(value = Layer_1) |> | ||
summarize(pct_treecanopy_2016 = round(value)) | ||
|
||
tract_nlcd <- bind_cols(tract_nlcd, pct_treecanopy) | ||
|
||
# EVI | ||
evi_hc_2018 <- terra::rast("rasters/evi_hc_2018.tif") | ||
|
||
evi <- | ||
terra::extract(evi_hc_2018, | ||
tract, | ||
fun = "mean", | ||
na.rm = TRUE) |> | ||
rename(evi_2018 = evi_June_2018_5072) |> | ||
mutate(evi_2018 = round(evi_2018 * 0.0001, 4)) |> | ||
select(-ID) | ||
|
||
tract_nlcd <- bind_cols(tract_nlcd, evi) | ||
tract_nlcd <- sf::st_drop_geometry(tract_nlcd) | ||
|
||
tract_nlcd <- tract_nlcd |> | ||
add_attrs( | ||
name = "hamilton_landcover", | ||
title = "Hamilton County Landcover and Built Environment Characteristics", | ||
version = "0.1.0", | ||
homepage = "https://geomarker.io/hamilton_landcover" | ||
) | ||
|
||
tract_nlcd <- | ||
tract_nlcd |> | ||
add_col_attrs(census_tract_id, title = "Census Tract Identifier") |> | ||
add_col_attrs(pct_green_2019, title = "Percent Greenspace 2019", description = "percent of pixels in each tract classified as green") |> | ||
add_col_attrs(pct_impervious_2019, title = "Percent Impervious 2019", description = "average percent imperviousness for pixels in each tract") |> | ||
add_col_attrs(pct_treecanopy_2016, title = "Percent Treecanopy 2016", description = "average percent tree canopy for pixels in each tract") |> | ||
add_col_attrs(evi_2018, title = "Enhanced Vegetation Index 2018", description = "average enhanced vegetation index for pixels in each tract") | ||
|
||
tract_nlcd <- add_type_attrs(tract_nlcd) | ||
|
||
# write metadata.md | ||
cat("#### Metadata\n\n", file = "metadata.md", append = FALSE) | ||
CODECtools::glimpse_attr(tract_nlcd) |> | ||
knitr::kable() |> | ||
cat(file = "metadata.md", sep = "\n", append = TRUE) | ||
|
||
cat("\n#### Schema\n\n", file = "metadata.md", append = TRUE) | ||
tract_nlcd |> | ||
CODECtools::glimpse_schema() |> | ||
knitr::kable() |> | ||
cat(file = "metadata.md", sep = "\n", append = TRUE) | ||
|
||
write_tdr_csv(tract_nlcd) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#### Metadata | ||
|
||
|name |value | | ||
|:--------|:---------------------------------------------------------------| | ||
|name |hamilton_landcover | | ||
|version |0.1.0 | | ||
|title |Hamilton County Landcover and Built Environment Characteristics | | ||
|homepage |https://geomarker.io/hamilton_landcover | | ||
|
||
#### Schema | ||
|
||
|name |title |type |description | | ||
|:-------------------|:------------------------------|:------|:----------------------------------------------------------| | ||
|census_tract_id |Census Tract Identifier |string |NA | | ||
|pct_green_2019 |Percent Greenspace 2019 |number |percent of pixels in each tract classified as green | | ||
|pct_impervious_2019 |Percent Impervious 2019 |number |average percent imperviousness for pixels in each tract | | ||
|pct_treecanopy_2016 |Percent Treecanopy 2016 |number |average percent tree canopy for pixels in each tract | | ||
|evi_2018 |Enhanced Vegetation Index 2018 |number |average enhanced vegetation index for pixels in each tract | |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
nlcd_legend <- | ||
tibble::tribble( | ||
~value, ~landcover_class, ~landcover, ~green, | ||
11, "water", "water", FALSE, | ||
12, "water", "ice/snow", FALSE, | ||
21, "developed", "developed open", TRUE, | ||
22, "developed", "developed low intensity", TRUE, | ||
23, "developed", "developed medium intensity", FALSE, | ||
24, "developed", "developed high intensity", FALSE, | ||
31, "barren", "rock/sand/clay", FALSE, | ||
41, "forest", "deciduous forest", TRUE, | ||
42, "forest", "evergreen forest", TRUE, | ||
43, "forest", "mixed forest", TRUE, | ||
51, "shrubland", "dwarf scrub", TRUE, | ||
52, "shrubland", "shrub/scrub", TRUE, | ||
71, "herbaceous", "grassland", TRUE, | ||
72, "herbaceous", "sedge", TRUE, | ||
73, "herbaceous", "lichens", TRUE, | ||
74, "herbaceous", "moss", TRUE, | ||
81, "cultivated", "pasture/hay", TRUE, | ||
82, "cultivated", "cultivated crops", TRUE, | ||
90, "wetlands", "woody wetlands", TRUE, | ||
95, "wetlands", "emergent herbaceous wetlands", TRUE | ||
) |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.