Skip to content

Instantly share code, notes, and snippets.

@bohdanszymanik
Created May 13, 2025 02:11
Show Gist options
  • Save bohdanszymanik/807f45da5023351b1faa303d41a61f7a to your computer and use it in GitHub Desktop.
Save bohdanszymanik/807f45da5023351b1faa303d41a61f7a to your computer and use it in GitHub Desktop.
Clip meshblock 2013 to Auckland area - copied from a Microsoft Fabric Spark(R) notebook so I st_read file will be an odd location
library(sf)
library(dplyr)
nz_coastline <- st_read("/lakehouse/default/Files/lds-nz-coastline-mean-high-water-SHP/nz-coastline-mean-high-water.shp")
mb2013_akld <- st_read("/lakehouse/default/Files/statsnz-meshblock-2013-SHP-akld/meshblock-2013.shp")
# different CRS for the two regions
# nz_coastline is NZGD2000 while mb2013_akld is WGS 84
# Let's reconcile both to WGS84
nz_coastline_wgs84 <- st_transform(nz_coastline, st_crs(mb2013_akld))
mb2013_akld_clipped <- st_intersection(mb2013_akld, nz_coastline_wgs84)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment