Skip to content

Commit d6158c0

Browse files
authored
Merge pull request #183 from R-ArcGIS/cranlogs
add badge to readme
2 parents 2127ac5 + 79220f6 commit d6158c0

File tree

3 files changed

+67
-94
lines changed

3 files changed

+67
-94
lines changed

README.Rmd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ knitr::opts_chunk$set(
2020
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/license/apache-2-0)
2121
[![R-CMD-check](https://github.com/R-ArcGIS/arcgislayers/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/R-ArcGIS/arcgislayers/actions/workflows/R-CMD-check.yaml)
2222
[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)
23+
[![](https://cranlogs.r-pkg.org/badges/arcgislayers)](https://cran.r-project.org/package=arcgislayers)
2324
<!-- badges: end -->
2425

2526
The goal of `{arcgislayers}` is to provide an R interface to the [ArcGIS REST API](https://developers.arcgis.com/rest/).

README.md

Lines changed: 66 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
1+
---
2+
output: github_document
3+
---
14

25
<!-- README.md is generated from README.Rmd. Please edit that file -->
36

7+
8+
49
# arcgislayers
510

611
<!-- badges: start -->
712

813
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/license/apache-2-0)
914
[![R-CMD-check](https://github.com/R-ArcGIS/arcgislayers/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/R-ArcGIS/arcgislayers/actions/workflows/R-CMD-check.yaml)
10-
[![Lifecycle:
11-
stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)
15+
[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)
16+
[![](https://cranlogs.r-pkg.org/badges/arcgislayers)](https://cran.r-project.org/package=arcgislayers)
1217
<!-- badges: end -->
1318

14-
The goal of `{arcgislayers}` is to provide an R interface to the [ArcGIS
15-
REST API](https://developers.arcgis.com/rest/).
19+
The goal of `{arcgislayers}` is to provide an R interface to the [ArcGIS REST API](https://developers.arcgis.com/rest/).
1620

1721
## Installation
1822

19-
It is recommend you install and use the metapackage `{arcgis}`. You can
20-
install the development version of arcgis like so:
23+
It is recommend you install and use the metapackage `{arcgis}`. You can install the development version of arcgis like so:
2124

2225
``` r
2326
remotes::install_github("r-arcgis/arcgis", dependencies = TRUE)
@@ -27,28 +30,26 @@ remotes::install_github("r-arcgis/arcgis", dependencies = TRUE)
2730

2831
### Creating a simple feature object from an ArcGIS FeatureLayer
2932

30-
``` r
33+
34+
```r
3135
library(arcgis)
3236
#> Attaching core arcgis packages:
33-
#> → arcgisutils v0.2.0
34-
#> → arcgislayers v0.2.0
37+
#> → arcgisutils v0.2.0.9000
3538
```
3639

37-
`arc_open()` takes a URL to create a reference to a remote ArcGIS layer,
38-
server, or table. The function can return any of the following classes
39-
(corresponding to different ArcGIS service types):
40+
`arc_open()` takes a URL to create a reference to a remote ArcGIS layer, server, or table. The function can return any of the following classes (corresponding to different ArcGIS service types):
4041

41-
- `FeatureLayer`
42-
- `Table`
43-
- `FeatureServer`
44-
- `ImageServer`
45-
- `MapServer`
46-
- `GroupLayer`
42+
- `FeatureLayer`
43+
- `Table`
44+
- `FeatureServer`
45+
- `ImageServer`
46+
- `MapServer`
47+
- `GroupLayer`
48+
49+
For example, you can create a `FeatureLayer` object based on a Feature Server URL:
50+
4751

48-
For example, you can create a `FeatureLayer` object based on a Feature
49-
Server URL:
50-
51-
``` r
52+
```r
5253
furl <- "https://services.arcgis.com/P3ePLMYs2RVChkJx/ArcGIS/rest/services/USA_Counties_Generalized_Boundaries/FeatureServer/0"
5354

5455
county_fl <- arc_open(furl)
@@ -61,15 +62,14 @@ county_fl
6162
#> Capabilities: Query,Extract
6263
```
6364

64-
You can then use `arc_select()` to query the feature layer object and
65-
return an `sf` object.
65+
You can then use `arc_select()` to query the feature layer object and return an `sf` object.
6666

67-
If no arguments are provided to `arc_select()` the entire feature layer
68-
is returned in memory as an `sf` object.
67+
If no arguments are provided to `arc_select()` the entire feature layer is returned in memory as an `sf` object.
6968

70-
``` r
69+
70+
```r
7171
arc_select(county_fl)
72-
#> Iterating ■■■■■■■■■■■■■■■■ 50% | ETA: 1s
72+
#> Iterating ■■■■■■■■■■■■■■■■ 50% | ETA: 2s
7373
#> Simple feature collection with 3143 features and 12 fields
7474
#> Geometry type: MULTIPOLYGON
7575
#> Dimension: XY
@@ -110,46 +110,42 @@ arc_select(county_fl)
110110
#> 9 MULTIPOLYGON (((-85.58963 3...
111111
#> 10 MULTIPOLYGON (((-85.41657 3...
112112
```
113+
### Filtering using `where` or `filter_geom` arguments
113114

114-
### Filtering using `where` or `filter_geom` arguments
115+
You can also use the `fields` argument to select columns or the `where` argument to subset rows.
115116

116-
You can also use the `fields` argument to select columns or the `where`
117-
argument to subset rows.
117+
For example, using a character vector of column names for `fields` and a simple SQL where clause for `where` you can select counties with population greater than 1,000,000:
118118

119-
For example, using a character vector of column names for `fields` and a
120-
simple SQL where clause for `where` you can select counties with
121-
population greater than 1,000,000:
122119

123-
``` r
120+
```r
124121
arc_select(
125122
county_fl,
126123
fields = c("state_abbr", "population"),
127124
where = "population > 1000000"
128125
)
129-
#> Simple feature collection with 49 features and 3 fields
126+
#> Simple feature collection with 49 features and 2 fields
130127
#> Geometry type: MULTIPOLYGON
131128
#> Dimension: XY
132129
#> Bounding box: xmin: -158.2674 ymin: 21.24986 xmax: -71.02671 ymax: 47.77552
133130
#> Geodetic CRS: WGS 84
134131
#> First 10 features:
135-
#> STATE_ABBR POPULATION OBJECTID geometry
136-
#> 1 AZ 4420568 101 MULTIPOLYGON (((-111.0425 3...
137-
#> 2 AZ 1043433 104 MULTIPOLYGON (((-110.4522 3...
138-
#> 3 CA 1682353 184 MULTIPOLYGON (((-121.4721 3...
139-
#> 4 CA 1165927 190 MULTIPOLYGON (((-122.3076 3...
140-
#> 5 CA 1008654 193 MULTIPOLYGON (((-120.6636 3...
141-
#> 6 CA 10014009 202 MULTIPOLYGON (((-118.1067 3...
142-
#> 7 CA 3186989 213 MULTIPOLYGON (((-117.509 33...
143-
#> 8 CA 2418185 216 MULTIPOLYGON (((-116.0824 3...
144-
#> 9 CA 1585055 217 MULTIPOLYGON (((-121.6652 3...
145-
#> 10 CA 2181654 219 MULTIPOLYGON (((-117.7832 3...
132+
#> STATE_ABBR POPULATION geometry
133+
#> 1 AZ 4420568 MULTIPOLYGON (((-111.0425 3...
134+
#> 2 AZ 1043433 MULTIPOLYGON (((-110.4522 3...
135+
#> 3 CA 1682353 MULTIPOLYGON (((-121.4721 3...
136+
#> 4 CA 1165927 MULTIPOLYGON (((-122.3076 3...
137+
#> 5 CA 1008654 MULTIPOLYGON (((-120.6636 3...
138+
#> 6 CA 10014009 MULTIPOLYGON (((-118.1067 3...
139+
#> 7 CA 3186989 MULTIPOLYGON (((-117.509 33...
140+
#> 8 CA 2418185 MULTIPOLYGON (((-116.0824 3...
141+
#> 9 CA 1585055 MULTIPOLYGON (((-121.6652 3...
142+
#> 10 CA 2181654 MULTIPOLYGON (((-117.7832 3...
146143
```
147144

148-
For `FeatureLayer` and `Table` objects, and sometimes `ImageServer`s,
149-
the `list_fields()` function can be helpful to check available
150-
attributes and build a `where` query:
145+
For `FeatureLayer` and `Table` objects, and sometimes `ImageServer`s, the `list_fields()` function can be helpful to check available attributes and build a `where` query:
151146

152-
``` r
147+
148+
```r
153149
list_fields(county_fl)
154150
#> name type alias sqlType
155151
#> 1 OBJECTID esriFieldTypeOID OBJECTID sqlTypeOther
@@ -192,15 +188,13 @@ list_fields(county_fl)
192188
#> 12 <NA>
193189
```
194190

195-
You can also provide a `bbox`, `sfc`, or `sfg` object to the
196-
`filter_geom` argument to perform a spatial filter. If the `sfc` object
197-
contains more than one geometry, the object is combined with
198-
`sf::st_union()`. See documentation for more (`?arc_select`).
191+
You can also provide a `bbox`, `sfc`, or `sfg` object to the `filter_geom` argument to perform a spatial filter. If the `sfc` object contains more than one geometry, the object is combined with `sf::st_union()`. See documentation for more (`?arc_select`).
199192

200-
``` r
193+
194+
```r
201195
nc <- sf::st_read(system.file("shape/nc.shp", package="sf"))
202196
#> Reading layer `nc' from data source
203-
#> `C:\Users\mar10556\AppData\Local\R\win-library\4.3\sf\shape\nc.shp'
197+
#> `/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/sf/shape/nc.shp'
204198
#> using driver `ESRI Shapefile'
205199
#> Simple feature collection with 100 features and 14 fields
206200
#> Geometry type: MULTIPOLYGON
@@ -242,14 +236,12 @@ arc_select(
242236

243237
### Creating a `SpatRaster` from an ArcGIS ImageServer
244238

245-
A `SpatRaster` object from the `{terra}` package can be extracted from
246-
an `ImageServer` using `arc_raster()`.
239+
A `SpatRaster` object from the `{terra}` package can be extracted from an `ImageServer` using `arc_raster()`.
247240

248-
`arc_raster()` will extract the area defined by `xmin`, `ymin`, `xmax`,
249-
and `ymax`. You can optionally specify the `width` and `height` of the
250-
resultant image. Use `format` to define what type of image is returned.
241+
`arc_raster()` will extract the area defined by `xmin`, `ymin`, `xmax`, and `ymax`. You can optionally specify the `width` and `height` of the resultant image. Use `format` to define what type of image is returned.
251242

252-
``` r
243+
244+
```r
253245
img_url <- "https://landsat2.arcgis.com/arcgis/rest/services/Landsat/MS/ImageServer"
254246

255247
landsat <- arc_open(img_url)
@@ -265,51 +257,31 @@ res <- arc_raster(
265257
terra::plotRGB(res, 4, 3, 2, scale = max(landsat[["maxValues"]]))
266258
```
267259

268-
<img src="man/figures/README-unnamed-chunk-8-1.png" width="100%" />
260+
<img src="man/figures/README-unnamed-chunk-8-1.png" alt="plot of chunk unnamed-chunk-8" width="100%" />
269261

270262
## Authorization and publication
271263

272-
Authorization is not required for reading any public data sources.
264+
Authorization is not required for reading any public data sources.
273265

274266
Workflows that require authorization include:
275267

276-
- interacting with
277-
[non-public](https://doc.arcgis.com/en/arcgis-online/share-maps/share-items.htm)
278-
services,
279-
- publishing a new service (the authorized user must also have
280-
[publishing
281-
privileges](https://doc.arcgis.com/en/arcgis-online/administer/roles.htm)),
282-
and
283-
- modifying or deleting any existing service (the authorized user must
284-
also have [edit
285-
access](https://doc.arcgis.com/en/arcgis-online/manage-data/manage-editing-hfl.htm)
286-
to the service).
268+
- interacting with [non-public](https://doc.arcgis.com/en/arcgis-online/share-maps/share-items.htm) services,
269+
- publishing a new service (the authorized user must also have [publishing privileges](https://doc.arcgis.com/en/arcgis-online/administer/roles.htm)), and
270+
- modifying or deleting any existing service (the authorized user must also have [edit access](https://doc.arcgis.com/en/arcgis-online/manage-data/manage-editing-hfl.htm) to the service).
287271

288272
### Accessing non-public data
289273

290-
The same functions for reading public ArcGIS Online and Enterprise
291-
services (such as
292-
`arc_open()`,`arc_read()`,`arc_select()`,`arc_raster()`, etc.) can be
293-
used to read data from non-public services by using the `token`
294-
argument. For more information on tokens and authorization functions,
295-
see the [authorization
296-
article](https://r.esri.com/r-bridge-site/location-services/connecting-to-a-portal.html).
274+
The same functions for reading public ArcGIS Online and Enterprise services (such as `arc_open()`,`arc_read()`,`arc_select()`,`arc_raster()`, etc.) can be used to read data from non-public services by using the `token` argument.
275+
For more information on tokens and authorization functions, see the [authorization article](https://r.esri.com/r-bridge-site/location-services/connecting-to-a-portal.html).
297276

298277
### Publishing and modifying services from R
299278

300279
The package includes functions to publish data to an ArcGIS Portal:
301280

302-
- `add_item()`: Creates a new FeatureCollection from a `sf` or
303-
`data.frame` object
281+
- `add_item()`: Creates a new FeatureCollection from a `sf` or `data.frame` object
304282
- `publish_item()`: Publishes an existing FeatureLayer
305-
- `publish_layer()`: is a higher level wrapper around both `add_item()`
306-
and `publish_item()`
283+
- `publish_layer()`: is a higher level wrapper around both `add_item()` and `publish_item()`
307284

308-
There are also functions to add or modify data including
309-
`add_features()`, `update_features()`, and `delete_features()`. For a
310-
more detailed guide to adding, updating, and deleting features, view the
311-
tutorial on the [R-ArcGIS Bridge
312-
website](https://r.esri.com/r-bridge-site/location-services/workflows/add-delete-update.html).
285+
There are also functions to add or modify data including `add_features()`, `update_features()`, and `delete_features()`. For a more detailed guide to adding, updating, and deleting features, view the tutorial on the [R-ArcGIS Bridge website](https://r.esri.com/r-bridge-site/location-services/workflows/add-delete-update.html).
313286

314-
These functions all require authorization since data cannot be published
315-
or modified anonymously in ArcGIS Online and ArcGIS Enterprise.
287+
These functions all require authorization since data cannot be published or modified anonymously in ArcGIS Online and ArcGIS Enterprise.
55.1 KB
Loading

0 commit comments

Comments
 (0)