-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 46682bc
Showing
12 changed files
with
556 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Package: spMaps | ||
Type: Package | ||
Title: Europe SpatialPolygonsDataFrame Builder | ||
Version: 0.1 | ||
Date: 2017-11-15 | ||
Authors@R: c( | ||
person("Jalal-Edine", "ZAWAM", email = "jalal-edine.zawam@rte-france.com", role = c("aut", "cre")), | ||
person("Benoit", "Thieurmel", email = "benoit.thieurmel@datastorm.fr", role = "aut"), | ||
person("RTE", role = "cph") | ||
) | ||
Maintainer: Jalal-Edine ZAWAM <jalal-edine.zawam@rte-france.com> | ||
Description: Build custom Europe SpatialPolygonsDataFrame, if you don't know what is a SpatialPolygonsDataFrame see SpatialPolygons() in 'sp', by example for mapLayout() in 'antaresViz'. Antares is a powerful software developed by RTE to simulate and study electric power systems (more information about 'Antares' here: <https://antares.rte-france.com>). | ||
URL: https://github.com/rte-antares-rpackage/antaresMaps | ||
BugReports: https://github.com/rte-antares-rpackage/antaresMaps/issues | ||
License: GPL (>= 2) | file LICENSE | ||
LazyData: TRUE | ||
Encoding: UTF-8 | ||
Depends: R (>= 2.10), sp | ||
RoxygenNote: 6.0.1 | ||
Suggests: testthat, covr | ||
NeedsCompilation: no | ||
Packaged: 2017-11-16 07:47:02 UTC; jalazawa | ||
Author: Jalal-Edine ZAWAM [aut, cre], | ||
Benoit Thieurmel [aut], | ||
RTE [cph] | ||
Repository: CRAN | ||
Date/Publication: 2017-11-17 12:38:17 UTC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
COPYRIGHT HOLDER: RTE R�seau de transport d'�lectricit� |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
b79134305d97d52407acfc154e9fd3b2 *DESCRIPTION | ||
ed36de57b24b2922c78b0e50e20809a9 *LICENSE | ||
ce49b038f581b9ec6e206e20cf90557d *NAMESPACE | ||
dcaa1256d4b8e5285f459dc474152e10 *R/sysdata.rda | ||
1c507631eba2c255220b19696c9cb282 *R/utils.R | ||
7816407adc31f3b2887fe5305ffcf886 *README.md | ||
2387ca3e1161621e8b175b076404f06d *inst/dataset/build_save_data.R | ||
5bdf4fb8b9f09675569e9ab5e32fc936 *man/spMaps.Rd | ||
a0930d037706bc88c15d2df7a521761d *tests/testthat.R | ||
a26e0b57e38e2a32c2e202e3be70253c *tests/testthat/test-dataset.R | ||
3fbe9a50e3e2dc5693186da2a8b3d68e *tests/testthat/test-getAntaresMap.R |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
export(getEuropeCountries) | ||
export(getEuropeReferenceTable) | ||
export(getEuropeStates) | ||
export(getSpMaps) | ||
import(sp) | ||
importFrom(utils,data) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
#' @rdname spMaps | ||
#' @export | ||
#' @importFrom utils data | ||
#' @import sp | ||
#' | ||
getEuropeReferenceTable <- function(){ | ||
europe_countries_ref$name <- as.character(europe_countries_ref$name) | ||
europe_countries_ref$code <- as.character(europe_countries_ref$code) | ||
europe_countries_ref | ||
} | ||
|
||
#' @rdname spMaps | ||
#' @export | ||
#' | ||
getEuropeCountries <- function(){ | ||
europe_countries_10m | ||
} | ||
|
||
#' @rdname spMaps | ||
#' @export | ||
#' | ||
getEuropeStates <- function(){ | ||
europe_states_provinces_10m | ||
} | ||
|
||
#' Get custom Europe map (\code{SpatialPolygonsDataFrame}) | ||
#' | ||
#' This function builds a custom Europe map and return a \code{SpatialPolygonsDataFrame}. | ||
#' The output can be use by example in \link[antaresViz]{mapLayout} with the \code{map} argument. | ||
#' | ||
#' @param countries \code{character}. Vector of wanted countries, without details / states. | ||
#' Must referred to \code{code} column of the reference table \code{getEuropeReferenceTable}. | ||
#' "all" (default) keep all countries | ||
#' | ||
#' @param states \code{character}. Vector of wanted countries, with details / states. | ||
#' Must referred to \code{code} column of the reference table \code{getEuropeReferenceTable}. | ||
#' "all" keep all countries. NULL as default. | ||
#' | ||
#' @return \code{SpatialPolygonsDataFrame} | ||
#' | ||
#' @examples | ||
#' | ||
#' # default map : Europe without states | ||
#' europe_cty <- getSpMaps() | ||
#' plot(europe_cty) | ||
#' | ||
#' # subset on some countries | ||
#' ref_table <- getEuropeReferenceTable() | ||
#' | ||
#' italy_spain_fra <- getSpMaps(countries = c("FRA", "ITA", "ESP")) | ||
#' plot(italy_spain_fra) | ||
#' | ||
#' \dontrun{ | ||
#' italy_spain_fra_states <- getSpMaps(countries = NULL, states = c("FRA", "ITA", "ESP")) | ||
#' plot(italy_spain_fra_states) | ||
#' | ||
#' # combine countries and states | ||
#' combine_map <- getSpMaps(countries = c("ITA", "ESP"), states = "FRA") | ||
#' plot(combine_map) | ||
#' | ||
#' # build your custom map : you can use directly data | ||
#' # to subset the area you really want | ||
#' europe_states <- getEuropeStates() | ||
#' europe_countries <- getEuropeCountries() | ||
#' | ||
#' # for example, have a look to GBR states map | ||
#' summary(europe_states) | ||
#' gbr_states_districts <- europe_states[ | ||
#' europe_states$sr_adm0_a3 %in% "GBR" & | ||
#' europe_states$type %in% "Administrative County",] | ||
#' plot(gbr_states_districts) | ||
#' | ||
#' # combine with another map : you just have to have the same columns... | ||
#' # getSpMaps only return "name" column | ||
#' custom_states <- rbind( | ||
#' getSpMaps(countries = NULL, states = "FRA"), | ||
#' gbr_states_districts[, "name", drop = FALSE]) | ||
#' | ||
#' plot(custom_states) | ||
#' | ||
#' } | ||
#' | ||
#' @export | ||
#' | ||
#' | ||
#' @name spMaps | ||
#' | ||
getSpMaps <- function(countries = "all", states = NULL){ | ||
|
||
# controls | ||
if(is.null(countries) & is.null(states)){ | ||
message("No countries and no states selected") | ||
return(NULL) | ||
} | ||
|
||
# reference table | ||
ref_table <- getEuropeReferenceTable() | ||
|
||
# don't show countries if in states | ||
if("all" %in% countries & "all" %in% states){ | ||
countries <- NULL | ||
} else if("all" %in% countries & !is.null(states)){ | ||
countries <- ref_table$code | ||
countries <- setdiff(countries, states) | ||
} else if(!is.null(countries) & !is.null(states)){ | ||
countries <- setdiff(countries, states) | ||
} | ||
if(length(countries) == 0) countries <- NULL | ||
|
||
# countries | ||
if(!is.null(countries)){ | ||
stopifnot(all(countries %in% c("all", ref_table$code))) | ||
if(!"all" %in% countries){ | ||
countries_data <- europe_countries_10m[europe_countries_10m$adm0_a3 %in% countries, ] | ||
} else { | ||
countries_data <- europe_countries_10m | ||
} | ||
} else { | ||
countries_data <- NULL | ||
} | ||
|
||
# states | ||
if(!is.null(states)){ | ||
stopifnot(all(states %in% c("all", ref_table$code))) | ||
if(!"all" %in% states){ | ||
states_data <- europe_states_provinces_10m[europe_states_provinces_10m$sr_adm0_a3 %in% states, ] | ||
} else { | ||
states_data <- europe_states_provinces_10m | ||
} | ||
} else { | ||
states_data <- NULL | ||
} | ||
|
||
if(!is.null(countries_data) & is.null(states_data)){ | ||
return(countries_data[, c("name"), drop = FALSE]) | ||
} else if(is.null(countries_data) & !is.null(states_data)){ | ||
return(states_data[, c("name"), drop = FALSE]) | ||
} else { | ||
return(rbind(countries_data[, c("name"), drop = FALSE], | ||
states_data[, c("name"), drop = FALSE])) | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[![Build status](https://ci.appveyor.com/api/projects/status/rnf5iejmgyu00j1i?svg=true)](https://ci.appveyor.com/project/rte-antares-rpackage/antaresMaps) | ||
[![Build Status](https://travis-ci.org/rte-antares-rpackage/antaresMaps.svg?branch=master)](https://travis-ci.org/rte-antares-rpackage/antaresMaps) | ||
[![codecov](https://codecov.io/gh/rte-antares-rpackage/antaresMaps/branch/master/graph/badge.svg)](https://codecov.io/gh/rte-antares-rpackage/antaresMaps) | ||
|
||
# The 'antaresMaps' R package | ||
|
||
The `antaresMaps` package provides functions allow to build custom maps to using `antaresViz` (`mapLayout`). | ||
|
||
## Installation | ||
|
||
|
||
To install the current version: | ||
|
||
```r | ||
install_github("rte-antares-rpackage/antaresMaps", ref = "master") | ||
``` | ||
|
||
To display the help of the package and see all the functions it provides, type: | ||
|
||
|
||
```r | ||
?antaresMaps | ||
``` |
Oops, something went wrong.