Description Usage Arguments Details Value See Also Examples

Approximate the area sizes of the polygons in real-world area units (such as sq km or sq mi), proportional numbers, or normalized numbers. Also, the areas can be calibrated to a prespecified area total. This function is a convenient wrapper around `st_area`

.

1 | ```
approx_areas(shp, target = "metric", total.area = NULL)
``` |

`shp` |
shape object, i.e., an |

`target` |
target unit, one of `"prop"` :Proportional numbers. In other words, the sum of the area sizes equals one. `"norm"` :Normalized numbers. All area sizes are normalized to the largest area, of which the area size equals one. `"metric"` (default):Output area sizes will be either `"km"` (kilometer) or`"m"` (meter) depending on the map scale`"imperial"` :Output area sizes will be either `"mi"` (miles) or`"ft"` (feet) depending on the map scale- other:
Predefined values are "km^2", "m^2", "mi^2", and "ft^2". Other values can be specified as well, in which case `to` is required).
These units are the output units. See |

`total.area` |
total area size of |

Note that the method of determining areas is an approximation, since it depends on the used projection and the level of detail of the shape object. Projections with equal-area property are highly recommended. See https://en.wikipedia.org/wiki/List_of_map_projections for equal area world map projections.

Numeric vector of area sizes (class `units`

).

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | ```
if (require(tmap) && packageVersion("tmap") >= "2.0") {
data(NLD_muni)
NLD_muni$area <- approx_areas(NLD_muni, total.area = 33893)
tm_shape(NLD_muni) +
tm_bubbles(size="area", title.size=expression("Area in " * km^2))
# function that returns min, max, mean and sum of area values
summary_areas <- function(x) {
list(min_area=min(x),
max_area=max(x),
mean_area=mean(x),
sum_area=sum(x))
}
# area of the polygons
approx_areas(NLD_muni) %>% summary_areas()
# area of the polygons, adjusted corrected for a specified total area size
approx_areas(NLD_muni, total.area=33893) %>% summary_areas()
# proportional area of the polygons
approx_areas(NLD_muni, target = "prop") %>% summary_areas()
# area in squared miles
approx_areas(NLD_muni, target = "mi mi") %>% summary_areas()
# area of the polygons when unprojected
approx_areas(NLD_muni %>% sf::st_transform(crs = 4326)) %>% summary_areas()
}
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.