key請由課綱選: 新課綱:https://docs.google.com/document/d/1o8UQIpy6GFqCgfUxc47fqyAPuEYrk3FLd7bB1EhYMVg

knitr::opts_chunk$set(echo = TRUE, eval=F)
library(drake)
library(econDV)
library(dplyr)

makecondition

library(dplyr)
library(tidyr)
library(stringr)
library(googledrive)
library(readr)
library(ggplot2)
library(econDV)
econDV::setup_chinese(need2Knit = F)
rprojroot::is_rstudio_project -> .pj
.pj$make_fix_file() -> .root

imageFolder <- file.path(.root(),"img")
dataFolder <- file.path(.root(),"data")

if(!dir.exists(imageFolder)) dir.create(imageFolder)
if(!dir.exists(dataFolder)) dir.create(dataFolder)
# xfun::download_file("https://www.dropbox.com/s/7b3nbgfx5bgft8g/drake_annotationmaps.Rdata?dl=1")
# load("drake_annotationmaps.Rdata")

xfun::download_file("https://www.dropbox.com/s/8ndtvzqbdb4cb93/data_visulaization_pk.R?dl=1")
source("data_visulaization_pk.R", encoding = "UTF-8")
library(osmdata)
osmdata::getbb("new taipei") -> newTaipeiBBox
newTaipeiBBox
newTaipeiBBox <- c(xmin=121.28263, xmax=122.00640, ymin=24.67316, ymax=25.29974)
ntputBBox <- c(xmin=121.3621,
               xmax=121.3740,
               ymin=24.9383,
               ymax=24.9484)

Features

OPQ instance

opq_newTaipei <- 
  opq(newTaipeiBBox)
opq_ntpu <- 
  opq(ntputBBox)

add features

osmdata::available_features()
stringr::str_subset(osmdata::available_features(), "boundary|admin")
osmdata::add_osm_feature(
  opq_newTaipei,
  "admin_level", "5"
) -> osmTaipei
osmdata_sf(osmTaipei) -> dsf_newTaipei
dsf_newTaipei <- {

  osmdata::getbb("new taipei") -> bbox_ntp

  osmdata::opq(bbox_ntp) -> 
    opq_ntp

  osmdata::add_osm_feature(
    opq_ntp,
    key="admin_level",
    value="5"
  )  -> request_ntp

  osmdata::osmdata_sf(
    request_ntp
  )
}
dsf_newTaipei <- {

  osmdata::getbb("new taipei") %>%
  osmdata::opq() %>%
  osmdata::add_osm_feature(
    key="admin_level",
    value="5"
  )  %>%
  osmdata::osmdata_sf()
}
dsf_newTaipei$osm_points %>%
  filter(
    !is.na(name)
  ) %>%
  ggplot()+geom_sf()
dsf_newTaipei$osm_multipolygons %>%
  osm_geom_rename() -> dsf_newTaipei2
dsf_newTaipei2 %>%
  ggplot()+geom_sf()
dsf_newTaipei2 %>%
  filter(
    stringr::str_detect(name, "土|峽|板")
  ) %>%
  ggplot()+geom_sf()

國立臺北大學

opq_ntpu = {
  opq(c(xmin=121.36, ymin=24.94, xmax=121.38, ymax=24.95))
}
dsf_ntpu <- {

  opq_ntpu %>%
    add_osm_feature(
      key = "building",
      value="university"
    ) %>%
    add_osm_feature(
      key="highway", value="residential"
    ) %>%
    osmdata_sf()


}
dsf_ntpu$osm_polygons %>%
  ggplot()+geom_sf()


tpemartin/econDV1091 documentation built on Feb. 17, 2021, 6:37 a.m.