runapp-aus / strayr

A catalogue of ready-to-use ABS coding structures. Package documentation can be found here: https://runapp-aus.github.io/strayr/
45 stars 15 forks source link

ASGS structures and correspondences #6

Closed bryceroney closed 3 years ago

bryceroney commented 3 years ago

Would ASGS structures and correspondences be useful?

wfmackey commented 3 years ago

I reckon it'd be worth having in abscorr. They currently live in the absmapsdata package as sf files with geometries attached. So we could:

  1. import those sf objects (and non-sf variants) from the absmapsdata package, keeping both acrtive; or
  2. copy the files across and have everything live under the abscorr roof, and I will depreciate the absmapsdata package.
wfmackey commented 3 years ago

I'll do 1. now

wfmackey commented 3 years ago

Just thinking about this some more. We want users who library(abscorr) to be able to immediately call the geometries used in absmapsdata, with their documentations, eg:

library(abscorr)
library(sf)

sa42016
#> Simple feature collection with 107 features and 9 fields (with 18 geometries empty)
#> geometry type:  MULTIPOLYGON
#> dimension:      XY
#> bbox:           xmin: 96.81695 ymin: -43.74048 xmax: 167.9969 ymax: -9.219937
#> CRS:            EPSG:4283
#> First 10 features:
#>    sa4_code_2016               sa4_name_2016 gcc_code_2016  gcc_name_2016
#> 1            101              Capital Region         1RNSW    Rest of NSW
#> 2            102               Central Coast         1GSYD Greater Sydney
#> 3            103                Central West         1RNSW    Rest of NSW
#> 4            104     Coffs Harbour - Grafton         1RNSW    Rest of NSW
#> 5            105          Far West and Orana         1RNSW    Rest of NSW
#> 6            106 Hunter Valley exc Newcastle         1RNSW    Rest of NSW
#> 7            107                   Illawarra         1RNSW    Rest of NSW
#> 8            108             Mid North Coast         1RNSW    Rest of NSW
#> 9            109                      Murray         1RNSW    Rest of NSW
#> 10           110  New England and North West         1RNSW    Rest of NSW
#>    state_code_2016 state_name_2016 areasqkm_2016 cent_long  cent_lat
#> 1                1 New South Wales     51895.563  149.2450 -35.56480
#> 2                1 New South Wales      1681.072  151.2855 -33.30797
#> 3                1 New South Wales     70297.060  148.3558 -33.21697
#> 4                1 New South Wales     13229.758  152.7739 -29.81603
#> 5                1 New South Wales    339363.693  145.0269 -30.98611
#> 6                1 New South Wales     21491.291  150.9849 -32.35481
#> 7                1 New South Wales      1538.919  150.7711 -34.43464
#> 8                1 New South Wales     18851.500  152.3410 -31.56476
#> 9                1 New South Wales     97797.675  144.0434 -34.42275
#> 10               1 New South Wales     99145.916  150.7019 -30.06335
#>                          geometry
#> 1  MULTIPOLYGON (((150.3113 -3...
#> 2  MULTIPOLYGON (((151.315 -33...
#> 3  MULTIPOLYGON (((150.6107 -3...
#> 4  MULTIPOLYGON (((153.2785 -2...
#> 5  MULTIPOLYGON (((150.1106 -3...
#> 6  MULTIPOLYGON (((152.3165 -3...
#> 7  MULTIPOLYGON (((150.8783 -3...
#> 8  MULTIPOLYGON (((159.0686 -3...
#> 9  MULTIPOLYGON (((147.6165 -3...
#> 10 MULTIPOLYGON (((152.4876 -2...

I'm not sure about the best way to do this. We want both the data and the object documentation ported over from the absmapsdata package, in a neat way that would automatically update if absmapsdata is updated.

One (seemingly silly) way is to retrieve all the data files in absmapsdata and load them into abscorr as objects. This is relatively easy, for example:

# Import ASGS structures from absmapsdata
library(tidyverse)
library(absmapsdata) # remotes::install_github("wfmackey/absmapsdata")

# Load all files
lazyLoad(file.path(system.file(package = 'absmapsdata'), "data", "Rdata"))

objects <- ls()[ls() != "dir"]

save_paths <- file.path("data", paste0(objects, ".rda"))

export_objects <- function(x, y) save(list = x, file = y)

purrr::walk2(objects, save_paths,
             export_objects)

And it could be set up to update whenever the package is built. But the documentation wouldn't port, so would have to be done manually.

Any ideas? Or thoughts about the best way to structure this? @MattCowgill @hughparsonage @mdsumner

HughParsonage commented 3 years ago

Depends: absmapsdata ?

wfmackey commented 3 years ago

Of course! That works. My goodness.