Title: | Further Capabilities in Geographic Information Science |
---|---|
Description: | Mapping and spatial data manipulation tools - in particular drawing thematic maps with nice looking legends, and aggregation of point data to polygons. |
Authors: | Chris Brunsdon [aut], Binbin Lu [aut, cre], Hongyan Chen [aut] |
Maintainer: | Binbin Lu <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.0-2 |
Built: | 2025-01-31 03:08:10 UTC |
Source: | https://github.com/cran/GISTools |
In this package, a number of utilities for handling and visualising geographical data of a “Spatial” or “sf” object - for example choropleth mapping with 'nice' legends.
Package: | GISTools |
Type: | Package |
Version: | 1.0-2 |
Date: | 2024-10-03 |
License: | GPL (>=2) |
LazyLoad: | yes |
Takes an ‘mask’ type polygon object - basically a rectangle with a polygon hole cut through it - and draws this over an image. This has the effect of only showing the image inside the hole. This is useful for plotting surfaces defined over a study area, but masking the values outside of the area.
add.masking(maskPoly,color)
add.masking(maskPoly,color)
maskPoly |
A masking polygon of a “Spatial” or “sf” class as described above. |
color |
Colour of the mask. Defaults to white, but for example, sea could be shown as blue. |
Returns no value, but draws a mask on the current graphics device as a side effect
None
Chris Brunsdon, Binbin Lu
# Data for New Haven to use in example data(newhaven) # Do the KDE breach.dens = kde.points(breach,lims=tracts) # Plot the result level.plot(breach.dens) # Block out the part outside the study area masker = poly.outer(breach.dens,tracts,extend=100); add.masking(masker) add.masking(masker,"blue")
# Data for New Haven to use in example data(newhaven) # Do the KDE breach.dens = kde.points(breach,lims=tracts) # Plot the result level.plot(breach.dens) # Block out the part outside the study area masker = poly.outer(breach.dens,tracts,extend=100); add.masking(masker) add.masking(masker,"blue")
Creates an object of class shading
automatically, given a choropleth variable to be mapped.
auto.shading(x, digits = 2, cutter = quantileCuts, n = 5, params = NA, cols = brewer.pal(n, "Reds"))
auto.shading(x, digits = 2, cutter = quantileCuts, n = 5, params = NA, cols = brewer.pal(n, "Reds"))
x |
The variable to be mapped. |
digits |
The number of significant digits to round the class limits to. |
cutter |
Function used to create the break points. Can be user defined or a supplied cut function. |
n |
The number of classes. The should be one more than the number of break points. |
params |
Other parameters to be passed to the cut function. |
cols |
List of colours for shading each class. |
Returns an object of class shading
, as set out below:
An object of class shading
, having the following list elements:
breaks |
Break points between choropleth classes. |
cols |
Colours to shade in each class. |
Chris Brunsdon, Binbin Lu
choropleth
,shading
,choro.legend
.
# Read in map data and compute a rate for mapping # Try the sf class data(WHData) shades = auto.shading(WHHP[["Avg_HP_avg"]],n=7) dev.new(width = 16, height = 12) choropleth(sp = WHHP,v="Avg_HP_avg",shading=shades) choro.legend(548871.4, 3377000, shades,title='Average house price') #Try the Spatial object shades = auto.shading(whp_sp@data[["Avg_HP_avg"]],n=6) dev.new(width = 16, height = 12) choropleth(sp = whp_sp,v="Avg_HP_avg",shading=shades) choro.legend(548871.4, 3377000, shades,title='Average house price')
# Read in map data and compute a rate for mapping # Try the sf class data(WHData) shades = auto.shading(WHHP[["Avg_HP_avg"]],n=7) dev.new(width = 16, height = 12) choropleth(sp = WHHP,v="Avg_HP_avg",shading=shades) choro.legend(548871.4, 3377000, shades,title='Average house price') #Try the Spatial object shades = auto.shading(whp_sp@data[["Avg_HP_avg"]],n=6) dev.new(width = 16, height = 12) choropleth(sp = whp_sp,v="Avg_HP_avg",shading=shades) choro.legend(548871.4, 3377000, shades,title='Average house price')
Draw a legend for a choropleth map.
choro.legend(px, py, sh, under = "under", over = "over", between = "to", fmt = "%g", cex=1, ...)
choro.legend(px, py, sh, under = "under", over = "over", between = "to", fmt = "%g", cex=1, ...)
px |
x coordinate of legend location |
py |
y coordinate of legend location |
sh |
Shading scheme object used as basis for the legend |
under |
What to write in front of the lowest choropleth class upper limit. |
over |
What to write in front of the highest choropleth class lower limit. |
between |
What to write between the upper and lower limits of intermediate chropleth classes. |
fmt |
C style format for values stated in above choroplth class limits. |
cex |
Relative size of text in the legend. |
... |
Other arguments, passed on to the generic |
Returns no value, but draws a choropleth map legend on the current graphics device as a side effect
None (see above)
Chris Brunsdon
choropleth
, auto.shading
, shading
.
# Read in map data and compute a rate for mapping # Try the sf class data(WHData) shades = auto.shading(WHHP[["Avg_HP_avg"]],n=7) dev.new(width = 16, height = 12) choropleth(sp = WHHP,v="Avg_HP_avg",shading=shades) choro.legend(548871.4, 3377000, shades,title='Average house price') #Try the Spatial object shades = auto.shading(whp_sp@data[["Avg_HP_avg"]],n=6) dev.new(width = 16, height = 12) choropleth(sp = whp_sp,v="Avg_HP_avg",shading=shades) choro.legend(548871.4, 3377000, shades,title='Average house price')
# Read in map data and compute a rate for mapping # Try the sf class data(WHData) shades = auto.shading(WHHP[["Avg_HP_avg"]],n=7) dev.new(width = 16, height = 12) choropleth(sp = WHHP,v="Avg_HP_avg",shading=shades) choro.legend(548871.4, 3377000, shades,title='Average house price') #Try the Spatial object shades = auto.shading(whp_sp@data[["Avg_HP_avg"]],n=6) dev.new(width = 16, height = 12) choropleth(sp = whp_sp,v="Avg_HP_avg",shading=shades) choro.legend(548871.4, 3377000, shades,title='Average house price')
Draws a choropleth map given a spatialPolygons object, a variable and a shading scheme.
choropleth(sp, v, shading, ...)
choropleth(sp, v, shading, ...)
sp |
A |
v |
The variable name to be mapped and must included in the data. |
shading |
A shading scheme created by |
... |
Additional parameters to be passed on to the |
The function returns no value, but draws a choropleth map on the current graphics device as a side effect.
None (see above).
Chris Brunsdon, Binbin Lu
choro.legend
, auto.shading
, shading
.
# Read in map data and compute a rate for mapping # Try the sf class data(WHData) shades = auto.shading(WHHP[["Avg_HP_avg"]],n=7) dev.new(width = 16, height = 12) choropleth(sp = WHHP,v="Avg_HP_avg",shading=shades) choro.legend(548871.4, 3377000, shades,title='Average house price') #Try the Spatial object shades = auto.shading(whp_sp@data[["Avg_HP_avg"]],n=6) dev.new(width = 16, height = 12) choropleth(sp = whp_sp,v="Avg_HP_avg",shading=shades) choro.legend(548871.4, 3377000, shades,title='Average house price')
# Read in map data and compute a rate for mapping # Try the sf class data(WHData) shades = auto.shading(WHHP[["Avg_HP_avg"]],n=7) dev.new(width = 16, height = 12) choropleth(sp = WHHP,v="Avg_HP_avg",shading=shades) choro.legend(548871.4, 3377000, shades,title='Average house price') #Try the Spatial object shades = auto.shading(whp_sp@data[["Avg_HP_avg"]],n=6) dev.new(width = 16, height = 12) choropleth(sp = whp_sp,v="Avg_HP_avg",shading=shades) choro.legend(548871.4, 3377000, shades,title='Average house price')
Operations for bootstrapping and kernel bootstrapping based on point data. bstrap.points
sample n
points with replacement from a sample - and jitter.points
adds a Gaussian displacement to each point in a data set. Applying a jitter to a bootstrap effectively creates a kernel bootstrap operation.
jitter.points(pts,scl) bstrap.points(pts)
jitter.points(pts,scl) bstrap.points(pts)
pts |
A |
scl |
A scale parameter - basically the standard deviation of the random Gaussian displacement |
A SpatialPointsDataFrame
- with either a sample without replacement or a replica of the input data with displacements.
Chris Brunsdon, Binbin Lu
data(newhaven) plot(blocks) for (i in 1:20) plot(jitter.points(breach,150),add=TRUE,pch=1,col='red')
data(newhaven) plot(blocks) for (i in 1:20) plot(jitter.points(breach,150),add=TRUE,pch=1,col='red')
Takes a polygon object and creates a new polygon whose outline is rectangular, but has a hole shaped like the input polygon cut into it. This is useful for plotting surfaces defined over a study area, but masking the values outside of the area. It is designed to work with pixel images, so that the mask covers up all parts of the image not in the input polygon.
poly.outer(exo.object,input.poly,extend=0)
poly.outer(exo.object,input.poly,extend=0)
exo.object |
The object extending beyond |
input.poly |
The polygon used to make the hole in the mask. |
extend |
A buffer used to extend the mask if it is required to be larger than |
A polygon object whose outline is rectangular, but having holes cut into it in the shape of input.poly
Chris Brunsdon, Binbin Lu
# Data for New Haven to use in example data(newhaven) # Do the KDE breach.dens = kde.points(breach,lims=tracts) # Plot the result level.plot(breach.dens) # Block out the part outside the study area masker = poly.outer(breach.dens,tracts,extend=100); add.masking(masker) # Plot census tract boundaries plot(tracts,add=TRUE)
# Data for New Haven to use in example data(newhaven) # Do the KDE breach.dens = kde.points(breach,lims=tracts) # Plot the result level.plot(breach.dens) # Block out the part outside the study area masker = poly.outer(breach.dens,tracts,extend=100); add.masking(masker) # Plot census tract boundaries plot(tracts,add=TRUE)
Takes a colour defined in hex format as #XXXXXX
and adds a two transparency bytes XX
based on a number from 0 to 1. Its main use is to make RColorBrewer palettes transparent.
add.alpha(hex.color.list,alpha)
add.alpha(hex.color.list,alpha)
hex.color.list |
A list of strings defining solid colors in six byte format. |
alpha |
A value (or list of values) from 0 to 1 specifying transparency. |
A list of strings defining transparent colours in eight byte format.
Chris Brunsdon
# Make a list of semi-transparent RColorBrewer colours, based on Brewer's Red palette with 5 shades require(RColorBrewer) add.alpha(brewer.pal(5,'Reds'),0.5)
# Make a list of semi-transparent RColorBrewer colours, based on Brewer's Red palette with 5 shades require(RColorBrewer) add.alpha(brewer.pal(5,'Reds'),0.5)
Helper functions for auto.shading
. Given a variable to be mapped, a number of classes and possibly some more params
, returns a list of break values. There should be one less break value than the number of classes.
quantileCuts(x, n = 5, params = NA) sdCuts(x, n = 5, params = NA) rangeCuts(x, n = 5, params = NA)
quantileCuts(x, n = 5, params = NA) sdCuts(x, n = 5, params = NA) rangeCuts(x, n = 5, params = NA)
x |
The variable to be mapped. |
n |
The number of classes. |
params |
Extra params for individual cut functions. |
An ordered list of the break values between classes
The only cut function using params
is quantileCuts
, where it is used to specify a list of quantile values - useful if they are not evenly spaced.
Chris Brunsdon
Generalises a SpatialPolygons
or SpatialPolygonsDataFrame
or a sf
-POLYGON or - MULTIPOLYGON object using the Douglas-Peuker algorithm
generalize.polys(sfo, preserveTopology, dTolerance)
generalize.polys(sfo, preserveTopology, dTolerance)
sfo |
A |
preserveTopology |
logical; carry out topology preserving simplification? May be specified for each, or for all feature geometries. Note that topology is preserved only for single feature geometries, not for sets of them. |
dTolerance |
numeric; tolerance parameter, specified for all or for each feature geometry. |
Returns an object of the same class as sp
. Note that the algorithm is applied on a polygon-by-polygon,
not edge-by-edge basis. Thus edges in generalised polygons may not match perfectly.
An object of class SpatialPolygons
or SpatialPolygonsDataFrame
. Each polygon shape has been
generalized using the Douglas-Peuker algorithm.
Chris Brunsdon, Binbin Lu
# Data for Georgia to use in example data(WHData) WH.outline <- st_union(WHHP) WH.generalised <- generalize.polys(WH.outline,TRUE,0.1) plot(st_geometry(WHHP)) plot(st_geometry(WH.generalised),add=TRUE,border='red',lwd=2)
# Data for Georgia to use in example data(WHData) WH.outline <- st_union(WHHP) WH.generalised <- generalize.polys(WH.outline,TRUE,0.1) plot(st_geometry(WHHP)) plot(st_geometry(WH.generalised),add=TRUE,border='red',lwd=2)
Polygon Data Frame as used in the Brunsdon, Fotheringham & Charlton GWR book, with further variable median income (MedInc)
data(georgia)
data(georgia)
georgia Georgia polygons SpatialPolygonsDataFrame
- geographical projection
georgia2 Georgia polygons SpatialPolygonsDataFrame
- equal area projection
georgia.polys Georgia polygons in list format - equal area projection
# Read in the data data(georgia) # Make a map of median income choropleth(georgia2,"MedInc")
# Read in the data data(georgia) # Make a map of median income choropleth(georgia2,"MedInc")
Given a set of points, a bandwidth, a grid density and a frame, produce a kernel density estimate
kde.points(pts,h,n=200,lims=NULL)
kde.points(pts,h,n=200,lims=NULL)
pts |
A |
h |
A real number - the bandwidth of the KDE |
n |
An integer, the output grid density - ie result is nxn grid |
lims |
A spatial object - the KDE grid will cover this, if provided |
A SpatialPixelsDataFrame
containing the KDE.
Chris Brunsdon, Binbin Lu
# Data for New Haven to use in example data(newhaven) # Do the KDE breach.dens = kde.points(breach,lims=tracts) # Plot the result level.plot(breach.dens) # Block out the part outside the study area masker = poly.outer(breach.dens,tracts,extend=100); add.masking(masker) # Plot census tract boundaries plot(tracts,add=TRUE)
# Data for New Haven to use in example data(newhaven) # Do the KDE breach.dens = kde.points(breach,lims=tracts) # Plot the result level.plot(breach.dens) # Block out the part outside the study area masker = poly.outer(breach.dens,tracts,extend=100); add.masking(masker) # Plot census tract boundaries plot(tracts,add=TRUE)
Draws a level plot given a SpatialPixelsDataFrame, an index and a shading scheme.
level.plot(grd, shades, index=1, add=FALSE)
level.plot(grd, shades, index=1, add=FALSE)
grd |
A |
shades |
A shading scheme created by |
index |
Index giving the variable in |
add |
Whether to add the level plot to an existing plot. |
The function returns no value, but draws a level plot on the current graphics device as a side effect.
None (see above).
Chris Brunsdon, Binbin Lu
# Data for New Haven to use in example data(newhaven) # Do the KDE breach.dens = kde.points(breach,lims=tracts) # Plot the result level.plot(breach.dens)
# Data for New Haven to use in example data(newhaven) # Do the KDE breach.dens = kde.points(breach,lims=tracts) # Plot the result level.plot(breach.dens)
Draws a scale bar on a map.
map.scale(xc,yc,len,units,ndivs,subdiv=1,tcol='black',scol='black',sfcol='black')
map.scale(xc,yc,len,units,ndivs,subdiv=1,tcol='black',scol='black',sfcol='black')
xc |
The x-centre (in map units) of the scale bar |
yc |
The y-centre (in map units) of the scale bar |
len |
The length (in map units) of the scale bar |
units |
String specifying the name of the units for the scale bar |
ndivs |
The number of divisions (units marked) on the scale |
subdiv |
The fraction of |
tcol |
The colour of text on the scale bar. |
scol |
The colour of the scale bar itself. |
sfcol |
The colour of the filled rectangles in the scale bar. |
Draws an alternating bar scale on a map. Returns no value.
None (see above)
Chris Brunsdon
# Read in map data for New Haven data(newhaven) # Plot census block boundaries plot(blocks) # Add a map scale map.scale(534750,152000,miles2ft(2),"Miles",4,0.5,sfcol='red') # ... and a title title('New Haven (CT)')
# Read in map data for New Haven data(newhaven) # Plot census block boundaries plot(blocks) # Add a map scale map.scale(534750,152000,miles2ft(2),"Miles",4,0.5,sfcol='red') # ... and a title title('New Haven (CT)')
Data set from New Haven (CT) crime web site containing point sources of some crimes, plus roads, railways and census block spatial data frames.
data(newhaven)
data(newhaven)
blocks Census blocks SpatialPolygonsDataFrame
roads Roads SpatialLinesDataFrame
places Place names SpatialPointsDataFrame
breach Breach of peace SpatialPointsDataFrame
famdisp Family dispute SpatialPointsDataFrame
tracts Census tracts SpatialPolygonsDataFrame
burgres.f Residential Burglary (Forced) SpatialPointsDataFrame
burgres.n Residential Burglary (Non-Forced) SpatialPointsDataFrame
http://www.newhavencrimelog.org/
# Read in map data for New Haven data(newhaven) # Plot census block boundaries plot(blocks) # Add a map scale map.scale(534750,152000,miles2ft(2),"Miles",4,0.5,sfcol='red') # ... and a title title('New Haven (CT)')
# Read in map data for New Haven data(newhaven) # Plot census block boundaries plot(blocks) # Add a map scale map.scale(534750,152000,miles2ft(2),"Miles",4,0.5,sfcol='red') # ... and a title title('New Haven (CT)')
Draws a north arrow on a map.
north.arrow(xb,yb,len,lab='NORTH',cex.lab=1,tcol='black',...)
north.arrow(xb,yb,len,lab='NORTH',cex.lab=1,tcol='black',...)
xb |
The x-centre (in map units) of the arrow base. |
yb |
The y-centre (in map units) of the arrow base. |
len |
The length (in map units) of the arrow base. |
lab |
The label for the arrow. |
cex.lab |
Scale factor for the label for the arrow. |
tcol |
The colour of the label text. |
... |
Other graphical parameters passed to the drawing of the arrow. |
Draws a north arrow on a map. The arrow itself is drawn using polygon
and any extra parameters are passed to this call.
None.
Chris Brunsdon
# Read in map data for New Haven data(newhaven) # Plot census block boundaries plot(blocks) # Add a north arrow north.arrow(534750,152000,miles2ft(0.5),col='cyan') # ... and a title title('New Haven (CT)')
# Read in map data for New Haven data(newhaven) # Plot census block boundaries plot(blocks) # Add a north arrow north.arrow(534750,152000,miles2ft(0.5),col='cyan') # ... and a title title('New Haven (CT)')
Data set from Schwartz, M.D. and J.M. Caprio, 2003, North American First Leaf and First Bloom Lilac Phenology Data, IGBP PAGES/World Data Center for Paleoclimatology Data Contribution Series # 2003-078. NOAA/NGDC Paleoclimatology Program, Boulder CO, USA.
data(phenology)
data(phenology)
chinensis Syringa Chinensis Observation Stations SpatialPointsDataFrame
- geographical projection
chinensis2 Syringa Chinensis Observation Stations SpatialPointsDataFrame
- equal area projection
us_states States of US SpatialPolygonsDataFrame
- geographical projection
us_states2 States of US SpatialPolygonsDataFrame
- equal area projection
http://www.ncdc.noaa.gov/paleo/phenology.html
# Read in the data data(phenology) # Split the plot in two opar <- par(mfrow=c(2,1)) # Plot US states plot(us_states2) # Add Locations of observation stations plot(chinensis2,add=TRUE,pch=16,col='red') # Plot a histogram of year of observation next to this hist(chinensis2$Year) par(opar)
# Read in the data data(phenology) # Split the plot in two opar <- par(mfrow=c(2,1)) # Plot US states plot(us_states2) # Add Locations of observation stations plot(chinensis2,add=TRUE,pch=16,col='red') # Plot a histogram of year of observation next to this hist(chinensis2$Year) par(opar)
Given a set of points, and a set of polygons, computes the number of points in each polygon.
poly.counts(pts, polys)
poly.counts(pts, polys)
pts |
A |
polys |
A |
A list of integers of the same length as the number of polygons in polys
, giving the number of points from pts
.
Chris Brunsdon, Binbin Lu
# Data for New Haven to use in example data(newhaven) # How many breaches of peace in each census block? n.breach = poly.counts(breach,blocks) blocks@data$Count.per <- n.breach/poly.areas(blocks) # Compute densities and map them choropleth(blocks,"Count.per")
# Data for New Haven to use in example data(newhaven) # How many breaches of peace in each census block? n.breach = poly.counts(breach,blocks) blocks@data$Count.per <- n.breach/poly.areas(blocks) # Compute densities and map them choropleth(blocks,"Count.per")
Given a set of polygons, returns the area of each polygon.
poly.areas(polys)
poly.areas(polys)
polys |
A |
A list of areas of the same length as the number of polygons in polys
.
Chris Brunsdon, Binbin Lu
# Data for New Haven to use in example data(newhaven) # What is the area each census block? poly.areas(blocks)
# Data for New Haven to use in example data(newhaven) # What is the area each census block? poly.areas(blocks)
Given a set of polygons, returns the label point for each polygon in a SpatialPoints or a sf POINT object.
poly.labels(polys)
poly.labels(polys)
polys |
A |
SpatialPoints or sf POINT object containing the label point for each polygon, respectively.
Chris Brunsdon, Binbin Lu
Creates an object of class shading
by directly specifying break values and (optionally) colours.
shading(breaks, cols = brewer.pal(length(breaks), "Reds"))
shading(breaks, cols = brewer.pal(length(breaks), "Reds"))
breaks |
The break points |
cols |
The shading colours - there should be one more of these than break points. |
An object of class shading
.
At the moment, the it is assumed that the number of shading colours is one more than the break points, but this is not checked.
Chris Brunsdon
Draw thematic maps together with histograms with a Spatial
or sf
object, background layers according to variables and shading schemes.
thematic.map(data, var.names, colorStyle = NULL, na.pos = "bottomright", bglyrs, bgStyle, scaleBar.pos = "bottomright", mtitle = NULL, htitle = NULL, legend = "Legend", legend.pos = "topright", cuts = 5, cutter = quantileCuts, horiz = FALSE, digits=2,...)
thematic.map(data, var.names, colorStyle = NULL, na.pos = "bottomright", bglyrs, bgStyle, scaleBar.pos = "bottomright", mtitle = NULL, htitle = NULL, legend = "Legend", legend.pos = "topright", cuts = 5, cutter = quantileCuts, horiz = FALSE, digits=2,...)
data |
A |
var.names |
A vector of variable names to be mapped |
colorStyle |
A vector of colors (including "red", "blue" and "green") or a color function, e.g. |
na.pos |
A 2-D coordinate or character to define the position of north arrow, i.e. "topright", "topleft", "bottomright", "bottomleft" |
bglyrs |
A list of background layers of "Spatial" or "sf" objects |
bgStyle |
A list of parameters for define the styles of background layers, e.g. list(col="grey", cex=1, lwd=1, pch=16, lty=1) |
scaleBar.pos |
A 2-D coordinate or character to define the position of scale bar, i.e. "topright", "topleft", "bottomright", "bottomleft" |
mtitle |
Title of each map |
htitle |
Title of each histogram |
legend |
Title of each legend for each map |
legend.pos |
A 2-D coordinate or character to define the position of legend, i.e. "topright", "topleft", "bottomright", "bottomleft" |
cuts |
The number of classes. |
cutter |
Function used to create the break points. Can be user defined or a supplied cut function. |
horiz |
logical; if TRUE, set the legend horizontally rather than vertically |
digits |
Number of digits kept for legend |
... |
Arguments to be passed to methods |
The function returns no value, but draws thematic maps together with histograms on the current graphics device as a side effect.
None (see above).
Binbin Lu
choropleth
, choro.legend
, auto.shading
, shading
.
data(newhaven) # Single map thematic.map(blocks, var.names="POP1990", horiz = FALSE, na.pos = "topleft", scaleBar.pos = "bottomright", legend.pos = "bottomleft", colorStyle = "red") #Multiple maps and different colors thematic.map(blocks, var.names=c("P_35_44","P_25_34", "POP1990"), horiz =FALSE, na.pos = "topleft", scaleBar.pos = "bottomright", legend.pos = "bottomleft",colorStyle =hcl.colors) thematic.map(blocks, var.names=c("P_35_44","P_25_34", "POP1990"), horiz =FALSE, na.pos = "topleft", scaleBar.pos = "bottomright", legend.pos = "bottomleft", colorStyle =c("red", "blue", "na")) # Use coordinate to define the legend data(WHData) thematic.map(whp_sp, var.names="Avg_Green_", colorStyle ="red", na.pos = "topleft", scaleBar.pos = "bottomleft", legend.pos = c(544000, 3380000),cuts=7, cutter=rangeCuts) thematic.map(WHHP, var.names=c("Avg_HP_avg", "Avg_Green_"), colorStyle =c("red", "blue"), na.pos = "topleft", scaleBar.pos = "bottomleft", legend.pos = c(544000, 3380000),cuts=7, cutter=rangeCuts)
data(newhaven) # Single map thematic.map(blocks, var.names="POP1990", horiz = FALSE, na.pos = "topleft", scaleBar.pos = "bottomright", legend.pos = "bottomleft", colorStyle = "red") #Multiple maps and different colors thematic.map(blocks, var.names=c("P_35_44","P_25_34", "POP1990"), horiz =FALSE, na.pos = "topleft", scaleBar.pos = "bottomright", legend.pos = "bottomleft",colorStyle =hcl.colors) thematic.map(blocks, var.names=c("P_35_44","P_25_34", "POP1990"), horiz =FALSE, na.pos = "topleft", scaleBar.pos = "bottomright", legend.pos = "bottomleft", colorStyle =c("red", "blue", "na")) # Use coordinate to define the legend data(WHData) thematic.map(whp_sp, var.names="Avg_Green_", colorStyle ="red", na.pos = "topleft", scaleBar.pos = "bottomleft", legend.pos = c(544000, 3380000),cuts=7, cutter=rangeCuts) thematic.map(WHHP, var.names=c("Avg_HP_avg", "Avg_Green_"), colorStyle =c("red", "blue"), na.pos = "topleft", scaleBar.pos = "bottomleft", legend.pos = c(544000, 3380000),cuts=7, cutter=rangeCuts)
Data set from NOAA's National Weather Service Indianapolis, IN Weather Forecast Office 6900 W. Hanna Ave.
data(tornados)
data(tornados)
torn Tornado Touchdown points SpatialPointsDataFrame
- geographical projection
torn2 Tornado Touchdown points SpatialPointsDataFrame
- equal area projection
http://www.crh.noaa.gov/ind/?n=svrgis
# Read in the data data(tornados) # Split the plot in two opar <- par(mfrow=c(2,1)) # Plot US states plot(us_states) # Add Locations of observation stations plot(torn,add=TRUE,pch=16,col='red') # Plot a histogram of year of observation next to this hist(torn$YEAR) par(opar)
# Read in the data data(tornados) # Split the plot in two opar <- par(mfrow=c(2,1)) # Plot US states plot(us_states) # Add Locations of observation stations plot(torn,add=TRUE,pch=16,col='red') # Plot a histogram of year of observation next to this hist(torn$YEAR) par(opar)
Convert between different distance units - all functions take the form xx2yy
where xx
is the unit to be converted from and yy
is the unit to be converted to.
ft2miles(x) miles2ft(x) ft2km(x) km2ft(x)
ft2miles(x) miles2ft(x) ft2km(x) km2ft(x)
x |
A quantity in units to be converted from |
The value of x
converted to the new units. In the example below the conversions are from feet to miles and feet to kilometers (hence functions are ft2miles
and ft2km
).
Chris Brunsdon
# How many miles is 10,000 feet? ft2miles(10000) # How about in kilometers? ft2km(10000)
# How many miles is 10,000 feet? ft2miles(10000) # How about in kilometers? ft2km(10000)
Data set from Schwartz, M.D. and J.M. Caprio, 2003, North American First Leaf and First Bloom Lilac Phenology Data, IGBP PAGES/World Data Center for Paleoclimatology Data Contribution Series # 2003-078. NOAA/NGDC Paleoclimatology Program, Boulder CO, USA.
data(vulgaris)
data(vulgaris)
vulgaris Syringa Vulgaris Observation Stations SpatialPointsDataFrame
- geographical projection
vulgaris2 Syringa Vulgaris Observation Stations SpatialPointsDataFrame
- equal area projection
us_states States of US SpatialPolygonsDataFrame
- geographical projection
us_states2 States of US SpatialPolygonsDataFrame
- equal area projection
http://www.ncdc.noaa.gov/paleo/phenology.html
# Read in the data data(vulgaris) # Split the plot in two opar <- par(mfrow=c(2,1)) # Plot US states plot(us_states) # Add Locations of observation stations plot(vulgaris,add=TRUE,pch=16,col='red') # Plot a histogram of year of observation next to this hist(vulgaris$Year) par(opar)
# Read in the data data(vulgaris) # Split the plot in two opar <- par(mfrow=c(2,1)) # Plot US states plot(us_states) # Add Locations of observation stations plot(vulgaris,add=TRUE,pch=16,col='red') # Plot a histogram of year of observation next to this hist(vulgaris$Year) par(opar)
Four geographic data sets of Wuhan are incoporated in this package
data(WHData)
data(WHData)
WHHP House price data at the community level of Wuhan in a sf object
WHD District boundary data of Wuhan
WHRD Road network data of Wuhan
whp_sp House price data at the community level of Wuhan in a SpatialPolygonsDataFrame object
# Read in the data data(WHData) choropleth(WHHP,"Avg_HP_avg")
# Read in the data data(WHData) choropleth(WHHP,"Avg_HP_avg")