Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/adatar-do/sfDR
Browse files Browse the repository at this point in the history
  • Loading branch information
dnldelarosa committed Jul 24, 2024
2 parents ce946c3 + 65e6cf2 commit a961169
Show file tree
Hide file tree
Showing 75 changed files with 1,314 additions and 611 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
^docs$
^pkgdown$
^\.github$
^CODE_OF_CONDUCT\.md$
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
docs
data-raw/shapes
.Rhistory
<<<<<<< HEAD
=======
/.quarto/
>>>>>>> 65e6cf2f6112ffddde6fe39040897cf8165541f3
126 changes: 126 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# Contributor Covenant Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, caste, color, religion, or sexual
identity and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the overall
community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or advances of
any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email address,
without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.

Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at ddelarosa@adatar.do.
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
reporter of any incident.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series of
actions.

**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or permanent
ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.

**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within the
community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.1, available at
<https://www.contributor-covenant.org/version/2/1/code_of_conduct.html>.

Community Impact Guidelines were inspired by
[Mozilla's code of conduct enforcement ladder][https://github.com/mozilla/inclusion].

For answers to common questions about this code of conduct, see the FAQ at
<https://www.contributor-covenant.org/faq>. Translations are available at <https://www.contributor-covenant.org/translations>.

[homepage]: https://www.contributor-covenant.org
10 changes: 8 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: sfDR
Title: Simple Features for Dominican Republic Administrative Boundaries
Version: 0.1.5
Version: 0.2.2
Authors@R:
c(person(given = "Daniel E.",
family = "de la Rosa",
Expand All @@ -16,9 +16,15 @@ Description: The sfDR package provides a comprehensive collection of simple
License: MIT + file LICENSE
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
Depends:
R (>= 2.10)
LazyData: true
LazyDataCompression: xz
URL: https://adatar-do.github.io/sfDR/
Imports:
dplyr,
lifecycle,
magrittr,
pins,
sf
9 changes: 9 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
# Generated by roxygen2: do not edit by hand

export("%>%")
export(dr_municipal_districts)
export(dr_municipalities)
export(dr_provinces)
export(dr_regions)
export(dr_sections)
export(get_dr_provinces)
importFrom(lifecycle,deprecated)
importFrom(magrittr,"%>%")
109 changes: 87 additions & 22 deletions R/dm.R
Original file line number Diff line number Diff line change
@@ -1,30 +1,95 @@
#' Simple features for the "Municipal Districts of the Dominican Republic"
#' Load Dominican Republic Municipal Districts Simple Features (sf)
#' `r lifecycle::badge('experimental')`
#'
#' This dataset contains simple features polygons representing the 393 municipal districts
#' of the Dominican Republic, as defined in the `División Territorial 2021`.
#' This function loads the Dominican Republic municipal districts simple features (sf)
#' and adds metadata for municipalities, provinces, and regions if required.
#' It also optionally converts the result to an `sf` object.
#'
#' @format ## `DR_DM`
#' A simple features collection with 393 features and 2 fields:
#' @param .sf Logical; if TRUE, converts the result to an `sf` object. Defaults to TRUE.
#' @param .mun Logical; if FALSE, removes columns related to municipalities. Defaults to FALSE.
#' @param .prov Logical; if FALSE, removes columns related to provinces. Defaults to FALSE.
#' @param .reg Logical; if FALSE, removes columns related to regions. Defaults to FALSE.
#' @param .uniques Logical; if TRUE, removes some duplicated IDs inserted to consider
#' territories names changes over time. Defaults to TRUE.
#'
#' @return A data frame or `sf` object (if .sf is TRUE) with the loaded and processed data.
#' @export
#'
#' @format
#' A simple features collection with 393 features and 10 fields:
#' \describe{
#' \item{DM_ID}{Municipal district number (6 digits) based on the `División Territorial 2021` order}
#' \item{MD_ID}{Municipal district number (6 digits) based on the `División Territorial 2021` order}
#' \item{MD_NAME}{Full name of the municipal district as defined in the `División Territorial 2021`}
#' \item{MUN_ID}{Municipality number (4 digits)}
#' \item{MUN_NAME}{Full name of the municipality}
#' \item{PROV_ID}{Province number (2 digits)}
#' \item{PROV_CODE}{Code of the province}
#' \item{PROV_NAME}{Full name of the province}
#' \item{REG_ID}{Region number}
#' \item{REG_NAME}{Name of the region}
#' \item{REG_CODE}{Code of the region}
#' \item{geometry}{Polygon geometry representing each municipal district}
#' }
#' @source <https://geoportal.iderd.gob.do/layers/geonode_data:geonode:RD_DM>
'DR_DM'


#' Metadata for the "Municipal Districts of the Dominican Republic"
#'
#' This dataset contains the metadata for the 393 municipal districts of the Dominican
#' Republic as defined in the `División Territorial 2021`. Due to historical name changes,
#' some municipal districts may have duplicate IDs. Users should be aware of this when
#' analyzing the data.
#' @source <https://geoportal.iderd.gob.do/layers/geonode_data:geonode:RD_DM>
#' @source <https://www.one.gob.do/publicaciones/2021/division-territorial-2021/>
#'
#' @format ## `dr_municipal_district`
#' A data frame with 393 rows and 3 variables:
#' \describe{
#' \item{DM_ID}{Municipal district number (6 digits) based on the `División Territorial 2021` order}
#' \item{DM_NAME}{Full name of the municipal district as defined in the `División Territorial 2021`}
#' @examples
#' \dontrun{
#' # Load and process the data as sf object
#' result <- dr_municipal_districts(TRUE, TRUE, TRUE, TRUE)
#' print(result)
#' }
#' @source <https://www.one.gob.do/publicaciones/2021/division-territorial-2021/>
'dr_municipal_district'
#'
dr_municipal_districts <- function(.sf = TRUE, .mun = FALSE, .prov = FALSE, .reg = FALSE, .uniques = TRUE) {
MD_ID <- NULL

metadata <- pins::pin_read(
pins::board_folder(system.file("extdata", package = "sfDR")),
"DR_MD_METADATA"
)

if (.uniques) {
metadata <- metadata %>%
dplyr::distinct(MD_ID, .keep_all = T)
}

drmd <- DR_MUNICIPAL_DISTRICTS %>%
sf::st_as_sf() %>%
dplyr::left_join(metadata, by = dplyr::join_by(MD_ID)) %>%
.add_mun(.prov, .reg)

if (!.mun) {
drmd <- drmd %>%
dplyr::select(-dplyr::starts_with("MUN"))
}

if (!.prov) {
drmd <- drmd %>%
dplyr::select(-dplyr::starts_with("PROV"))
}

if (!.reg) {
drmd <- drmd %>%
dplyr::select(-dplyr::starts_with("REG"))
}

if (!.sf) {
drmd <- drmd %>%
sf::st_drop_geometry()
}

drmd
}


.add_mun <- function(drmd, .prov = FALSE, .reg = FALSE) {
MD_ID <- NULL

drmd %>%
dplyr::mutate(MUN_ID = substr(MD_ID, 1, 4)) %>%
dplyr::left_join(
dr_municipalities(FALSE, .prov, .reg),
by = "MUN_ID"
)
}
Loading

0 comments on commit a961169

Please sign in to comment.