Skip to content

Commit

Permalink
Update docs and fix bug in read_fb_mobility_files() (ropensci/softwar…
Browse files Browse the repository at this point in the history
…e-review#619)

- Fix bug in read_fb_mobility_files() that was producing parsing issues and update docs
- Add contributing.md link to README and other minor updates
- Fix url breaks in the roxygen docs
  • Loading branch information
flor14 committed Feb 20, 2024
1 parent 9b7b8c4 commit 0fa24de
Show file tree
Hide file tree
Showing 28 changed files with 193 additions and 91 deletions.
1 change: 1 addition & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ If you’ve found a bug, please file an issue that illustrates the bug with a mi
Please note that the quadkeyr project is released with a
[Contributor Code of Conduct](CODE_OF_CONDUCT.md). By contributing to this
project you agree to abide by its terms.

1 change: 1 addition & 0 deletions R/grid_to_polygon.R
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ grid_to_polygon <- function(data) {
#' QuadKeys appears as NAs as there are only kept to extend the grid.
#' Their value is not necessary.
#'
#' @keywords internal
#' @export
#'
#' @examples
Expand Down
51 changes: 33 additions & 18 deletions R/read_and_format_files.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,32 @@
#'
#' @examples
#'
#' read_fb_mobility_files(
#' files <- read_fb_mobility_files(
#' path_to_csvs = paste0(system.file("extdata",
#' package = "quadkeyr"), "/"),
#' colnames = c(
#' "lat", "lon",
#' "quadkey", "date_time",
#' "n_crisis", "percent_change"
#' package = "quadkeyr"), "/"),
#' colnames = c( # The columns not listed here will be omitted
#' "lat",
#' "lon",
#' "quadkey",
#' "date_time",
#' "n_crisis",
#' "percent_change",
#' "day",
#' "hour"
#' ),
#' coltypes = list(
#' lat = "d",
#' lon = "d",
#' quadkey = "d",
#' date_time = "T",
#' n_crisis = "c",
#' percent_change = "c"
#' lat = 'd',
#' lon = 'd',
#' quadkey = 'c',
#' date_time = 'T',
#' n_crisis = 'c',
#' percent_change = 'c',
#' day = 'D',
#' hour = 'i'
#' )
#' )
#'
#' head(files)
#'
read_fb_mobility_files <- function(path_to_csvs,
colnames,
Expand All @@ -61,12 +70,18 @@ read_fb_mobility_files <- function(path_to_csvs,

# There could be empty files, let's remove them
fnames <- fnames[file.info(fnames)$size != 0]

data <- purrr::map_dfr(fnames,
readr::read_csv,
col_select = dplyr::all_of(colnames), # tidyselect
col_names = TRUE, # header
col_types = coltypes

data <- purrr::map_dfr(
.x = fnames,
.f = function(files) {
readr::read_csv(
files,
# Let's select the columns given by the user.
col_select = dplyr::all_of(colnames),
col_names = TRUE, # header
col_types = coltypes
)
}
)


Expand Down
19 changes: 13 additions & 6 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ knitr::include_graphics("man/figures/quadkeys.jpg")

The goal of `quadkeyr` is to:

1. [**Convert a QuadKey to a simple features data.frame (and more)**](https://fernandez-lab-wsu.github.io/quadkeyr/articles/quadkey_to_sf_conversion.html)
1. [**Convert a QuadKey to a Simple Features data.frame (and more)**](https://fernandez-lab-wsu.github.io/quadkeyr/articles/quadkey_to_sf_conversion.html)
`quadkeyr` provides functions to convert a QuadKey to
a `sf POINT data.frame` or `sf POLYGON data.frame`.
a `sf` POINT data.frame or `sf` POLYGON data.frame.
Additionally, all the R functions described
in the [official documentation](https://learn.microsoft.com/en-us/bingmaps/articles/bing-maps-tile-system)
to convert QuadKeys to and from tiles, pixels and geographic coordinates
Expand All @@ -72,7 +72,7 @@ knitr::include_graphics("man/figures/workflow_quadkey.png")
Complete a grid of QuadKeys within a specified area and zoom level,
and create a `stars` raster.
You can also directly convert QuadKeys in a data.frame column
into an `sf POLYGON data.frame`.
into an `sf` POLYGON data.frame.

```{r w2, echo = FALSE, out.width= "90%", fig.align='center'}
knitr::include_graphics("man/figures/workflow_raster.png")
Expand All @@ -85,7 +85,7 @@ by day and hour reported.
knitr::include_graphics("man/figures/workflow_facebook.png")
```

4. [**Offer an App for visualizing QuadKeys on a map.**](https://fernandez-lab-wsu.github.io/quadkeyr/articles/quadkey_visualization_app.html)
4. [**Offer an App for visualizing QuadKeys on a map**](https://fernandez-lab-wsu.github.io/quadkeyr/articles/quadkey_visualization_app.html)
Introduce a QuadKey visualization application enabling users
to validate function outcomes.

Expand All @@ -100,9 +100,16 @@ remotes::install_github("Fernandez-Lab-WSU/quadkeyr")

## Code of Conduct

Please note that the `quadkeyr` project is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/2/1/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.
Please, note that the `quadkeyr` project is released with a
[Contributor Code of Conduct](https://contributor-covenant.org/version/2/1/CODE_OF_CONDUCT.html).
By contributing to this project, you agree to abide by its terms.

### References
## Contribute

If you'd like to contribute to this project, please follow the
[contributing guidelines](https://github.com/Fernandez-Lab-WSU/quadkeyr/blob/main/.github/CONTRIBUTING.md)

## Links of interest
- [Bing Maps Tile Systems - Microsoft](https://learn.microsoft.com/en-us/bingmaps/articles/bing-maps-tile-system)
- [R - `slippymath`: Slippy Map Tile Tools](https://cran.r-project.org/web/packages/slippymath/index.html)
- [Python - `pyquadkey2`](https://docs.muetsch.io/pyquadkey2/)
Expand Down
22 changes: 14 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ Bing Maps Tile System webpage.

The goal of `quadkeyr` is to:

1. [**Convert a QuadKey to a simple features data.frame (and
1. [**Convert a QuadKey to a Simple Features data.frame (and
more)**](https://fernandez-lab-wsu.github.io/quadkeyr/articles/quadkey_to_sf_conversion.html)
`quadkeyr` provides functions to convert a QuadKey to a
`sf POINT data.frame` or `sf POLYGON data.frame`. Additionally, all
the R functions described in the [official
`quadkeyr` provides functions to convert a QuadKey to a `sf` POINT
data.frame or `sf` POLYGON data.frame. Additionally, all the R
functions described in the [official
documentation](https://learn.microsoft.com/en-us/bingmaps/articles/bing-maps-tile-system)
to convert QuadKeys to and from tiles, pixels and geographic
coordinates are available.
Expand All @@ -68,7 +68,7 @@ The goal of `quadkeyr` is to:
Data**](https://fernandez-lab-wsu.github.io/quadkeyr/articles/quadkey_identified_data_to_raster.html)
Complete a grid of QuadKeys within a specified area and zoom level,
and create a `stars` raster. You can also directly convert QuadKeys
in a data.frame column into an `sf POLYGON data.frame`.
in a data.frame column into an `sf` POLYGON data.frame.

<img src="man/figures/workflow_raster.png" width="90%" style="display: block; margin: auto;" />
3. [**Convert Facebook Mobility QuadKey-identified Datasets into Raster
Expand All @@ -79,7 +79,7 @@ hour reported.
<img src="man/figures/workflow_facebook.png" width="90%" style="display: block; margin: auto;" />

4. [**Offer an App for visualizing QuadKeys on a
map.**](https://fernandez-lab-wsu.github.io/quadkeyr/articles/quadkey_visualization_app.html)
map**](https://fernandez-lab-wsu.github.io/quadkeyr/articles/quadkey_visualization_app.html)
Introduce a QuadKey visualization application enabling users to
validate function outcomes.

Expand All @@ -95,12 +95,18 @@ remotes::install_github("Fernandez-Lab-WSU/quadkeyr")

## Code of Conduct

Please note that the `quadkeyr` project is released with a [Contributor
Please, note that the `quadkeyr` project is released with a [Contributor
Code of
Conduct](https://contributor-covenant.org/version/2/1/CODE_OF_CONDUCT.html).
By contributing to this project, you agree to abide by its terms.

### References
## Contribute

If you’d like to contribute to this project, please follow the
[contributing
guidelines](https://github.com/Fernandez-Lab-WSU/quadkeyr/blob/main/.github/CONTRIBUTING.md)

## Links of interest

- [Bing Maps Tile Systems -
Microsoft](https://learn.microsoft.com/en-us/bingmaps/articles/bing-maps-tile-system)
Expand Down
10 changes: 5 additions & 5 deletions docs/authors.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions docs/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ articles:
quadkey_identified_data_to_raster: quadkey_identified_data_to_raster.html
quadkey_to_sf_conversion: quadkey_to_sf_conversion.html
quadkey_visualization_app: quadkey_visualization_app.html
last_built: 2024-02-13T23:55Z
last_built: 2024-02-14T03:35Z

3 changes: 2 additions & 1 deletion man/add_regular_polygon_grid.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/complete_grid_for_polygons.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions man/data_provided.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion man/get_regular_polygon_grid.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion man/ground_res.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions man/latlong_to_pixelXY.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0fa24de

Please sign in to comment.