map_gist: Make an interactive map to view in the browser as a GitHub...

Description Usage Arguments Details Examples

View source: R/map_gist.R

Description

Make an interactive map to view in the browser as a GitHub gist

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
map_gist(
  x,
  description = "",
  public = TRUE,
  browse = TRUE,
  lon = "longitude",
  lat = "latitude",
  name = NULL,
  ...
)

Arguments

x

The data. An object of class occdat, occdatind, gbif, gbif_data, SpatialPoints, SpatialPointsDataFrame, or data.frame. The package spocc needed for the first two, and rgbif needed for the third. When data.frame input, any number of columns allowed, but with at least the following: name (the taxonomic name), latitude (in dec. deg.), longitude (in dec. deg.)

description

Description for the Github gist, or leave to default (=no description)

public

(logical) Whether gist is public (default: TRUE)

browse

If TRUE (default) the map opens in your default browser.

lon, lat

(character) Longitude and latitude variable names. Ignored unless data.frame input to x parameter. We attempt to guess, but if nothing close, we stop. Default: longitude and latitude

name

(character) the column name that contains the name to use in creating the map. If left NULL we look for a "name" column.

...

Further arguments passed on to style_geojson()

Details

See gistr::gist_auth() for help on authentication

Does not support adding a convex hull via hull()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
## Not run: 
## spocc
library("spocc")
spp <- c('Danaus plexippus', 'Accipiter striatus', 'Pinus contorta')
dat <- spocc::occ(spp, from=c('gbif','ecoengine'), limit=30,
  gbifopts=list(hasCoordinate=TRUE))

# Define colors
map_gist(dat, color=c('#976AAE','#6B944D','#BD5945'))

# Define colors and marker size
map_gist(dat, color=c('#976AAE','#6B944D','#BD5945'),
  size=c('small','medium','large'))

# Define symbols
map_gist(dat, symbol=c('park','zoo','garden'))

## rgbif
if (requireNamespace("rgbif")) {
library("rgbif")
### occ_search() output
res <- occ_search(scientificName = "Puma concolor", limit = 100)
map_gist(res)

### occ_data() output
res <- occ_data(scientificName = "Puma concolor", limit = 100)
map_gist(res)

#### many taxa
res <- occ_data(scientificName = c("Puma concolor", "Quercus lobata"), 
   limit = 30)
res
map_gist(res)
}

## data.frame
df <- data.frame(name = c('Poa annua', 'Puma concolor', 'Foo bar'),
                 longitude = c(-120, -121, -121),
                 latitude = c(41, 42, 45), stringsAsFactors = FALSE)
map_gist(df)

### usage of occ2sp()
#### SpatialPoints
spdat <- occ2sp(dat)
map_gist(spdat)
#### SpatialPointsDataFrame
spdatdf <- as(spdat, "SpatialPointsDataFrame")
map_gist(spdatdf)

## End(Not run)

mapr documentation built on Oct. 23, 2020, 8:22 p.m.