Skip to content

Commit

Permalink
Update bookdown
Browse files Browse the repository at this point in the history
  • Loading branch information
jmhatch committed Jan 15, 2025
1 parent 4508c6d commit d41fb51
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bookdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:

- name: Install arcgis dependencies
run: |
install.packages(c("cli", "dbplyr", "here", "httr2", "RcppSimdJson", "rlang", "rvest", "sf"))
install.packages(c("cli", "dbplyr", "DT", "here", "httr2", "RcppSimdJson", "rlang", "rvest", "sf"))
shell: Rscript {0}

- name: Install arcgis
Expand Down
40 changes: 35 additions & 5 deletions bookdown/02-ecomon.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ token = arcgisutils::auth_client()
# feature server url
ecomon_url = 'https://services2.arcgis.com/C8EMgrsFcRFL6LrL/arcgis/rest/services/Ecosystem_Monitoring_Strata/FeatureServer/'
# layer
ecomon_lyr = arcgislayers::arc_open(ecomon_url, token = token)
# metadata
ecomon_meta = arcgisutils::fetch_layer_metadata(url = ecomon_url, token = token)
```
Expand All @@ -33,10 +30,10 @@ Yes, see [here](`r inport_href`).

`r ecomon_desc`

### Extent
### Spatial Extent

```{r, echo = FALSE}
# get layer
# get layer bounding box
ecomon_bb = data.frame(
x = c(ecomon_meta$fullExtent$xmin, ecomon_meta$fullExtent$xmax),
y = c(ecomon_meta$fullExtent$ymin, ecomon_meta$fullExtent$ymax)) |>
Expand All @@ -50,3 +47,36 @@ leaflet::leaflet() |>
leaflet::addTiles() |>
leaflet::addPolygons(data = ecomon_bb)
```

### Layers

```{r, echo = FALSE}
ecomon_meta$layers |>
dplyr::select(id, name, minScale, maxScale, type, geometryType) |>
knitr::kable()
```

### Fields

```{r, echo = FALSE, results = 'asis'}
# layers
ecomon_layers = ecomon_meta$layers
# loop over layers
ecomon_fields = purrr::map(.x = 1:nrow(ecomon_layers), .f = function(.x) {
# open layer
ecomon_layer = arcgislayers::arc_open(url = paste0(ecomon_url, '/', ecomon_layers$id[.x]), token = token)
# get fields
ecomon_fields = arcgislayers::list_fields(ecomon_layer) |>
dplyr::select(name, actualType, length, precision)
# output
cat('\n####', ecomon_layers$name[.x], '\n')
print(knitr::kable(ecomon_fields))
cat('\n')
})
```
35 changes: 34 additions & 1 deletion bookdown/Rmd/ecomon.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Yes, see [here](`r inport_href`).

`r ecomon_desc`

### Extent
### Spatial Extent

```{r, echo = FALSE}
# get layer bounding box
Expand All @@ -47,3 +47,36 @@ leaflet::leaflet() |>
leaflet::addTiles() |>
leaflet::addPolygons(data = ecomon_bb)
```

### Layers

```{r, echo = FALSE}
ecomon_meta$layers |>
dplyr::select(id, name, minScale, maxScale, type, geometryType) |>
knitr::kable()
```

### Fields

```{r, echo = FALSE, results = 'asis'}
# layers
ecomon_layers = ecomon_meta$layers
# loop over layers
ecomon_fields = purrr::map(.x = 1:nrow(ecomon_layers), .f = function(.x) {
# open layer
ecomon_layer = arcgislayers::arc_open(url = paste0(ecomon_url, '/', ecomon_layers$id[.x]), token = token)
# get fields
ecomon_fields = arcgislayers::list_fields(ecomon_layer) |>
dplyr::select(name, actualType, length, precision)
# output
cat('\n####', ecomon_layers$name[.x], '\n')
print(knitr::kable(ecomon_fields))
cat('\n')
})
```

0 comments on commit d41fb51

Please sign in to comment.