Download a resource from the portal directly into your R session. CSV, XLS, XLSX, XML, JSON, SHP, ZIP, and GeoJSON resources are supported.

get_resource(resource)

Arguments

resource

A way to identify the resource. Either a resource ID (passed as a character vector directly) or a single resource resulting from list_package_resources.

Value

In most cases, the resource is returned as a tibble or list of tibbles. If it is a spatial resource (i.e. SHP or GeoJSON), it is returned as an sf object.

Examples

# \donttest{ list_package_resources("https://open.toronto.ca/dataset/neighbourhoods/") %>% get_resource()
#> Simple feature collection with 140 features and 17 fields #> geometry type: POLYGON #> dimension: XY #> bbox: xmin: -79.63926 ymin: 43.581 xmax: -79.11527 ymax: 43.85546 #> geographic CRS: WGS 84 #> # A tibble: 140 x 18 #> `_id` AREA_ID AREA_ATTR_ID PARENT_AREA_ID AREA_SHORT_CODE AREA_LONG_CODE #> <int> <int> <int> <lgl> <chr> <chr> #> 1 10361 2480141 26005521 NA 096 096 #> 2 10362 2480140 26005520 NA 095 095 #> 3 10363 2480139 26005519 NA 109 109 #> 4 10364 2480064 26005444 NA 064 064 #> 5 10365 2480063 26005443 NA 103 103 #> 6 10366 2480062 26005442 NA 130 130 #> 7 10367 2480138 26005518 NA 053 053 #> 8 10368 2480137 26005517 NA 026 026 #> 9 10369 2480136 26005516 NA 006 006 #> 10 10370 2480135 26005515 NA 124 124 #> # … with 130 more rows, and 12 more variables: AREA_NAME <chr>, #> # AREA_DESC <chr>, X <lgl>, Y <lgl>, LONGITUDE <lgl>, LATITUDE <lgl>, #> # OBJECTID <int>, Shape__Area <dbl>, Shape__Length <dbl>, geometry <POLYGON #> # [°]>, CLASSIFICATION <chr>, CLASSIFICATION_CODE <chr>
# }