mdsumner / ozmaps

Australian maps
https://mdsumner.github.io/ozmaps/
17 stars 2 forks source link

sf object geometry column contain names that causes problems downstream #10

Closed AltfunsMA closed 3 years ago

AltfunsMA commented 4 years ago

I believe names are not supposed to be used in sfc as per https://github.com/r-spatial/sf/issues/1177

names(ozmaps::abs_lga$geometry)
#>   [1] "0"   "1"   "2"   "3"   "4"   "5"   "6"   "7"   "8"   "9"   "10"  "11" 
#>  [13] "12"  "13"  "14"  "15"  "16"  "17"  "18"  "19"  "20"  "21"  "22"  "23" 
#>  [25] "24"  "25"  "26"  "27"  "28"  "29"  "30"  "31"  "32"  "33"  "34"  "35" 
#>  [37] "36"  "37"  "38"  "39"  "40"  "41"  "42"  "43"  "44"  "45"  "46"  "47" 
#>  [49] "48"  "49"  "50"  "51"  "52"  "53"  "54"  "55"  "56"  "57"  "58"  "59" 
#>  [61] "60"  "61"  "62"  "63"  "64"  "65"  "66"  "67"  "68"  "69"  "70"  "71" 
#>  [73] "72"  "73"  "74"  "75"  "76"  "77"  "78"  "79"  "80"  "81"  "82"  "83" 
#>  [85] "84"  "85"  "86"  "87"  "88"  "89"  "90"  "91"  "92"  "93"  "94"  "95" 
#>  [97] "96"  "97"  "98"  "99"  "100" "101" "102" "103" "104" "105" "106" "107"
#> [109] "108" "109" "110" "111" "112" "113" "114" "115" "116" "117" "118" "119"
#> [121] "120" "121" "122" "123" "124" "125" "126" "127" "128" "129" "130" "131"
(snip)

I just attempted a dplyr::left_join with some other ABS LGA data and it failed with error.

Error in attributes(lst) <- a : 'names' attribute [563] must be the same length as the vector [544]

Removing the names solves the issue but the error is quite confusing as plenty of other left_joins of sf objects work

Thanks for a great package!

mdsumner commented 4 years ago

Ah thanks! It should be fixed here .

Btw what are you joining to?

I've long meant to bring in the original raw data tables to this package, but it never turned out how I wanted really. I can't stand having more than one field on the polygons because of the sf plot facetting, it's ok for these simplified layers but becomes really problematic with the original data.

If you are joining on the other ABS stuff I'd be happy to make that easier with a new release.

AltfunsMA commented 4 years ago

I was just trying a very quick test with some ABS data from here.

I think your approach of providing lightweight sf objects with location names is quite good in principle because people will have their own very diverse requirements and they can always join that with their tools of choice.... I was gonna simplify the raw maps myself when I saw your package, so that was handy!

On the other hand, I'm fairly new to using ABS data in general and I haven't really found an API/package to query what I want programmatically... so I'd actually welcome having some data to go with the maps by default to get things started.

mdsumner commented 3 years ago

ok, closing this - if I get to updating the data I'll have a rethink, there is https://cran.r-project.org/web/packages/readabs/index.html