map_plot | R Documentation |
Base R mapping
map_plot( x, lon = "longitude", lat = "latitude", color = NULL, size = 1, pch = 16, hull = FALSE, name = NULL, ... )
x |
The data. An object of class |
lon, lat |
(character) Longitude and latitude variable names. Ignored
unless |
color |
Default color of your points. |
size |
point size, passed to |
pch |
point symbol shape, Default: 16 |
hull |
(logical) whether to add a convex hull. Default: |
name |
(character) the column name that contains the name to use in
creating the map. If left |
... |
Further args to |
Plots a world scale map
# map spocc output, here using a built in object data(occdat_eg1) map_plot(occdat_eg1) # map rgbif output, here using a built in object data(gbif_eg1) map_plot(gbif_eg1) ## Not run: ## spocc library("spocc") (out <- occ(query='Accipiter striatus', from='gbif', limit=25, has_coords=TRUE)) ### class occdat map_plot(out) map_plot(out, hull = TRUE) ### class occdatind map_plot(out$gbif) map_plot(out$gbif, hull = TRUE) ## rgbif if (requireNamespace("rgbif")) { library("rgbif") ### occ_search() output res <- occ_search(scientificName = "Puma concolor", limit = 100) map_plot(res) map_plot(res, hull = TRUE) ### occ_data() output res <- occ_data(scientificName = "Puma concolor", limit = 100) map_plot(res) #### many taxa res <- occ_data(scientificName = c("Puma concolor", "Quercus lobata"), limit = 30) res map_plot(res) } ## data.frame df <- data.frame( name = c('Poa annua', 'Puma concolor', 'Foo bar', 'Stuff things'), longitude = c(-125, -123, -121, -110), latitude = c(41, 42, 45, 30), stringsAsFactors = FALSE) map_plot(df) map_plot(df, hull = TRUE) ### usage of occ2sp() #### SpatialPoints spdat <- occ2sp(out) map_plot(spdat) map_plot(spdat, hull = TRUE) #### SpatialPointsDataFrame spdatdf <- as(spdat, "SpatialPointsDataFrame") map_plot(spdatdf) map_plot(spdatdf, hull = TRUE) # many species, each gets a different color library("spocc") spp <- c('Danaus plexippus', 'Accipiter striatus', 'Pinus contorta', 'Ursus americanus') dat <- occ(spp, from = 'gbif', limit = 30, has_coords = TRUE, gbifopts = list(country = 'US')) map_plot(dat) map_plot(dat, hull = TRUE) ## diff. color for each taxon map_plot(dat, color = c('#976AAE', '#6B944D', '#BD5945', 'red')) map_plot(dat, color = c('#976AAE', '#6B944D', '#BD5945', 'red'), hull = TRUE) # add a convex hull if (requireNamespace("rgbif")) { library("rgbif") res <- occ_search(scientificName = "Puma concolor", limit = 100) map_plot(res, hull = FALSE) map_plot(res, hull = TRUE) } ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.