Description Usage Arguments Value Examples
ggplot2 mapping
1 2 3 4 5 6 7 8 9 10 11 | map_ggplot(
x,
map = "world",
point_color = "#86161f",
color = NULL,
size = 3,
lon = "longitude",
lat = "latitude",
name = NULL,
...
)
|
x |
The data. An object of class |
map |
(character) One of world, world2, state, usa, county, france, italy, or nz |
point_color |
Default color of your points. Deprecated, use
|
color |
Default color of your points. |
size |
point size, Default: 3 |
lon, lat |
(character) Longitude and latitude variable names. Ignored
unless |
name |
(character) the column name that contains the name to use in
creating the map. If left |
... |
Ignored |
A ggplot2 map, of class gg/ggplot
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 51 52 53 54 55 56 57 58 59 | # map spocc output, here using a built in object
data(occdat_eg1)
map_ggplot(occdat_eg1)
# map rgbif output, here using a built in object
data(gbif_eg1)
map_ggplot(gbif_eg1)
## Not run:
## spocc
library("spocc")
ddat <- occ(query = 'Lynx rufus californicus', from = 'gbif', limit=100)
map_ggplot(ddat)
map_ggplot(ddat$gbif)
map_ggplot(ddat$gbif, "usa")
map_ggplot(ddat, "county")
### usage of occ2sp()
#### SpatialPoints
spdat <- occ2sp(ddat)
map_ggplot(spdat)
#### SpatialPointsDataFrame
spdatdf <- as(spdat, "SpatialPointsDataFrame")
map_ggplot(spdatdf)
## rgbif
if (requireNamespace("rgbif")) {
library("rgbif")
library("ggplot2")
### occ_search() output
res <- occ_search(scientificName = "Puma concolor", limit = 100)
map_ggplot(res)
### occ_data() output
res <- occ_data(scientificName = "Puma concolor", limit = 100)
map_ggplot(res)
#### many taxa
res <- occ_data(scientificName = c("Puma concolor", "Quercus lobata"),
limit = 30)
map_ggplot(res)
### add a convex hull
hull(map_ggplot(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_ggplot(df)
# many species, each gets a different color
library("spocc")
spp <- c('Danaus plexippus', 'Accipiter striatus', 'Pinus contorta')
dat <- occ(spp, from = 'gbif', limit = 30, has_coords = TRUE)
map_ggplot(dat, color = c('#976AAE', '#6B944D', '#BD5945'))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.