Skip to content

Commit

Permalink
Minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
albuja committed May 28, 2020
1 parent f4c694d commit 43b9117
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 14 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ License: GPL-3
Encoding: UTF-8
LazyData: true
Imports: scales, dplyr, ggplot2, stringr, sf, classInt, ggspatial,
png, grid, showtext, sysfonts, grDevices
png, grid, showtext, sysfonts, grDevices, kimisc
Depends:
R (>= 2.10)
RoxygenNote: 7.1.0
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ import(grid)
import(showtext)
import(sysfonts)
import(grDevices)
import(kimisc)
18 changes: 15 additions & 3 deletions R/choropleth_map_prov_pdf.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,19 @@ choropleth_map_prov_pdf <- function(values,
scores <- tibble(DPA_PROVIN = sprintf('%02d', as.integer(names(values))),
VALUE = values,
LABEL = paste0(values_preffix, format(round(values, values_dec_places), nsmall = values_dec_places, big.mark = values_big_mark, trim = TRUE), values_suffix)) %>%
mutate(!!legend_title := cut(VALUE, breaks = classIntervals(var = VALUE, n = bins, style = bins_style, 5)$brks, include.lowest = TRUE))
mutate(!!legend_title := cut_format(VALUE,
breaks = classIntervals(var = VALUE, n = bins, style = bins_style, 5)$brks,
include.lowest = TRUE,
sep = '; '))

galapagos <- shp_pro %>%
filter(DPA_PROVIN == '20') %>%
st_set_geometry(., st_geometry(.) + c(8e5, 0)) %>%
st_set_crs(32717)

shp_pro <- shp_pro %>%
filter(DPA_PROVIN != '20') %>%
rbind(galapagos)

mapa <- shp_pro %>%
filter(DPA_PROVIN != '90') %>%
Expand Down Expand Up @@ -173,7 +185,8 @@ choropleth_map_prov_pdf <- function(values,
legend.position = legend_position,
legend.margin = margin(6, 6, 6, 6),
legend.background = element_rect(fill = legend_back_color),
plot.background = element_rect(fill = background_color),
plot.background = element_rect(color = NA,
fill = background_color),
panel.background = element_rect(color = NA,
fill = background_color))

Expand All @@ -194,5 +207,4 @@ choropleth_map_prov_pdf <- function(values,
scale = map_scale,
units = 'cm')

#chart
}
Binary file modified R/sysdata.rda
Binary file not shown.
23 changes: 15 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@

<!-- README.md is generated from README.Rmd. Please edit that file -->
mapsEcuador
-----------
\title{mapsEcuador}

mapsEcuador R package provide simple functions to create printer ready PDF Ecuador maps with your own data over a full customizable template.
# mapsEcuador

`mapsEcuador` R package provide simple functions to create printer ready PDF Ecuador maps with your own data over a full customizable template.

No GIS knowledge is required. You need just provide data and geographic data will be internally added.

Base map shape files were downloaded from:
Internal base maps shape files were downloaded from:
https://www.ecuadorencifras.gob.ec/documentos/web-inec/Cartografia/Clasificador_Geografico/2015/

Installation
Expand All @@ -16,13 +17,19 @@ Installation
You can install mapsEcuador R package from github with:

``` r
if (!require("devtools")) {
install.packages("devtools")
library("devtools")
}
install.packages("devtools")
devtools::install_github("albuja/mapsEcuador")
```

Tips for newbies R Windows users:

1) Download R from https://cran.r-project.org/bin/windows/base/ and install it
2) Download RStudio from https://rstudio.com/products/rstudio/download/ and install it
3) Download Rtools from https://cran.r-project.org/bin/windows/Rtools/ and install it
4) Install `devtools` package using `install.packages("devtools")`
5) Install `mapsEcuador` package using `devtools::install_github("albuja/mapsEcuador")`
6) Enjoy it!

Example
--------

Expand Down
4 changes: 2 additions & 2 deletions man/choropleth_map_prov_pdf.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,14 @@
\item{logo_aspect_ratio}{numeric. Relative 'y' size with respect to 'x' size of PNG logo image, 1 means a square image.}
}
\value{
A ggplot object
NULL (PDF file created)
}
\description{
This function creates a PDF printer ready file with Ecuador choropleth map using provided data at province level. No GIS knowledge is required. Provide just a named vector of numeric data. Geographic data will be internally added.

A PDF map can be created using default values simply calling the function only with named values vector as unique argument (see examples).

A lot of options are available for controlling data and customizing titles, labels, fonts, sizes and colors.
A lot of options are available for controlling data and customizing titles, labels, fonts, sizes and colors. See https://fonts.google.com/ for available fonts.

Base map shape files were downloaded from:
https://www.ecuadorencifras.gob.ec/documentos/web-inec/Cartografia/Clasificador_Geografico/2015/
Expand Down

0 comments on commit 43b9117

Please sign in to comment.