5.7 Scale

# get centroids
nz_centroid_sfc = st_centroid(nz_sfc)

#scale by factor of 0.5
nz_scale_sfc = (nz_sfc - nz_centroid_sfc) * 0.5 + nz_centroid_sfc 

nz_scale_sf = st_set_geometry(nz, nz_scale_sfc) #return to sf type
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()

Scale