pointmap | R Documentation |
Can help with a series of downloaded Census data files, such as one file per State.
Reads each using read.dbf
and combines them all as a data.frame.
They must all have the same columns, and each file just provides additional rows of data.
pointmap(
bin,
lat,
lon,
vartext = "x",
areatext = "area",
coloring = rainbow(length(unique(bin))),
asp = c(1, 1),
pch = ".",
...
)
bin |
Indicates color of each point. A vector of integers used to index the coloring vector. That would ideally include just 1:n where n is the n number of unique values and the index to the coloring vector, so each unique value 1:5, for example, is assigned a map color that is coloring[bin] |
lat |
vector of latitudes just interpreted as y values to plot |
lon |
vector of longitudes just interpreted as x values to plot |
vartext |
default is 'x', text to use in describing the field mapped |
areatext |
default is 'area', text to use in describing the area mapped |
coloring |
default is some basic colors from rainbow(). A vector specifying color for each bin (should be same length as number of unique bin values) |
asp |
default is c(1,1), aspect ratio of graphic (not right for AK, e.g.) |
pch |
default is '.', see |
... |
other params to send to plot |
Draws a map
countypointmap
myfips <- bg.pts$FIPS[substr(bg.pts$FIPS,1,2)=='06'] # CA
pointmap(bin = floor(runif(n = length(myfips),1,5.99)), lat = bg.pts$lat[match(myfips, bg.pts$FIPS)], lon = bg.pts$lon[match(myfips, bg.pts$FIPS)], vartext = 'Example', areatext = 'all of CA',coloring = c('gray', 'light blue', 'dark blue', 'orange', 'red') , pch=1, cex=0.3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.