There and Back Again competition entry https://shiny.petras.space/commute/
rstats
rshiny
census
competition
leaflet
javascript
stats-nz

maps.R 668B

123456789101112131415161718192021
  1. library(rgdal)
  2. library(rmapshaper)
  3. sf <- readOGR(dsn = "shapefiles/statsnzstatistical-area-2-2018-generalised-SHP/")
  4. plot(sf, xlim=c(1750000, 1760000), ylim=c(5430000, 5440000))
  5. # insf <- ms_innerlines(sf)
  6. ssf1 <- ms_simplify(sf)
  7. plot(ssf1, xlim=c(1750000, 1760000), ylim=c(5430000, 5440000))
  8. ssf2.5 <- ms_simplify(sf, 0.025)
  9. plot(ssf2.5, xlim=c(1750000, 1760000), ylim=c(5430000, 5440000))
  10. ssf2 <- ms_simplify(sf, 0.01)
  11. plot(ssf2, xlim=c(1750000, 1760000), ylim=c(5430000, 5440000))
  12. ssf3 <- ms_simplify(sf, 0.002)
  13. plot(ssf3, xlim=c(1750000, 1760000), ylim=c(5430000, 5440000))
  14. writeOGR(ssf2, dsn = "shapefiles/sa2001/", layer = "SA2", driver="ESRI Shapefile")