Creating a scale bar for a mapLaura TwardochlebSeptember 21, 2016Here I have modified a function to create a scale bar for a map. I will use an example map of black bear occurrences in the northeastern United States. The original code for the scale bar function was written by eipi10 at http://stackoverflow.com/questions/23784943/how-to-add-a-scale-bar-in-r
I will create the map of the northeast region and plot black bear occurrence data from GBIF (Global Biodiversity Information Facility) using the ‘raster’ library.
The above code produced a map with 100 km x 100 km resolution of bear occurrence data. Now I will add a custom scale bar illustrating 100 km on the map.
Clipping Points to a Raster (extract {raster})Megan KressSeptember 21, 2016
extract FunctionThe extract function extracts data from a Raster object based on the location of another set of spatial data (SpatialPoints, two-column data.frame, SpatialPolygons, etc.). The function comes from the raster package. For more information on the extract function, see the CRAN page for the raster package. For this example, I followed the general structure of Lab 02 (getting species occurrences from GBIF). I used data for the black bear, and clipped it to the outline of the Northeast region.
Preparation (from Lab 02)
Plot All Occurences
Plot Clipped Occurences
|
Spatial Ecology @ MSUClick on "Category" below to search for R code compiled by the Zarnetske Spatial & Community Ecology Lab and students in MSU's Spatial Ecology graduate course (FOR870/FW870) Category
All
Archive
October 2016
|