-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d4029e0
commit b49f2af
Showing
3 changed files
with
31 additions
and
2 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
_freeze/docs/editing/delete-features/execute-results/html.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"hash": "71163cdaa4a3d1dc96c7bc9fd2af5135", | ||
"result": { | ||
"engine": "knitr", | ||
"markdown": "---\ntitle: Deleting features\n---\n\n\n\n\nWhile `add_features()` and `update_features()` had a very similar syntax, `delete_features()` has a somewhat different interface. We have 3 different ways in which we can delete features. Here we will explore only two of them.\n\n\n::: {.cell}\n\n```{.r .cell-code}\nlibrary(arcgis)\nset_arc_token(auth_code())\n\nnc_url <- \"https://services1.arcgis.com/hLJbHVT9ZrDIzK0I/arcgis/rest/services/North%20Carolina%20SIDS/FeatureServer/0\" \n\nnc <- arc_open(nc_url)\n```\n:::\n\n\nWe can delete features based on object IDs or a SQL where clause. Let's explore deleting features based on object IDs. To do so, we need to pass the `FeatureLayer` obejct as the first argument to `delete_features()`. The second argument is a numeric vector of the IDs we want to delete. The ID `101` is the new feature that we created. \n\n\n::: {.cell}\n\n```{.r .cell-code}\ndelete_res <- delete_features(nc, object_ids = 101)\ndelete_res\n```\n:::\n\n\n```\n$deleteResults\n objectId uniqueId globalId success\n1 101 101 NA TRUE\n```\n\nWe can check to see if the delete worked by refreshing the layer and seeing the count that is printed out. \n\n\n::: {.cell}\n\n```{.r .cell-code}\nrefresh_layer(nc)\n```\n:::\n\n```\n<FeatureLayer>\nName: North Carolina SIDS\nGeometry Type: esriGeometryPolygon\nCRS: 4267\nCapabilities: Create,Delete,Query,Update,Editing\n```\n\nAlternatively, we can delete features based on a `where` clause. Say we wanted to delete all of the features where the `BIR74` value was less than `1000`. We can accomplish this using a where clause. \n\n\n::: {.cell}\n\n```{.r .cell-code}\ndelete_res <- delete_features(nc, where = \"BIR74 < 1000\")\ndelete_res\n```\n:::\n\n```\n$deleteResults\n objectId uniqueId globalId success\n1 2 2 NA TRUE\n2 4 4 NA TRUE\n3 7 7 NA TRUE\n4 8 8 NA TRUE\n5 9 9 NA TRUE\n6 20 20 NA TRUE\n7 21 21 NA TRUE\n8 22 22 NA TRUE\n9 32 32 NA TRUE\n10 35 35 NA TRUE\n11 38 38 NA TRUE\n12 44 44 NA TRUE\n13 45 45 NA TRUE\n14 56 56 NA TRUE\n15 58 58 NA TRUE\n16 59 59 NA TRUE\n17 73 73 NA TRUE\n18 77 77 NA TRUE\n19 78 78 NA TRUE\n20 80 80 NA TRUE\n21 83 83 NA TRUE\n22 87 87 NA TRUE\n23 90 90 NA TRUE\n```\n\nSuccessful deletes! Again, we can check to see the new count using `refresh_layer()`.\n\n\n::: {.cell}\n\n```{.r .cell-code}\nrefresh_layer(nc)\n```\n:::\n\n```\n<FeatureLayer>\nName: North Carolina SIDS\nGeometry Type: esriGeometryPolygon\nCRS: 4267\nCapabilities: Create,Delete,Query,Update,Editing\n```\n\nLastly, if you want to delete _every single feature_. We can take advantage of the where clause again. If we set `where = \"1 = 1\"` that will evaluate `TRUE` for every single feature.\n\n\n::: {.cell}\n\n```{.r .cell-code}\ndelete_res <- delete_features(nc, where = \"1 = 1\")\ndelete_res\n```\n:::\n\n```\n$deleteResults\n objectId uniqueId globalId success\n1 1 1 NA TRUE\n2 3 3 NA TRUE\n3 5 5 NA TRUE\n4 6 6 NA TRUE\n5 10 10 NA TRUE\n6 11 11 NA TRUE\n ... Truncated ...\n```\n\n\n::: {.cell}\n\n```{.r .cell-code}\nrefresh_layer(nc)\n```\n:::\n\n```\n<FeatureLayer>\nName: North Carolina SIDS\nGeometry Type: esriGeometryPolygon\nCRS: 4267\nCapabilities: Create,Delete,Query,Update,Editing\n```\n\nNote that you shuold use `truncate_layer()` instead of `delete_features(x, where = \"1 = 1\")`.", | ||
"supporting": [], | ||
"filters": [ | ||
"rmarkdown/pagebreak.lua" | ||
], | ||
"includes": {}, | ||
"engineDependencies": {}, | ||
"preserve": {}, | ||
"postProcess": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,4 +80,5 @@ format: | |
|
||
highlight-style: pygments | ||
|
||
freeze: true | ||
execute: | ||
freeze: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters