Learn R Programming

usmapdata (version 0.6.0)

create_us_map: 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_dir,
  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()

Arguments

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/.