create_us_map: Internal map creation tools

View source: R/create-us-map.R

create_us_mapR Documentation

Internal map creation tools

Description

create_us_map() creates the modified shapefiles used by the usmap package.

ea_crs() returns the US National Atlas Equal Area coordinate reference system (CRS) used by this package and usmap.

transform2D() computes a two dimensional affine transformation matrix for the provided rotation angle and scale factor.

transform_alaska() applies the appropriate transform for the Alaska polygons.

transform_hawaii() applies the appropriate transform for the Hawaii polygons.

compute_centroids() computes the modified centroids for each state or county polygon using a center-of-mass technique on the largest polygon in the region.

alaska_bbox() returns the bounding box of Alaska pre-transformation.

hawaii_bbox() returns the bounding box of Hawaii pre-transformation.

Usage

create_us_map(type = c("states", "counties"), input_file, output_file)

ea_crs()

transform2D(angle = 0, scale = 1)

transform_alaska(alaska)

transform_hawaii(hawaii)

compute_centroids(polygons, iterations = 3, initial_width_step = 10)

alaska_bbox()

hawaii_bbox()

Note

Using these functions externally is not recommended since they make certain undocumented assumptions that may not work with all inputs.

It is strongly recommend that the usmap package is used directly.

In some cases where the raw data is required, the us_map and centroid_labels functions located in this package can be used instead.

References

Gert (2017). “How to calculate polygon centroids in R (for non-contiguous shapes).” https://gis.stackexchange.com/a/265475.

Rudis B (2014). “Moving The Earth (well, Alaska & Hawaii) With R.” https://rud.is/b/2014/11/16/moving-the-earth-well-alaska-hawaii-with-r/.


usmapdata documentation built on May 29, 2024, 1:33 a.m.