Giter Site home page Giter Site logo

bertinr's Introduction

bertin

Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public. R-CMD-check

bertin.js is an easy to use JavaScript library mainly based on D3.js makes creating thematic maps simple. The principle is to work with layers stacked on top of one other. Much like in Geographic Information Software (GIS) software, bertin.js displays layers with a specific hierarchy. The layer at bottom are rendered and then followed by the layer right above it. Some of the layers are used to display various components of a map, some of common layers are: header, footer, graticule, outline, choro, typo, prop, shadow, scalebar, text etc.

bertin package is a wrapper around bertin.js

Installation

You can install the development version of bertin from GitHub with:

# install.packages("remotes")
remotes::install_github("riatelab/bertin")

Example

library(bertin)
library(sf)
world <- st_read(system.file("gpkg/world.gpkg", package = "bertin"),
                 layer = "world", quiet = TRUE)
bt_param(width = 800)|>
  bt_layer(data = world, fill = "#808080") |>
  bt_bubble(data = world, values = "pop", k = 20) |>
  bt_draw() |> 
  bt_save("map.svg")


file: “map.svg”

See examples here

bertinr's People

Contributors

rcarto avatar neocarto avatar rysebaert avatar adriendupas avatar llongour avatar pvictor avatar

Stargazers

Andreas avatar Kenneth Blake Vernon avatar James Goldie avatar  avatar N. Frerebeau avatar  avatar  avatar Olivier Leroy avatar  avatar Robin Lovelace avatar Jakub Nowosad avatar Leo Lee avatar  avatar Eric Book avatar timelyportfolio avatar Antony Barja  avatar Luiz Antonio Gouveia de Oliveira avatar Louis Rousselet avatar Damien Dotta avatar Michael Sumner avatar Cedric Rossi avatar Paul-Antoine avatar

Watchers

timelyportfolio avatar  avatar Luiz Antonio Gouveia de Oliveira avatar  avatar Matthieu Viry avatar  avatar  avatar  avatar

bertinr's Issues

Vignettes

A vignette by usage
Off-CRAN vignettes?

bt_logo | Local images are not rendered

bt_logo works correctly with a url

library(bertin)
library(sf)

bt_logo <-function(bertin, url, position, size = 100, display= TRUE){
  res <- c(as.list(environment()))
  res <- bertin:::clean_input(res, type = "logo")
  if(missing(bertin)){bertin <- list()}
  bertin$layers[[length(bertin$layers) + 1]] <- res
  return(bertin)
}

world <- st_read(system.file("gpkg/world.gpkg", package = "bertin"),
                 layer = "world", quiet = TRUE)
img <- "https://upload.wikimedia.org/wikipedia/commons/thumb/1/1b/R_logo.svg/310px-R_logo.svg.png"

bt_param(margin = 10, width = 500, projection = "Winkel3") |>
  bt_layer(data = world, fill = "red") |>
  bt_logo(url = img) |>
  bt_draw()

Created on 2023-05-11 with reprex v2.0.2
logo_remote

But if I do the same with a local image that doesn't work, i also tried with file:// on the path

library(bertin)
library(sf)

bt_logo <-function(bertin, url, position, size = 100, display= TRUE){
  res <- c(as.list(environment()))
  res <- bertin:::clean_input(res, type = "logo")
  if(missing(bertin)){bertin <- list()}
  bertin$layers[[length(bertin$layers) + 1]] <- res
  return(bertin)
}

world <- st_read(system.file("gpkg/world.gpkg", package = "bertin"),
                 layer = "world", quiet = TRUE)
img <- paste0("file://",system.file("png/bertin.png", package = "bertin"))

bt_param(margin = 10, width = 500, projection = "Winkel3") |>
  bt_layer(data = world, fill = "red") |>
  bt_logo(url = img) |>
  bt_draw()

Created on 2023-05-11 with reprex v2.0.2
logo_local

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.