Skip to content

Commit

Permalink
commit readme
Browse files Browse the repository at this point in the history
  • Loading branch information
oousmane committed Jul 27, 2024
1 parent 8755968 commit 94e2341
Show file tree
Hide file tree
Showing 27 changed files with 403 additions and 28 deletions.
6 changes: 6 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
^.*\.Rproj$
^\.Rproj\.user$
^LICENSE\.md$
^README\.Rmd$
^_pkgdown\.yml$
^docs$
^pkgdown$
^\.github$
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
50 changes: 50 additions & 0 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
release:
types: [published]
workflow_dispatch:

name: pkgdown

permissions: read-all

jobs:
pkgdown:
runs-on: ubuntu-latest
# Only restrict concurrency for non-PR jobs
concurrency:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::pkgdown, local::.
needs: website

- name: Build site
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
shell: Rscript {0}

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/[email protected]
with:
clean: false
branch: gh-pages
folder: docs
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
.Rdata
.httr-oauth
.DS_Store
docs
20 changes: 14 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
Package: hexbur
Type: Package
Title: What the Package Does (Title Case)
Title: hexbur provides several layers of information for Burkina Faso, particularly useful for analyzing agricultural systems
Version: 0.1.0
Author: Who wrote it
Authors@R:
person("Ousmane", "Ouedraogo", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-6349-4146"))
Maintainer: The package maintainer <[email protected]>
Description: More about what it does (maybe more than one line)
Use four spaces when indenting paragraphs within the Description.
License: What license is it under?
Description: hexbur stands for "hEXagons for BURkina Faso". The basis of this package is a gridded map of Burkina Faso in hexagons of about 340 km2. For each hexagon, different information can be added using the package function. The data is not included in the package itself, but is called up via URL. It therefore requires an Internet connection to operate.
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
URL: https://github.com/oousmane/hexbur
URL: https://github.com/oousmane/hexbur, https://oousmane.github.io/hexbur/
BugReports: https://github.com/oousmane/hexbur/issues
RoxygenNote: 7.3.1
Imports:
dplyr,
magrittr,
readr,
sf,
tibble
2 changes: 2 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
YEAR: 2024
COPYRIGHT HOLDER: hexbur authors
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# MIT License

Copyright (c) 2024 hexbur authors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
22 changes: 21 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1 +1,21 @@
exportPattern("^[[:alpha:]]+")
# Generated by roxygen2: do not edit by hand

export("%>%")
export(admin0_map)
export(admin1_map)
export(admin2_map)
export(admin3_map)
export(get_static_layer)
export(hex_map)
export(hwsd_cols)
export(num_to_usda)
import(dplyr)
import(readr)
import(sf)
import(tibble)
importFrom(dplyr,case_when)
importFrom(dplyr,filter)
importFrom(magrittr,"%>%")
importFrom(readr,read_csv)
importFrom(sf,read_sf)
importFrom(tibble,tibble)
2 changes: 2 additions & 0 deletions R/get_base_map.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
#'
#' @examples
#' # Plot the map
#' \dontrun{
#'library(sf)
#'library(tidyverse)
#'
#' # get hex map
#' hex_bf <-hex_map() # No argument, need internet connection.
#' ggplot(hex_bf)+geom_sf() # Quick visualization
#' }
#' @export
hex_map <-function(){
hex <- sf::read_sf('https://github.com/oousmane/hexburdb/raw/main/map/hex_grid.gpkg')
Expand Down
21 changes: 12 additions & 9 deletions R/get_static_layer.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
#' Add static data layers
#' Add static data layers
#'
#'Add static data layer (not updated from year to year), based on the spatial grid of the map obtained by the get_map() function
#'
#' @param layer type of data to be added ("soil" for soil feature, "crops" for main crops distribution, "herds" for farm animal density (aggregated from departmental scale), "herds_municipality" for farm animal density (aggregated from municipality scale), "human" for human population density)
#'
#' @return a tibble with the hexagon number ("hex_id" column) and the selected features values
#' @import sf
#' @import tidyverse
#'
#' @references
#' @import dplyr
#' @import readr
#' @import tibble
#'
#' @references
#' - Soil features from [SoilGrids](https://soilgrids.org/)
#' - Crop distribution from the Land-Parcel Identification System ([Registre Parcellaire Graphique](https://www.data.gouv.fr/fr/datasets/registre-parcellaire-graphique-rpg-contours-des-parcelles-et-ilots-culturaux-et-leur-groupe-de-cultures-majoritaire/) in France) of the European Common Agricultural Policy
#' - Organic crop distribution from [Agence Bio](https://www.data.gouv.fr/fr/datasets/parcelles-en-agriculture-biologique-ab-declarees-a-la-pac/)
Expand All @@ -17,14 +19,15 @@
#'
#' @examples
#'# Get soil features and plot clay content
#'\dontrun{
#'library(sf)
#'library(tidyverse)
#'
#'get_map()%>%
#' left_join(get_static_layer("soil"))%>%
#' ggplot()+
#' geom_sf(aes(fill=clay_0to30cm_percent))
#'
#' geom_sf(aes(fill=clay_0to30cm_percent))
#'}
#' @export
get_static_layer<-function(layer){
tb<-tibble(
Expand All @@ -41,8 +44,8 @@ get_static_layer<-function(layer){
)
)%>%
filter(name==layer)

ext<-read_csv(tb$url)

return(ext)
}
}
1 change: 1 addition & 0 deletions R/globals.R
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
utils::globalVariables(c("name"))
10 changes: 10 additions & 0 deletions R/hexbur-package.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#' @keywords internal
"_PACKAGE"

## usethis namespace: start
#' @importFrom dplyr filter
#' @importFrom readr read_csv
#' @importFrom sf read_sf
#' @importFrom tibble tibble
## usethis namespace: end
NULL
14 changes: 14 additions & 0 deletions R/utils-pipe.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#' Pipe operator
#'
#' See \code{magrittr::\link[magrittr:pipe]{\%>\%}} for details.
#'
#' @name %>%
#' @rdname pipe
#' @keywords internal
#' @export
#' @importFrom magrittr %>%
#' @usage lhs \%>\% rhs
#' @param lhs A value or the magrittr placeholder.
#' @param rhs A function call using the magrittr semantics.
#' @return The result of calling `rhs(lhs)`.
NULL
58 changes: 58 additions & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
output: github_document
---

<!-- README.md is generated from README.Rmd. Please edit that file -->

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%",
warning = FALSE,
message = FALSE
)
```

# hexbur

<!-- badges: start -->
<!-- badges: end -->

The goal of hexbur is to provides several layers of information for Burkina Faso, useful for agricultural systems analysis and more.

## Installation

You can install the development version of hexbur from [GitHub](https://github.com/) with:

``` r
# install.packages("devtools")
devtools::install_github("oousmane/hexbur")
```

## Example

The package is based on a hexagonal grid of Burkina Faso, to which data layers can be added. This grid may be loaded as follows,
using the `hex_map()` function
```{r example}
library(hexbur)
hex <- hex_map() # with no args.
```

A very quick viz of hex grids can be performed using `{sf}` and for sure the `{tidyverse}`

```{r cars}
#| warning
library(hexbur)
library(sf)
library(tidyverse)
hex <- hex_map() # with no args.
# Simple hex grid map
ggplot()+
geom_sf(data = hex)
```

58 changes: 58 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@

<!-- README.md is generated from README.Rmd. Please edit that file -->

# hexbur

<!-- badges: start -->
<!-- badges: end -->

The goal of hexbur is to provides several layers of information for
Burkina Faso, useful for agricultural systems analysis and more.

## Installation

You can install the development version of hexbur from
[GitHub](https://github.com/) with:

``` r
# install.packages("devtools")
devtools::install_github("oousmane/hexbur")
```

## Example

The package is based on a hexagonal grid of Burkina Faso, to which data
layers can be added. This grid may be loaded as follows, using the
`hex_map()` function

``` r
library(hexbur)
hex <- hex_map() # with no args.
```

A very quick viz of hex grids can be performed using `{sf}` and for sure
the `{tidyverse}`

``` r
library(hexbur)
library(sf)
library(tidyverse)

hex <- hex_map() # with no args.

# Simple hex grid map
ggplot()+
geom_sf(data = hex)
```

<img src="man/figures/README-warning-1.png" width="100%" />

You’ll still need to render `README.Rmd` regularly, to keep `README.md`
up-to-date. `devtools::build_readme()` is handy for this.

You can also embed plots, for example:

<img src="man/figures/README-pressure-1.png" width="100%" />

In that case, don’t forget to commit and push the resulting figure
files, so they display on GitHub and CRAN.
4 changes: 4 additions & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
url: https://oousmane.github.io/hexbur/
template:
bootstrap: 5

Binary file added figs/usda-d1-hex.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 removed hex_grid.gpkg
Binary file not shown.
Binary file added man/figures/README-cars-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 added man/figures/README-pressure-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 added man/figures/README-warning-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions man/get_static_layer.Rd

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

Loading

0 comments on commit 94e2341

Please sign in to comment.