Title: | Dot Density Maps |
---|---|
Description: | Generate point data for representing people within spatial data. This collects a suite of tools for creating simple dot density maps. Several functions from different spatial packages are standardized to take the same arguments so that they can be easily substituted for each other. |
Authors: | Christopher T. Kenny [aut, cre]
|
Maintainer: | Christopher T. Kenny <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.0.2 |
Built: | 2024-08-25 05:11:29 UTC |
Source: | https://github.com/christopherkenny/dots |
This data contains the largest named water within Suffolk County MA, with geographies simplified.
data("boston_water")
data("boston_water")
An sf dataframe with 10 observations
data('boston_water')
data('boston_water')
Remove Water
clip_water(shp, water, filter_islands = FALSE, ...)
clip_water(shp, water, filter_islands = FALSE, ...)
shp |
input shp with |
water |
water shapes to remove with |
filter_islands |
logical. Should additional filtering be done to remove small areas? |
... |
additional arguments to pass to |
tibble with sf
geometries
# time to run varies greatly, depending on machine data(suffolk) data(boston_water) clip_water(suffolk, boston_water[10, ])
# time to run varies greatly, depending on machine data(suffolk) data(boston_water) clip_water(suffolk, boston_water[10, ])
Make dot density plots
dots( shp, cols, engine = engine_terra, divisor = 250, min_point = 0.1 * divisor )
dots( shp, cols, engine = engine_terra, divisor = 250, min_point = 0.1 * divisor )
shp |
input shp with |
cols |
< |
engine |
backend to use. Default is |
divisor |
Number of people per dot. Default is 250. |
min_point |
Minimum number of people to generate one dot. Defaults to 10% of the divisor. |
A ggplot
data('suffolk') # subset to first 20 rows for speed on CRAN dots(suffolk[1:20, ], c(vap_black), divisor = 2000)
data('suffolk') # subset to first 20 rows for speed on CRAN dots(suffolk[1:20, ], c(vap_black), divisor = 2000)
Make dot density points
dots_points( shp, cols, engine = engine_terra, divisor = 250, min_point = 0.1 * divisor )
dots_points( shp, cols, engine = engine_terra, divisor = 250, min_point = 0.1 * divisor )
shp |
input shp with |
cols |
< |
engine |
backend to use. Default is |
divisor |
Number of people per dot. Default is 250. |
min_point |
Minimum number of people to generate one dot. Defaults to 10% of the divisor. |
tibble with sf
geometries
data('suffolk') # subset to first 20 rows for speed on CRAN dots_points(suffolk[1:20, ], c(vap_black))
data('suffolk') # subset to first 20 rows for speed on CRAN dots_points(suffolk[1:20, ], c(vap_black))
sf
Uses sf::st_sample()
to produce points and spatial joins with input shp
.
Each engine function takes the same arguments and produces comparable outputs.
Final number of points may be approximate for this method.
engine_sf_hexagonal(shp, col)
engine_sf_hexagonal(shp, col)
shp |
input shp with |
col |
character column name to produce points with |
tibble with sf
geometries
set.seed(1) data('suffolk') engine_sf_hexagonal(suffolk[16:20,], 'pop_nhpi')
set.seed(1) data('suffolk') engine_sf_hexagonal(suffolk[16:20,], 'pop_nhpi')
sf
Uses sf::st_sample()
to produce points and spatial joins with input shp
.
Each engine function takes the same arguments and produces comparable outputs.
engine_sf_random(shp, col)
engine_sf_random(shp, col)
shp |
input shp with |
col |
character column name to produce points with |
tibble with sf
geometries
set.seed(1) data('suffolk') engine_sf_random(suffolk[16:20,], 'pop_nhpi')
set.seed(1) data('suffolk') engine_sf_random(suffolk[16:20,], 'pop_nhpi')
sf
Uses sf::st_sample()
to produce points and spatial joins with input shp
.
Each engine function takes the same arguments and produces comparable outputs.
Final number of points may be approximate for this method.
engine_sf_regular(shp, col)
engine_sf_regular(shp, col)
shp |
input shp with |
col |
character column name to produce points with |
tibble with sf
geometries
set.seed(1) data('suffolk') engine_sf_regular(suffolk[16:20,], 'pop_nhpi')
set.seed(1) data('suffolk') engine_sf_regular(suffolk[16:20,], 'pop_nhpi')
sp
Uses sp::spsample()
with method "clustered" to produce points, converts back to sf
,
and spatial joins with input shp
.
Each engine function takes the same arguments and produces comparable outputs.
Final number of points may be approximate for this method.
engine_sp_clustered(shp, col)
engine_sp_clustered(shp, col)
shp |
input shp with |
col |
character column name to produce points with |
tibble with sf
geometries
set.seed(1) data('suffolk') engine_sp_clustered(suffolk[16:20, ], 'pop_nhpi')
set.seed(1) data('suffolk') engine_sp_clustered(suffolk[16:20, ], 'pop_nhpi')
sp
Uses sp::spsample()
with method "hexagonal" to produce points, converts back to sf
,
and spatial joins with input shp
.
Each engine function takes the same arguments and produces comparable outputs.
Final number of points may be approximate for this method.
engine_sp_hexagonal(shp, col)
engine_sp_hexagonal(shp, col)
shp |
input shp with |
col |
character column name to produce points with |
tibble with sf
geometries
set.seed(1) data('suffolk') engine_sp_hexagonal(suffolk[16:20, ], 'pop_nhpi')
set.seed(1) data('suffolk') engine_sp_hexagonal(suffolk[16:20, ], 'pop_nhpi')
sp
Uses sp::spsample()
with method "nonaligned" to produce points, converts back to sf
,
and spatial joins with input shp
.
Each engine function takes the same arguments and produces comparable outputs.
Final number of points may be approximate for this method.
engine_sp_nonaligned(shp, col)
engine_sp_nonaligned(shp, col)
shp |
input shp with |
col |
character column name to produce points with |
tibble with sf
geometries
set.seed(1) data('suffolk') engine_sp_nonaligned(suffolk[16:20, ], 'pop_nhpi')
set.seed(1) data('suffolk') engine_sp_nonaligned(suffolk[16:20, ], 'pop_nhpi')
sp
Uses sp::spsample()
with method "random" to produce points, converts back to sf
,
and spatial joins with input shp
.
Each engine function takes the same arguments and produces comparable outputs.
Final number of points may be approximate for this method.
engine_sp_random(shp, col)
engine_sp_random(shp, col)
shp |
input shp with |
col |
character column name to produce points with |
tibble with sf
geometries
set.seed(1) data('suffolk') engine_sp_random(suffolk[16:20,], 'pop_nhpi')
set.seed(1) data('suffolk') engine_sp_random(suffolk[16:20,], 'pop_nhpi')
sp
Uses sp::spsample()
with method "regular" to produce points, converts back to sf
,
and spatial joins with input shp
.
Each engine function takes the same arguments and produces comparable outputs.
Final number of points may be approximate for this method.
engine_sp_regular(shp, col)
engine_sp_regular(shp, col)
shp |
input shp with |
col |
character column name to produce points with |
tibble with sf
geometries
set.seed(1) data('suffolk') engine_sp_regular(suffolk[16:20,], 'pop_nhpi')
set.seed(1) data('suffolk') engine_sp_regular(suffolk[16:20,], 'pop_nhpi')
sp
Uses sp::spsample()
with method "regular" to produce points, converts back to sf
,
and spatial joins with input shp
.
Each engine function takes the same arguments and produces comparable outputs.
Final number of points may be approximate for this method.
engine_sp_stratified(shp, col)
engine_sp_stratified(shp, col)
shp |
input shp with |
col |
character column name to produce points with |
tibble with sf
geometries
set.seed(1) data('suffolk') engine_sp_stratified(suffolk[16:20, ], 'pop_nhpi')
set.seed(1) data('suffolk') engine_sp_stratified(suffolk[16:20, ], 'pop_nhpi')
terra
Uses terra::dots()
to produce points and transforms back to sf
.
Each engine function takes the same arguments and produces comparable outputs.
engine_terra(shp, col)
engine_terra(shp, col)
shp |
input shp with |
col |
character column name to produce points with |
tibble with sf
geometries
set.seed(1) data('suffolk') engine_terra(suffolk, 'pop_nhpi')
set.seed(1) data('suffolk') engine_terra(suffolk, 'pop_nhpi')
Filter Points to a Region
filter_pts(pts, shp, cond = TRUE)
filter_pts(pts, shp, cond = TRUE)
pts |
points with |
shp |
shp to filter to |
cond |
geometry subset to reduce shp to |
tibble with sf
geometries
data(suffolk) pts <- dots_points(suffolk, pop, divisor = 1000) filter_pts(pts, suffolk, pop < 1000)
data(suffolk) pts <- dots_points(suffolk, pop, divisor = 1000) filter_pts(pts, suffolk, pop < 1000)
This data contains the voting districts for Suffolk County MA, with geographies simplified.
data("suffolk")
data("suffolk")
An sf dataframe with 295 observations
data('suffolk')
data('suffolk')