testpoints | R Documentation |
Generate a number of randomly placed points, as latitude/longitude values.
testpoints(
n = 1,
weighting = "area",
ST,
as.df = TRUE,
minlat = 17.9,
maxlat = 71.25,
minlon = -175.89,
maxlon = 178.34,
useblocks = FALSE
)
n |
Numeric value, 1 by default. Specifies how many testpoints to return. Must be an integer between zero and 50 million, and not NA. |
weighting |
area or people or geo or degrees text indicating what type of weighting, by area or people or geo (each block or block group has equal chance). Default is area - a random square mile not a random residence or random Census geometry. |
ST |
optional vector of 2 letter state abbreviations, to limit it to some state(s). Default is all USA (including PR I think). |
as.df |
Logical, default is TRUE, in which case returns a data.frame, otherwise a matrix. |
minlat |
the minimum latitude in decimal degrees to use for generating random points within some range. |
maxlat |
the maximum latitude in decimal degrees to use for generating random points within some range. |
minlon |
the minimum longitude in decimal degrees to use for generating random points within some range. |
maxlon |
the maximum longitude in decimal degrees to use for generating random points within some range. |
useblocks |
logical, whether to use the several million Census blocks if TRUE (2020 Census as of 11/2022) or just the approx 220k block groups (from github package ejscreen) if FALSE which is faster |
This function returns n points at random location latitude and longitude values, weighted by area or by population count in block group, to be roughly representative of either a random location (like throwing a dart, equal weight per square mile of land area - does not include water area in weighting but can return a point in water if bg has internal point in water?!) or where a randomly selected US resident lives (population weighted). Points are returned as latitude and longitude in decimal degrees.
For people weighted, it picks from the Census blockgroup internal points, which are much more representative of where people live than a random square mile would be.
By default, returns a data.frame (or matrix if as.df=FALSE) that has 2 columns: lat and lon, in decimal degrees, with 1 row per point.
get.distances.all
which allows you to get distances between all points,
get.distances.prepaired
for finding distances
when data are already formatted as pairs of points,
get.nearest
which finds the distance to the single nearest point
within a specified search radius instead of all topoints, and
proxistat
which calculates a proximity score for each spatial unit
based on distances to nearby points.
testpoints(19,minlat=47,maxlat=48)
get.distances(testpoints(100),testpoints[10],radius=999,return.rownums=TRUE,return.latlons=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.