Skip to content

Commit

Permalink
version 0.2.7.9001
Browse files Browse the repository at this point in the history
  • Loading branch information
choonghyunryu committed May 18, 2024
1 parent 9ce0172 commit 6c0bf02
Show file tree
Hide file tree
Showing 26 changed files with 80 additions and 33 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: bitSpatial
Type: Package
Title: Tools for Spatial Analysis in Korean Regions
Version: 0.2.7.9000
Date: 2024-05-16
Version: 0.2.7.9001
Date: 2024-05-18
Authors@R: c(
person("Choonghyun", "Ryu",, "[email protected]", role = c("aut", "cre"))
)
Expand Down
8 changes: 7 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# bitSpatial 0.2.7.9000
# bitSpatial 0.2.7.9001

## MAJOR CHANGES

Expand Down Expand Up @@ -54,6 +54,12 @@
- 상가업소번호 : 상가업소번호를 새롭게 생성하여 과거 데이터와 연계 불가
- stats_info

## BUG FIXS

* 약국수 및 병원수 집계 오류 수정. (#34).
- pharmacy_info
- hospital_info



# bitSpatial 0.2.6
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ stats_info |>
gt::as_raw_html()
```

<div id="yweqrqvbwx" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
<div id="bxseoljwam" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
&#10; <table class="gt_table" data-quarto-disable-processing="false" data-quarto-bootstrap="false" style="-webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'; display: table; border-collapse: collapse; line-height: normal; margin-left: auto; margin-right: auto; color: #333333; font-size: 16px; font-weight: normal; font-style: normal; background-color: #FFFFFF; width: auto; border-top-style: solid; border-top-width: 2px; border-top-color: #A8A8A8; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #A8A8A8; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3;" bgcolor="#FFFFFF">
<thead style="border-style: none;">
&#10; <tr class="gt_col_headings" style="border-style: none; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3;">
Expand Down
Binary file modified data/admi.rda
Binary file not shown.
Binary file modified data/cty.rda
Binary file not shown.
Binary file modified data/hospital_info.rda
Binary file not shown.
Binary file modified data/mega.rda
Binary file not shown.
Binary file modified data/pharmacy_info.rda
Binary file not shown.
Binary file modified data/population_age.rda
Binary file not shown.
Binary file modified data/post_admi.rda
Binary file not shown.
Binary file modified data/school.rda
Binary file not shown.
Binary file modified data/store_info_gyeonggi.rda
Binary file not shown.
Binary file modified data/store_info_middle.rda
Binary file not shown.
Binary file modified data/store_info_seoul.rda
Binary file not shown.
Binary file modified data/store_info_south.rda
Binary file not shown.
27 changes: 19 additions & 8 deletions inst/create_data/01_create_polygons.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ mega <- sf::read_sf(file_mega) |>
mutate(base_ym = "202306") |>
select(base_ym, mega_cd, mega_nm, land_area)

mega <- sf::st_transform(mega, 4326)

## Simplifying geospatial features
## 플로팅 속도 개선을 위해서 리아스식 해안의 복잡한 해안선을 심플하게 변경
## https://datascience.blog.wzb.eu/2021/03/15/simplifying-geospatial-features-in-r-with-sf-and-rmapshaper/
mega <- rmapshaper::ms_simplify(mega, keep = 0.001, keep_shapes = FALSE)

mega <- sf::st_transform(mega, 4326)

object.size(mega) |>
format(units = "auto")

Expand All @@ -49,13 +49,13 @@ cty <- sf::read_sf(file_cty) |>
mutate(base_ym = "202306") |>
select(base_ym, mega_cd, mega_nm, cty_cd, cty_nm, land_area)

cty <- sf::st_transform(cty, 4326)

## Simplifying geospatial features
## 플로팅 속도 개선을 위해서 리아스식 해안의 복잡한 해안선을 심플하게 변경
## https://datascience.blog.wzb.eu/2021/03/15/simplifying-geospatial-features-in-r-with-sf-and-rmapshaper/
cty <- rmapshaper::ms_simplify(cty, keep = 0.01, keep_shapes = FALSE)

cty <- sf::st_transform(cty, 4326)

object.size(cty) |>
format(units = "auto")

Expand Down Expand Up @@ -83,18 +83,17 @@ admi <- sf::read_sf(file_admi) |>
mutate(base_ym = "202306") |>
select(base_ym, mega_cd:cty_nm, admi_cd, admi_nm, land_area)

admi <- sf::st_transform(admi, 4326)

## 위경도로 읍면동을매핑하기 위해서 저장
admi_origin <- admi
save(admi_origin, file = here::here("raw", "sf", "admi_origin.rda"))
admi_origin <- admi

## Simplifying geospatial features
## 플로팅 속도 개선을 위해서 리아스식 해안의 복잡한 해안선을 심플하게 변경
## https://datascience.blog.wzb.eu/2021/03/15/simplifying-geospatial-features-in-r-with-sf-and-rmapshaper/
admi <- rmapshaper::ms_simplify(admi, keep = 0.01, keep_shapes = FALSE,
sys = TRUE, sys_mem = 15)

admi <- sf::st_transform(admi, 4326)

object.size(admi) |>
format(units = "auto")

Expand Down Expand Up @@ -182,6 +181,18 @@ admi <- admi |>
) |>
select(base_ym, mega_cd, mega_nm, cty_cd, cty_nm, admi_cd, admi_nm, land_area)

admi_origin <- admi_origin |>
select(-mega_cd, -cty_cd, -admi_cd) |>
left_join(
admi_district |>
distinct(base_ym, mega_cd, mega_nm, cty_cd, cty_nm, admi_cd, admi_nm),
by = c("base_ym", "mega_nm", "cty_nm", "admi_nm")
) |>
select(base_ym, mega_cd, mega_nm, cty_cd, cty_nm, admi_cd, admi_nm, land_area)

## 위경도로 읍면동을매핑하기 위해서 저장
save(admi_origin, file = here::here("raw", "sf", "admi_origin.rda"))


##==============================================================================
## 02.06. 지도 데이터 저장
Expand Down
35 changes: 34 additions & 1 deletion inst/create_data/04_add_school.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,42 @@ school <- fnames %>%
##==============================================================================
## 01.02. 위치정보로 행정구역 매핑하기
##==============================================================================
# load(here::here("raw", "sf", "admi_origin.rda"))

position2admi_origin <- function(x, y, proj = c("WGS84", "Bessel", "GRS80", "KATECH")) {
proj <- match.arg(proj)

if (proj != "WGS84") {
pos <- convert_projection(x, y, from = proj, to = "WGS84")

x <- pos$lon
y <- pos$lat
}

crsWGS84 <- 4326

postions <- data.frame(lon = x, lat = y)

suppressWarnings(
result <- postions %>%
st_as_sf(coords = c("lon", "lat"), crs = crsWGS84) %>%
st_intersects(admi_origin %>%
st_set_crs(crsWGS84)) %>%
as.integer() %>%
admi[., ] %>%
select(base_ym:admi_nm) %>%
st_drop_geometry()
)

postions %>%
bind_cols(
result
)
}

school <- school %>%
bind_cols(
position2admi(school$lon, school$lat) %>%
position2admi_origin(school$lon, school$lat) %>%
select(mega_cd:admi_nm)
)

Expand Down
17 changes: 8 additions & 9 deletions inst/create_data/05_add_pharmacy.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,24 @@ pharmacy <- fnames %>%
function(x) {
fname <- glue::glue("{data_path}/{x}")

pharmacy <- openxlsx::read.xlsx(fname)
pharmacy <- openxlsx::read.xlsx(fname, detectDates = TRUE)

pharmacy %>%
pharmacy |>
rename("pharmacy_nm" = 요양기관명,
"class_cd" = 종별코드,
"class_nm" = 종별코드명,
# "mega_cd" = 시도코드,
# "mega_nm" = 시도코드명,
# "cty_cd" = 시군구코드,
# "cty_nm" = 시군구코드명,
# "cty_nm" = 시군구코드명,
# "admi_nm" = 읍면동,
"post_cd" = 우편번호,
"address" = 주소,
"open_date" = 개설일자,
"lat" = `좌표(Y)`,
"lon" = `좌표(X)`) %>%
select(-암호화요양기호, -시도코드, -시도코드명, -시군구코드,
-시군구코드명, -읍면동, -전화번호) %>%
"lon" = `좌표(X)`) |>
select(-암호화요양기호, -시도코드, -시도코드명, -시군구코드,
-시군구코드명, -읍면동, -전화번호) |>
mutate(post_cd = stringr::str_pad(post_cd, 5, pad = "0"))
}
)
Expand All @@ -57,9 +57,7 @@ pharmacy <- fnames %>%
tmp <- pharmacy %>%
filter(!is.na(lon))

load(here::here("raw", "sf", "admi_origin.rda"))
admi_origin <- admi_origin %>%
st_transform(4326)
# load(here::here("raw", "sf", "admi_origin.rda"))

position2admi_origin <- function(x, y, proj = c("WGS84", "Bessel", "GRS80", "KATECH")) {
proj <- match.arg(proj)
Expand Down Expand Up @@ -125,6 +123,7 @@ pharmacy_nopos_01 <- tmp %>%
select(pharmacy_nm:lat, base_ym, mega_cd, mega_nm, cty_cd, cty_nm, admi_cd,
admi_nm, geometry)


##------------------------------------------------------------------------------
## 02.02.03. 광역시도 + 시군구 + 읍면동 조인으로 매핑하기
## 주소의 1, 2과 괄호 안의 워드를 각각 추출하여 조인
Expand Down
4 changes: 1 addition & 3 deletions inst/create_data/06_add_hospital.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@ hospital <- fnames %>%
tmp <- hospital %>%
filter(!is.na(lon))

load(here::here("raw", "sf", "admi_origin.rda"))
admi_origin <- admi_origin %>%
st_transform(4326)
# load(here::here("raw", "sf", "admi_origin.rda"))

position2admi_origin <- function(x, y, proj = c("WGS84", "Bessel", "GRS80", "KATECH")) {
proj <- match.arg(proj)
Expand Down
16 changes: 8 additions & 8 deletions inst/doc/introduce.html

Large diffs are not rendered by default.

Binary file modified man/figures/README-unnamed-chunk-11-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-5-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-6-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-7-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-8-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-9-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6c0bf02

Please sign in to comment.