Skip to content

Instantly share code, notes, and snippets.

@mdsumner
Last active August 11, 2025 06:57
Show Gist options
  • Save mdsumner/6b42e0e42b7debac287a63c956eb88c9 to your computer and use it in GitHub Desktop.
Save mdsumner/6b42e0e42b7debac287a63c956eb88c9 to your computer and use it in GitHub Desktop.
parcels <- function(address, distance = 200) {
  parcel_dsn <- "/vsizip//vsicurl/listdata.thelist.tas.gov.au/opendata/data/LIST_PARCELS_HOBART.zip/list_parcels_hobart.shp"
  pt <- tidygeocoder::geo(address, quiet = TRUE)
  parcel_ds <- new(gdalraster::GDALVector, parcel_dsn)
  on.exit(parcel_ds$close(), add = TRUE)
  prj <- parcel_ds$getSpatialRef()
  pp <- gdalraster::transform_xy(cbind(pt$long, pt$lat), srs_to = prj, srs_from = "EPSG:4326")
  ex <- rep(pp, each = 2) + c(-1, 1, -1, 1) * distance
  sf <- gdalraster::bbox_to_wkt(ex[c(1, 3, 2, 4)])
  parcel_ds <- new(gdalraster::GDALVector, parcel_dsn)
  parcel_ds$setSpatialFilter(sf)
  out <- parcel_ds$fetch(-1)
  if (nrow(out) < 1) stop(sprintf("no parcels found for '%s' within %i m", address, as.integer(distance)))
  out
}

v <- parcels("1 Macquarie St Hobart", 50)

plot(v)

Created on 2025-08-11 with reprex v2.0.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment