Skip to content

Commit e80e204

Browse files
authored
Merge pull request #37 from R-ArcGIS/agol-note
Add note for using AGOL
2 parents 8a88835 + 9dcc643 commit e80e204

File tree

2 files changed

+37
-30
lines changed

2 files changed

+37
-30
lines changed

docs/layers/read-layers.qmd

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ ArcGIS Online and Enterprise web services can easily be read into R using`{arcgi
1515

1616
Metadata for all of the above service types can be accessed using `arc_open()`. Feature data can be read in using `arc_select()` for FeatureLayer, Table, and ImageServer.
1717

18-
This tutorial will teach you the basics of reading data from hosted Feature Layers into R as [`{sf}`](https://r-spatial.github.io/sf/) objects using`{arcgislayers}`.
18+
This tutorial will teach you the basics of reading data from hosted Feature Layers into R as [`{sf}`](https://r-spatial.github.io/sf/) objects using`{arcgislayers}`.
19+
20+
:::{.callout-note}
21+
When leveraging Esri hosted content, organizations should review the [ArcGIS Online terms of use](https://doc.arcgis.com/en/arcgis-online/reference/terms-of-use.htm), as well as the terms of use for the data layer to ensure they are in compliance with extracting data and/or making it available in other systems.
22+
:::
1923

2024
## Objective
2125

@@ -28,21 +32,21 @@ The objective of this tutorial is to teach you how to:
2832

2933
## Obtaining a feature layer url
3034

31-
For this example, you will read in population data of major US cities from ArcGIS Online.
35+
For this example, you will read in population data of major US cities from ArcGIS Online.
3236

33-
You will use the functions `arc_open()` and `arc_select()` to read data from ArcGIS Online into R. However, these functions require the url of the hosted feature service. To find this, navigate to the [item](https://www.arcgis.com/home/item.html?id=9df5e769bfe8412b8de36a2e618c7672) in ArcGIS Online.
37+
You will use the functions `arc_open()` and `arc_select()` to read data from ArcGIS Online into R. However, these functions require the url of the hosted feature service. To find this, navigate to the [item](https://www.arcgis.com/home/item.html?id=9df5e769bfe8412b8de36a2e618c7672) in ArcGIS Online.
3438

3539

3640
![](../shared/images/usa-cities.png)
37-
When you scroll down, on the right hand side, you will see a button to view the service itself.
41+
When you scroll down, on the right hand side, you will see a button to view the service itself.
3842

3943
![](../shared/images/view-url.png){width=45%}
4044

41-
Clicking this will bring you to the Feature Service. Inside of a Feature Server there may be many layers or tables that you can use. In this case, there is only one layer. Click the hyperlinked **USA Major Cities**.
45+
Clicking this will bring you to the Feature Service. Inside of a Feature Server there may be many layers or tables that you can use. In this case, there is only one layer. Click the hyperlinked **USA Major Cities**.
4246

4347
![](../shared/images/usa-cities-server.png)
4448

45-
This reveals the Feature Layer of interest.
49+
This reveals the Feature Layer of interest.
4650

4751
![](../shared/images/usa-cities-layer.png){width=70%}
4852

@@ -57,7 +61,7 @@ https://services.arcgis.com/P3ePLMYs2RVChkJx/ArcGIS/rest/services/USA_Major_Citi
5761
Before you can read in the Feature Layer, you need to load the `arcgis` R package. If you do not have `arcgis` installed, install it with `pak::pak("r-arcgis/arcgis")` or `install.packages("arcgis")`.
5862

5963
:::{.aside}
60-
`{pak}` is an R package that makes it faster and easier to install R packages. If you do not have it installed, run `install.packages("pak")` first.
64+
`{pak}` is an R package that makes it faster and easier to install R packages. If you do not have it installed, run `install.packages("pak")` first.
6165
:::
6266

6367
```{r}
@@ -77,39 +81,39 @@ flayer <- arc_open(furl)
7781
flayer
7882
```
7983

80-
`arc_open()` will create a `FeatureLayer` object. Under the hood, this is really just a list containing the feature layer's metadata.
84+
`arc_open()` will create a `FeatureLayer` object. Under the hood, this is really just a list containing the feature layer's metadata.
8185

8286
:::{.callout-note collapse="true" title="FeatureLayer details for the curious"}
83-
The `FeatureLayer` object is obtained by adding `?f=json` to the feature layer url and processing the json. All of the metadata is stored in the `FeatureLayer` object. You can see this by running `unclass(flayer)`. Be warned! It gets messy.
87+
The `FeatureLayer` object is obtained by adding `?f=json` to the feature layer url and processing the json. All of the metadata is stored in the `FeatureLayer` object. You can see this by running `unclass(flayer)`. Be warned! It gets messy.
8488
:::
8589

86-
With this `FeatureLayer` object, you can read data from the service into R!
90+
With this `FeatureLayer` object, you can read data from the service into R!
8791

8892
## Reading from a Feature Layer
8993

9094
Once you have a `FeatureLayer` object, you can read its data into memory using the `arc_select()` function. By default, if you use `arc_select()` on a `FeatureLayer` without any additional arguments, the entire service will be brought into memory.
9195

9296
:::{.callout-warning}
93-
Avoid reading in more data than you need! Reading an entire feature service is fine for datasets with fewer than 5,000 features. But when there are more than 10,000 features, performance and memory may be throttled.
97+
Avoid reading in more data than you need! Reading an entire feature service is fine for datasets with fewer than 5,000 features. But when there are more than 10,000 features, performance and memory may be throttled.
9498

9599
Exceptionally detailed geometries require more data to be transferred across the web and may be slower to process and may require adjustment of the `page_size` argument of `arc_select()`.
96100
:::
97101

98-
Store the results of `arc_select()` in the object `cities`.
102+
Store the results of `arc_select()` in the object `cities`.
99103

100104
```{r, message = FALSE}
101105
cities <- arc_select(flayer)
102106
cities
103107
```
104108

105-
The result is an `sf` object that you can now work with using **`sf`** and any other R packages.
109+
The result is an `sf` object that you can now work with using **`sf`** and any other R packages.
106110

107-
### Specifying output fields
111+
### Specifying output fields
108112

109-
In some cases, you may have Feature Layers with many extraneous fields. You can specify which fields to return to R using the `fields` argument.
113+
In some cases, you may have Feature Layers with many extraneous fields. You can specify which fields to return to R using the `fields` argument.
110114

111115
:::{.callout-tip}
112-
Remember to only read in the data that you need. Adding unneeded fields uses more memory and takes longer to process.
116+
Remember to only read in the data that you need. Adding unneeded fields uses more memory and takes longer to process.
113117
:::
114118

115119
`fields` takes a character vector of field names. To see which fields are available in a Feature Layer, you can use the utility function `list_fields()`.
@@ -122,11 +126,11 @@ fields[, 1:4]
122126
For the sake of readability, only the first 4 columns are displayed.
123127
:::
124128

125-
Let's try reading in only the `"STATE_ABBR"`, `"POPULATION"`, and `"NAME"` fields.
129+
Let's try reading in only the `"STATE_ABBR"`, `"POPULATION"`, and `"NAME"` fields.
126130

127131
```{r}
128132
arc_select(
129-
flayer,
133+
flayer,
130134
fields = c("STATE_ABBR", "POPULATION", "NAME")
131135
)
132136
```
@@ -135,7 +139,7 @@ arc_select(
135139

136140
Not only can you limit the number of columns returned from a Feature Layer, but you can also limit the number of rows returned. This is very handy in the case of Feature Layers with hundreds of thousands of features. Reading all of those features into memory would be slow, costly (in terms of memory), and, in many cases, unnecessary!
137141

138-
The `where` argument of `arc_select()` permits you to provide a very simple SQL where clause to limit the features returned. Let's explore the use of the `where` argument.
142+
The `where` argument of `arc_select()` permits you to provide a very simple SQL where clause to limit the features returned. Let's explore the use of the `where` argument.
139143

140144
Let's modify the above `arc_select()` statement to return only the features in California, using the where clause `STATE_ABBR = 'CA'`
141145

@@ -210,4 +214,3 @@ There is also a helper `get_all_layers()` to fetch all of layers of a `FeatureSe
210214
```{r}
211215
get_all_layers(fsrv2)
212216
```
213-

docs/layers/read-rasters.qmd

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ Metadata for all of the above service types can be accessed using `arc_open()`.
1818

1919
This tutorial will teach you the basics of reading data from hosted image services into R as [`{terra} SpatRaster`](https://rspatial.github.io/terra/reference/rast.html) objects using`{arcgislayers}`. The source for an image service is published raster or imagery data. To learn more about image services, see the [Image services documentation](https://enterprise.arcgis.com/en/server/latest/publish-services/windows/key-concepts-for-image-services.htm).
2020

21+
:::{.callout-note}
22+
When leveraging Esri hosted content, organizations should review the [ArcGIS Online terms of use](https://doc.arcgis.com/en/arcgis-online/reference/terms-of-use.htm), as well as the terms of use for the data layer to ensure they are in compliance with extracting data and/or making it available in other systems.
23+
:::
24+
25+
2126
## Objective
2227

2328
The objective of this tutorial is to teach you how to:
@@ -29,13 +34,13 @@ The objective of this tutorial is to teach you how to:
2934

3035
## Obtaining an image service url
3136

32-
For this example, you will read in multispectral Landsat imagery of the Ouarkziz Crater from ArcGIS Online.
37+
For this example, you will read in multispectral Landsat imagery of the Ouarkziz Crater from ArcGIS Online.
3338

34-
You will use the functions `arc_open()` and `arc_raster()` to read image data from ArcGIS Online into R. However, these functions require the url of the hosted image service. To find this, navigate to the [item](https://www.arcgis.com/home/item.html?id=d9b466d6a9e647ce8d1dd5fe12eb434b) in ArcGIS Online.
39+
You will use the functions `arc_open()` and `arc_raster()` to read image data from ArcGIS Online into R. However, these functions require the url of the hosted image service. To find this, navigate to the [item](https://www.arcgis.com/home/item.html?id=d9b466d6a9e647ce8d1dd5fe12eb434b) in ArcGIS Online.
3540

3641

3742
![](../shared/images/multispectral-landsat.png)
38-
When you scroll down, on the right hand side, you will see a button to view the service itself.
43+
When you scroll down, on the right hand side, you will see a button to view the service itself.
3944

4045
![](../shared/images/view-url-imagery.png){width=45%}
4146

@@ -50,7 +55,7 @@ https://landsat2.arcgis.com/arcgis/rest/services/Landsat/MS/ImageServer
5055
First, load the `arcgis` R package. If you do not have `arcgis` installed, install it with `pak::pak("r-arcgis/arcgis")` or `install.packages("arcgis")`.
5156

5257
:::{.aside}
53-
`{pak}` is an R package that makes it faster and easier to install R packages. If you do not have it installed, run `install.packages("pak")` first.
58+
`{pak}` is an R package that makes it faster and easier to install R packages. If you do not have it installed, run `install.packages("pak")` first.
5459
:::
5560

5661
```{r}
@@ -74,17 +79,17 @@ imgsrv <- arc_open(url)
7479
imgsrv
7580
```
7681

77-
`arc_open()` will create a `ImageServer` object. Under the hood, this is really just a list containing the image service's metadata.
82+
`arc_open()` will create a `ImageServer` object. Under the hood, this is really just a list containing the image service's metadata.
7883

7984
:::{.callout-note collapse="true" title="ImageServer details for the curious"}
80-
The `ImageServer` object is obtained by adding `?f=json` to the image server url and processing the json. All of the metadata is stored in the `ImageServer` object. You can see this by running `unclass(imgsrv)`. Be warned! It gets messy.
85+
The `ImageServer` object is obtained by adding `?f=json` to the image server url and processing the json. All of the metadata is stored in the `ImageServer` object. You can see this by running `unclass(imgsrv)`. Be warned! It gets messy.
8186
:::
8287

83-
With this `ImageServer` object, you can read data from the service into R!
88+
With this `ImageServer` object, you can read data from the service into R!
8489

8590
## Reading from a Image Service
8691

87-
Once you have a `ImageServer` object, you can access the image data using the `arc_raster()` function. Pass the coordinates for a bounding box into the function using the `xmin`, `ymin`, `xmax`, and `ymax` arguments. Store the results of `arc_raster()` in the object `crater`.
92+
Once you have a `ImageServer` object, you can access the image data using the `arc_raster()` function. Pass the coordinates for a bounding box into the function using the `xmin`, `ymin`, `xmax`, and `ymax` arguments. Store the results of `arc_raster()` in the object `crater`.
8893

8994
:::{.callout-warning}
9095
Avoid reading in more data than you need! When extracting data from an image service, it is best practice to include a bounding box to limit the extraction to just the area that you need. Make sure to provide the bounding box coordinates in the Coordinate Reference System (CRS) of the image service or use the `bbox_crs` argument to specify another CRS for these coordinates.
@@ -101,7 +106,7 @@ crater <- arc_raster(
101106
crater
102107
```
103108

104-
The result is a `SpatRaster` object that you can now work with using **`terra`** and any other R packages.
109+
The result is a `SpatRaster` object that you can now work with using **`terra`** and any other R packages.
105110

106111

107112
### Using `terra`
@@ -117,4 +122,3 @@ or saving the image locally:
117122
```{r, message = FALSE}
118123
terra::writeRaster(crater, "ouarkziz-crater-RGB.tif", overwrite = TRUE)
119124
```
120-

0 commit comments

Comments
 (0)