Title: | Quickly Map and Explore Spatial Data |
---|---|
Description: | While analyzing geospatial data, easy visualization is often needed that allows for quick plotting, and simple, but easy interactivity. Additionally, visualizing geospatial data in projected coordinates is also desirable. The 'quickmapr' package provides a simple method to visualize 'sp', 'sf' (via coercion to 'sp'), and 'raster' objects, allows for basic zooming, panning, identifying,labeling, selecting, and measuring spatial objects. Importantly, it does not require that the data be in geographic coordinates. |
Authors: | Jeffrey W. Hollister [aut] |
Maintainer: | Jeffrey W. Hollister <[email protected]> |
License: | CC0 |
Version: | 0.4.0 |
Built: | 2025-02-03 03:08:44 UTC |
Source: | https://github.com/geogugal/quickmapr |
quickmapr
examplesThis example data is a SpatialPolygonsDataFrame representing a buffer of a single lake, Lake Sunapee.
SpatialPolygonsDataFrame
quickmapr
examplesThis example data is a RasterLayer of the National Elevation Dataset for a buffer of Lake Sunapee.
RasterLayer of 455 x 246 and 30 meter resolution
quickmapr
examplesThis example data is a polygon dataset of many lakes in New Hampshire. Data for each lake are from the first version of the National Lakes Morphometry Dataset.
SpatialPolygonsDataFrame
Allows for restoring map to original extent. The inital map is replayed and the map extent of the object is reset to match the current display.
f(qmap_obj = NULL)
f(qmap_obj = NULL)
qmap_obj |
a qmap_obj to restore |
## Not run: data(lake) x<-qmap(list(lake,buffer,elev)) zi(x) f(x) ## End(Not run)
## Not run: data(lake) x<-qmap(list(lake,buffer,elev)) zi(x) f(x) ## End(Not run)
Interactively select an sp
or raster
object and print the
data associated with it. i()
only accepts a single input point.
i(qmap_obj = NULL, i_idx = 1, loc = NULL)
i(qmap_obj = NULL, i_idx = 1, loc = NULL)
qmap_obj |
a |
i_idx |
a numeric value specifying which data layer to identify or a character string indicating the name of the layer. Defaults to 1. |
loc |
A list with an x and y numeric indicating a location. Default is to interactively get loc value until escaped. |
Returns NULL. Identified values are printed to the screen.
## Not run: data(lake) qm<-qmap(list(lake,elev,samples)) i(qm,"lake") i(qm,"samples") i(qm,2) ## End(Not run)
## Not run: data(lake) qm<-qmap(list(lake,elev,samples)) i(qm,"lake") i(qm,"samples") i(qm,2) ## End(Not run)
It is useful to be able to provide labels to features on your map when examining the results of given analysis. This function adds labels for a given layer (currently just point or polygon layers).
l(qmap_obj, field = NULL, layer = 1)
l(qmap_obj, field = NULL, layer = 1)
qmap_obj |
a qmap object from which to pull the labels. Raster layers
are ignored. Will also accept |
field |
a field in the sp object to use to label the features. Defaults to row.names(). |
layer |
identify which sp layer to label. Defaults to first layer in qmap_obj$map_data. |
## Not run: data(lake) qm<-qmap(lake,width,buffer) l(qm,'COMID') l(qm, layer = 2) l(qm, layer = "buffer") ## End(Not run)
## Not run: data(lake) qm<-qmap(lake,width,buffer) l(qm,'COMID') l(qm, layer = 2) l(qm, layer = "buffer") ## End(Not run)
quickmapr
examplesThis example data is a SpatialPolygonsDataFrame of a single lake, Lake Sunapee.
SpatialPolygonDataframe with 1 lakes, each with 13 variables
quickmapr
examplesThis example data is a line dataset representing the maximum lake length.
SpatialLines
Allows interactive selection of points and returns length of selecte line in
units of the current qmap
object.
m(qmap_obj = NULL)
m(qmap_obj = NULL)
qmap_obj |
a |
quickmapr
examplesThis example data is a RasterLayer of the National Land Cover Dataset for a buffer of Lake Sunapee.
RasterLayer of 467 x 262 and 30 meter resolution
Interactively reposition the current plot. Works on an existing
qmap
object. Simply pass that object to p()
. A single
repositioning results and the extent of the qmap
object is changed.
p(qmap_obj = NULL, loc = NULL)
p(qmap_obj = NULL, loc = NULL)
qmap_obj |
A qmap object. Optional, but performs better with larger data sets. |
loc |
A list with an x and y numeric indicating a location. Default is to interactively get loc value until escaped. |
## Not run: data(lake) x<-qmap(list(lake,buffer,elev)) p() ## Or p(x) ## End(Not run)
## Not run: data(lake) x<-qmap(list(lake,buffer,elev)) p() ## Or p(x) ## End(Not run)
Plots the qmap class and uses the order, colors, extent, and fill option
from qmap
.
## S3 method for class 'qmap' plot(x, ...)
## S3 method for class 'qmap' plot(x, ...)
x |
input qmap class to plotS |
... |
options passed to image or plot |
Plots a qmap object
## S3 method for class 'qmap' print(x, ...)
## S3 method for class 'qmap' print(x, ...)
x |
input qmap class to print |
... |
options passed to plot |
This function builds the qmap object that forms the basis for the rest of
the quickmapr
package.
qmap( ..., extent = NULL, order = 1:length(mapdata), colors = 1:length(mapdata), fill = FALSE, prj = TRUE, basemap = c("none", "1m_aerial", "topo"), resolution = 300 )
qmap( ..., extent = NULL, order = 1:length(mapdata), colors = 1:length(mapdata), fill = FALSE, prj = TRUE, basemap = c("none", "1m_aerial", "topo"), resolution = 300 )
... |
Spatial objects to map. Maybe passed as objects, a list of
spatial objects, or a |
extent |
A |
order |
draw order of the spatial object. Defaults to order in mapdata |
colors |
line colors. Defaults to 1:length(mapdata) |
fill |
Logical to determine if polygons should be filled (using colors) or just the border colored. |
prj |
Logical to check projections of input spatial objects.
Transformation, if needed, should be done prior to mapping with
|
basemap |
a basemap generated from |
resolution |
Specifies the width in pixels of the retrieved basemap. Larger values result in higher resolution images but since the images are downloaded for each zoom level can result in delays. Default is 300, while ~600 is a decent compromise for performance and image quality. |
Function displays a map from the input mapdata
parameter and
returns a recorded plot.
## Not run: data(lake) mymap<-list(elev,lake,buffer,length,samples) qm<-qmap(mymap) #change draw order and which data is displayed qmap(qm,order=c(2,3,5)) #add a basemap qm<-qmap(qm,basemap="1m_aerial", resolution = 800) ## End(Not run)
## Not run: data(lake) mymap<-list(elev,lake,buffer,length,samples) qm<-qmap(mymap) #change draw order and which data is displayed qmap(qm,order=c(2,3,5)) #add a basemap qm<-qmap(qm,basemap="1m_aerial", resolution = 800) ## End(Not run)
This package provides tools to quickly viusalize and interact with
sp
and raster
objects. Simple interactivity
includes panning, zooming, identifying, and labelling. The goal of
quickmapr
is to make working with spatial data easy and quick,
it is not intended to provide publication quality maps.
Interactively select a single sp
or raster
object and return the
object. s()
only accepts a single input point.
s(qmap_obj = NULL, s_idx = 1, loc = NULL)
s(qmap_obj = NULL, s_idx = 1, loc = NULL)
qmap_obj |
a |
s_idx |
a numeric value specifying which data layer to select or a character string indicating the name of the layer. Defaults to 1. |
loc |
A list with an x and y numeric indicating a location. Default is to interactively get loc value. |
Returns a selected sp
object
## Not run: data(lake) qm<-qmap(list(lake,elev,samples)) s(qm,"lake") s(qm,3) ## End(Not run)
## Not run: data(lake) qm<-qmap(list(lake,elev,samples)) s(qm,"lake") s(qm,3) ## End(Not run)
quickmapr
examplesThis is a fabricated point dataset for what might be a common type of data collected for a lake.
This example data is a fabricated point dataset with data for each location.
SpatialPointsDataFrame
SpatialPointsDataFrame
quickmapr
examplesThis example data is a line dataset representing the maximum lake width. Maximum lake width is defined as the longest line perpendciular to the maximum lake length.
SpatialLines
Select a bounding box interactively and zoom to that extent. Works on an existing
qmap
object. Simply pass that object to ze()
. A single zoom in to
the selected
extent results and the extent of the qmap
object is changed.
ze(qmap_obj = NULL, extent = NULL)
ze(qmap_obj = NULL, extent = NULL)
qmap_obj |
A qmap object. Optional, but performs better with larger data sets. |
extent |
A Spatial* object to specify extent to zoom into. |
## Not run: data(lake) qmap(list(lake,buffer,elev)) ze() ## End(Not run)
## Not run: data(lake) qmap(list(lake,buffer,elev)) ze() ## End(Not run)
Interactively zoom in on the current plot. Works on an existing
qmap
object. Simply pass that object to zi()
. A single zoom in
results and the extent of the
qmap
object is changed.
zi(qmap_obj = NULL, zoom_perc = 0.5, loc = NULL)
zi(qmap_obj = NULL, zoom_perc = 0.5, loc = NULL)
qmap_obj |
A qmap object. Optional, but performs better with larger data sets. |
zoom_perc |
A proportion to determine the zoom level. The x and y axes are reduced by this amount. Default is 0.5. |
loc |
A list with an x and y numeric indicating a location. Default is to interactively get loc value until escaped. |
## Not run: data(lake) x<-qmap(list(lake,buffer,elev)) zi(x) ## End(Not run)
## Not run: data(lake) x<-qmap(list(lake,buffer,elev)) zi(x) ## End(Not run)
Interactively zoom out on the current plot. Works on an existing
qmap
object. Simply pass that object to zo()
. A single zoom
out results and the extent of the qmap
object is changed.
zo(qmap_obj = NULL, zoom_perc = 0.5, loc = NULL)
zo(qmap_obj = NULL, zoom_perc = 0.5, loc = NULL)
qmap_obj |
A qmap object. Optional, but performs better with larger data sets. |
zoom_perc |
A proportion to determine the zoom level. The x and y axes are increased by this amount. Default is 0.5. |
loc |
A list with an x and y numeric indicating a location. Default is to interactively get loc value until escaped. |
## Not run: data(lake) qm<-qmap(list(lake,buffer,elev)) zo(qm) ## End(Not run)
## Not run: data(lake) qm<-qmap(list(lake,buffer,elev)) zo(qm) ## End(Not run)