d3_map: Create a map in D3

Description Usage Arguments Examples

Description

Create a map in D3

Usage

1
2
d3_map(shape, projection = "Mercator", stroke_col = "#fff",
  stroke_width = 0.5, width = NULL, height = NULL)

Arguments

shape

A sf or sp object.

projection

D3 projection to use.

stroke_col

Color of shape contours.

stroke_width

Width of shape contour in pixels.

width

Desired width for output widget.

height

Desired height for output widget.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
library( sf )
library( rnaturalearth )
library( r2d3maps )

# Hello world!
world <- st_as_sf(countries110)
d3_map(shape = world)

# Brazil!
brazil <- ne_states(country = "brazil", returnclass = "sf")
d3_map(shape = brazil)

# Italy!
italy <- ne_states(country = "italy", returnclass = "sf")
d3_map(shape = italy)

# Oceania!
oceania <- ne_countries(continent = "oceania", returnclass = "sf")
oceania <- sf::st_crop(oceania, xmin = 112, ymin = -56, xmax = 194, ymax = 12)
d3_map(shape = oceania) %>%
  add_tooltip()

dreamRs/r2d3maps documentation built on May 25, 2019, 8:17 a.m.