suggest_top_crs | R Documentation |
Return the EPSG code or proj4string syntax for the top-ranking projected coordinate reference system returned by suggest_crs()
. This function should be used with caution and is recommended for interactive work rather than in production data pipelines.
suggest_top_crs(input, units = NULL, inherit_gcs = TRUE, output = "epsg")
input |
An input spatial dataset of class |
units |
(optional) The measurement units used by the returned coordinate reference system. |
inherit_gcs |
if |
output |
one of |
The EPSG code or proj4string for the output coordinate reference system.
## Not run: # Let's say we are working with a demographic dataset from the US Census: library(tidycensus) library(ggplot2) library(sf) library(crsuggest) tx_income <- get_acs( geography = "county", variables = "B19013_001", state = "TX", geometry = TRUE ) # We can use `suggest_top_crs()` to return the EPSG code of the "top" suggested CRS # for statewide mapping of Texas tx_crs <- suggest_top_crs(tx_income) # The returned CRS is EPSG code 3083, NAD83 / Texas Centric Albers Equal Area. # This code can be used for visualization: ggplot(tx_income, aes(fill = estimate)) + geom_sf() + coord_sf(crs = tx_crs) # Alternatively, we can transform the CRS of our sf object directly: tx_projected <- st_transform(tx_income, tx_crs) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.