5.7 Scale
# get centroids
= st_centroid(nz_sfc)
nz_centroid_sfc
#scale by factor of 0.5
= (nz_sfc - nz_centroid_sfc) * 0.5 + nz_centroid_sfc
nz_scale_sfc
= st_set_geometry(nz, nz_scale_sfc) #return to sf type
nz_scale_sf st_crs(nz_scale_sf) <- st_crs(nz) #ensure same coordinate system
|>
nz ggplot() +
geom_sf() +
geom_sf(fill = "red", alpha = 0.5,
data = nz_scale_sf) +
labs(title = "New Zealand",
subtitle = "Affine Transformation: Scale",
caption = "GeoComputation with R book club") +
theme_minimal()