diff --git a/_freeze/docs/editing/delete-features/execute-results/html.json b/_freeze/docs/editing/delete-features/execute-results/html.json new file mode 100644 index 0000000..1d4890f --- /dev/null +++ b/_freeze/docs/editing/delete-features/execute-results/html.json @@ -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\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\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\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 + } +} \ No newline at end of file diff --git a/_quarto.yml b/_quarto.yml index c7d7094..c859893 100644 --- a/_quarto.yml +++ b/_quarto.yml @@ -80,4 +80,5 @@ format: highlight-style: pygments -freeze: true \ No newline at end of file +execute: + freeze: true \ No newline at end of file diff --git a/docs/editing/delete-features.qmd b/docs/editing/delete-features.qmd index d19513c..c6ae1a7 100644 --- a/docs/editing/delete-features.qmd +++ b/docs/editing/delete-features.qmd @@ -2,8 +2,21 @@ title: Deleting features --- +```{r include=FALSE} +knitr::opts_chunk$set(eval = FALSE) +``` + While `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. +```{r} +library(arcgis) +set_arc_token(auth_code()) + +nc_url <- "https://services1.arcgis.com/hLJbHVT9ZrDIzK0I/arcgis/rest/services/North%20Carolina%20SIDS/FeatureServer/0" + +nc <- arc_open(nc_url) +``` + We 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. ```{r} @@ -106,4 +119,4 @@ CRS: 4267 Capabilities: Create,Delete,Query,Update,Editing ``` -Using `delete_features(x, where = "1 = 1")` is basically the equivalent of `truncate_layer()`. \ No newline at end of file +Note that you shuold use `truncate_layer()` instead of `delete_features(x, where = "1 = 1")`. \ No newline at end of file