-
Notifications
You must be signed in to change notification settings - Fork 1
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
113075c
commit 9a53e01
Showing
30 changed files
with
2,107 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
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,83 @@ | ||
# cleaning data for assignment 1 | ||
|
||
library(tidyterra) | ||
library(tidyverse) | ||
library(terra) | ||
|
||
# load previous shapefile for projection | ||
temp <- vect("/Users/Josh/Dropbox/KDIS/Classes/geospatialdataR/week4files/kgrid.shp") | ||
|
||
|
||
# load geojson of provinces | ||
do <- vect("/Users/Josh/Downloads/skorea-provinces-2018-geo.json") | ||
do <- do |> filter(name_eng=="Seoul") | ||
do <- do |> dplyr::select(province = name_eng) | ||
do <- project(do, crs(temp)) | ||
|
||
# gu | ||
gu <- vect("/Users/Josh/Downloads/skorea-municipalities-2018-geo.json") | ||
gu <- gu |> select("name_eng") | ||
gu <- project(gu, crs(temp)) | ||
gu <- intersect(gu, do) | ||
gu <- aggregate(gu, "name_eng") | ||
writeVector(gu, "data/seoulgu.shp", overwrite = TRUE) | ||
|
||
# create grid | ||
grid <- rast(do, res=100) | ||
grid <- as.polygons(grid) | ||
grid$id <- 1:nrow(grid) | ||
grid <- intersect(grid, do) | ||
grid <- aggregate(grid, "id") | ||
# pop raster | ||
pop <- rast("/Users/Josh/Downloads/kor_ppp_2020_constrained.tif") | ||
pop <- project(pop, crs(temp)) | ||
# extract | ||
grid$pop <- round(extract(pop["kor_ppp_2020_constrained"], grid, fun = "mean", na.rm = TRUE, method = "bilinear", ID = FALSE), 0) | ||
writeVector(grid, "data/seoulgrid.shp", overwrite = TRUE) | ||
|
||
|
||
|
||
# Load rail stations | ||
transport <- vect("/Users/Josh/Downloads/south-korea-latest-free.shp/gis_osm_transport_free_1.shp") | ||
transport <- transport |> filter(fclass=="railway_station") | ||
transport <- project(transport, crs(temp)) | ||
transport <- intersect(transport, do) | ||
transport <- project(transport, "EPSG:4326") | ||
writeVector(transport, "data/seoulrail.shp", overwrite = TRUE) | ||
|
||
|
||
|
||
# points of interest | ||
points <- vect("/Users/Josh/Downloads/south-korea-latest-free.shp/gis_osm_pois_a_free_1.shp") | ||
points <- points |> filter(fclass %in% c("hospital", "supermarket", "school")) | ||
points$fclass[grep("초등학교", points$name)] <- "elementaryschool" | ||
points$fclass[grep("중학교", points$name)] <- "middleschool" | ||
points$fclass[grep("고등학교", points$name)] <- "highschool" | ||
points <- points |> select(-c("osm_id", "name")) | ||
points <- project(points, crs(temp)) | ||
points <- intersect(points, do) | ||
points <- project(points, "EPSG:4326") | ||
# get lon/lat | ||
points$lon <- geom(points)[,"x"] | ||
points$lat <- geom(points)[,"y"] | ||
# remove geometry | ||
points <- as_tibble(points) | ||
write_csv(points, "data/seoulpoints.csv") | ||
|
||
|
||
|
||
# water | ||
water <- vect("/Users/Josh/Downloads/south-korea-latest-free.shp/gis_osm_water_a_free_1.shp") | ||
water <- project(water, crs(temp)) | ||
water <- intersect(water, do) | ||
water <- aggregate(water, "osm_id") | ||
writeVector(water, "data/seoulwater.shp", overwrite = TRUE) | ||
|
||
ggplot() + | ||
geom_spatvector(data = water, fill = "blue") + | ||
geom_spatvector(data = gu, fill = NA) | ||
|
||
|
||
|
||
|
||
|
Binary file not shown.
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 @@ | ||
UTF-8 |
Binary file not shown.
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 @@ | ||
PROJCS["Korea_2000_Korea_Unified_Coordinate_System",GEOGCS["GCS_Korea_2000",DATUM["D_Korea_2000",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",1000000.0],PARAMETER["False_Northing",2000000.0],PARAMETER["Central_Meridian",127.5],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",38.0],UNIT["Meter",1.0]] |
Binary file not shown.
Binary file not shown.
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 @@ | ||
UTF-8 |
Binary file not shown.
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 @@ | ||
PROJCS["Korea_2000_Korea_Unified_Coordinate_System",GEOGCS["GCS_Korea_2000",DATUM["D_Korea_2000",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",1000000.0],PARAMETER["False_Northing",2000000.0],PARAMETER["Central_Meridian",127.5],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",38.0],UNIT["Meter",1.0]] |
Binary file not shown.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
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 @@ | ||
UTF-8 |
Binary file not shown.
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 @@ | ||
GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]] |
Binary file not shown.
Binary file not shown.
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 @@ | ||
UTF-8 |
Binary file not shown.
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 @@ | ||
PROJCS["Korea_2000_Korea_Unified_Coordinate_System",GEOGCS["GCS_Korea_2000",DATUM["D_Korea_2000",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",1000000.0],PARAMETER["False_Northing",2000000.0],PARAMETER["Central_Meridian",127.5],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",38.0],UNIT["Meter",1.0]] |
Binary file not shown.
Binary file not shown.
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,6 @@ | ||
|
||
\definecolor{kdisgreen}{RGB}{0, 99, 52} | ||
\definecolor{kdisplatinum}{RGB}{167, 169, 172} | ||
|
||
|
||
|
Binary file not shown.
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,38 @@ | ||
--- | ||
title: | | ||
| In-class lab 1 | ||
subtitle: | | ||
| Geospatial analysis in R | ||
| KDI School Fall 2024 | ||
# Output type and options (no TOC and yes fig captions) | ||
format: | ||
pdf: | ||
toc: false | ||
|
||
# This includes latex arguments | ||
header-includes: | ||
- \input{header.tex} | ||
|
||
--- | ||
|
||
You can find all of the data in the assignments/in-class1/data folder. The datasets are: | ||
|
||
- seoulgrid.shp: a grid of 100m x 100m cells covering Seoul | ||
- seoulgu.shp: the administrative districts (gu/구) of Seoul | ||
- seoulrail.shp: the rail stations in Seoul | ||
- seoulwater.shp: the water bodies in Seoul | ||
- seoulpoints.csv: points of interest in Seoul | ||
|
||
By the end of class, you need to turn in a raw markdown file AND the pdf output. Please make sure ALL STUDENTS' names are on the assignment. Here are your tasks for today: | ||
|
||
- Let's start easy. The grid shapefile has a variable in it: estimated population in the grid cell (from [WorldPop](https://www.worldpop.org/)). Load the grid shapefile and plot the population distribution in Seoul. Please make the map look nice. | ||
- You'll notice there are a lot of grid cells with missing values. Please write what you think might be going on there. | ||
- Next, filter out any grid cells that are majority water. Plot the population distribution in Seoul again. | ||
- Please write what you think the missing values are again. | ||
- I forgot to put the Gu identifier into the grid cells. Please add that using the seoulgu.shp file. | ||
|
||
|
||
|
||
|
||
|
||
|