diff --git a/.Rhistory b/.Rhistory index 9b55ce6..93ab586 100644 --- a/.Rhistory +++ b/.Rhistory @@ -448,3 +448,4 @@ check() use_readme_rmd() renv::status() ?renv::status() +library diff --git a/.gitignore b/.gitignore index 3bde252..e7f437e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .Rproj.user renv.lock +renv/ diff --git a/R/core.R b/R/core.R index 733bc09..5259cc3 100644 --- a/R/core.R +++ b/R/core.R @@ -55,7 +55,7 @@ dataset_path <- function(overture_type) { #' #' @param overture_type Character. Required. The type of feature to select. Examples include 'building', 'place', etc. #' To learn more, run \code{get_all_overture_types()}. -#' @param bbox Numeric vector. Optional. A bounding box specified as c(xmin, ymin, xmax, ymax). +#' @param bbox_ Numeric vector. Optional. A bounding box specified as c(xmin, ymin, xmax, ymax). #' It is recommended to use a bounding box to limit the dataset size and processing time. #' Without a bounding box, processing the entire dataset (e.g., buildings over 2 billion) can be time-consuming. #' @@ -66,25 +66,25 @@ dataset_path <- function(overture_type) { #' \dontrun{ #' # Example usage with a bounding box #' sf_bbox <- c(-122.5, 37.7, -122.3, 37.8) -#' result <- record_batch_reader(overture_type = 'place', bbox = sf_bbox) +#' result <- record_batch_reader(overture_type = 'place', bbox_ = sf_bbox) #' print(result) #' } #' #' @importFrom arrow open_dataset #' @importFrom sf st_as_sf #' @importFrom dplyr %>% filter collect -record_batch_reader <- function(overture_type, bbox = NULL){ +record_batch_reader <- function(overture_type, bbox_ = NULL){ # Open the dataset based on the overture_type dataset <- open_dataset(dataset_path(overture_type)) # based on kyle walker code - https://walker-data.com/posts/overture-buildings/ - if(!is.null(bbox)){ - filtered_df <- open_dataset(dataset_path(overture_type)) %>% - filter(bbox$xmin > bbox[1], - bbox$ymin > bbox[2], - bbox$xmax < bbox[3], - bbox$ymax < bbox[4]) %>% + if(!is.null(bbox_)){ + filtered_df <- dataset %>% + filter(bbox$xmin > bbox_[1], + bbox$ymin > bbox_[2], + bbox$xmax < bbox_[3], + bbox$ymax < bbox_[4]) %>% collect() %>% st_as_sf(crs = 4326) } else { @@ -98,5 +98,5 @@ record_batch_reader <- function(overture_type, bbox = NULL){ # Example usage (uncomment to test) # sf_bbox <- c(-122.5, 37.7, -122.3, 37.8) -# result <- record_batch_reader(overture_type = 'place', bbox = sf_bbox) +# result <- record_batch_reader(overture_type = 'place', bbox_ = sf_bbox) # print(result) diff --git a/README.Rmd b/README.Rmd index 10f2275..de14849 100644 --- a/README.Rmd +++ b/README.Rmd @@ -47,6 +47,15 @@ You'll still need to render `README.Rmd` regularly, to keep `README.md` up-to-da In that case, don't forget to commit and push the resulting figure files, so they display on GitHub and CRAN. +## Try it out + +Example lisbon building +```{r } +library(overturemapsr) + + +``` + ## Functions - `get_all_overture_types`: This function returns all available OvertureMaps theme types. diff --git a/man/record_batch_reader.Rd b/man/record_batch_reader.Rd index adf4bb2..96d05e0 100644 --- a/man/record_batch_reader.Rd +++ b/man/record_batch_reader.Rd @@ -4,13 +4,13 @@ \alias{record_batch_reader} \title{record_batch_reader} \usage{ -record_batch_reader(overture_type, bbox = NULL) +record_batch_reader(overture_type, bbox_ = NULL) } \arguments{ \item{overture_type}{Character. Required. The type of feature to select. Examples include 'building', 'place', etc. To learn more, run \code{get_all_overture_types()}.} -\item{bbox}{Numeric vector. Optional. A bounding box specified as c(xmin, ymin, xmax, ymax). +\item{bbox_}{Numeric vector. Optional. A bounding box specified as c(xmin, ymin, xmax, ymax). It is recommended to use a bounding box to limit the dataset size and processing time. Without a bounding box, processing the entire dataset (e.g., buildings over 2 billion) can be time-consuming.} } @@ -25,7 +25,7 @@ optionally within a bounding box, and converts it to an \code{sf} object. \dontrun{ # Example usage with a bounding box sf_bbox <- c(-122.5, 37.7, -122.3, 37.8) -result <- record_batch_reader(overture_type = 'place', bbox = sf_bbox) +result <- record_batch_reader(overture_type = 'place', bbox_ = sf_bbox) print(result) }