Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create DeleteFeatures_onebyone_Portal.ipynb #1653

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

rmesend
Copy link

@rmesend rmesend commented Sep 11, 2023

one notebook to delete elements in AGOL one by one.

<insert pull request description here>


Checklist

Please go through each entry in the below checklist and mark an 'X' if that condition has been met. Every entry should be marked with an 'X' to be get the Pull Request approved.

  • [X ] All imports are in the first cell?
    • [X ] First block of imports are standard libraries
    • Second block are 3rd party libraries
    • Third block are all arcgis imports? Note that in some cases, for samples, it is a good idea to keep the imports next to where they are used, particularly for uncommonly used features that we want to highlight.
  • [x ] All GIS object instantiations are one of the following?
    • gis = GIS()
    • gis = GIS('home') or gis = GIS('pro')
    • gis = GIS(profile="your_online_portal")
    • gis = GIS(profile="your_enterprise_portal")
  • If this notebook requires setup or teardown, did you add the appropriate code to ./misc/setup.py and/or ./misc/teardown.py?
  • [ x] If this notebook references any portal items that need to be staged on AGOL/Python API playground, did you coordinate with a Python API team member to stage the item the correct way with the api_data_owner user?
  • If the notebook requires working with local data (such as CSV, FGDB, SHP, Raster files), upload the files as items to the Geosaurus Online Org using api_data_owner account and change the notebook to first download and unpack the files.
  • Code simplified & split out across multiple cells, useful comments?
  • Consistent voice/tense/narrative style? Thoroughly checked for typos?
  • All images used like <img src="base64str_here"> instead of <img src="https://some.url">? All map widgets contain a static image preview? (Call mapview_inst.take_screenshot() to do so)
  • All file paths are constructed in an OS-agnostic fashion with os.path.join()? (Instead of r"\foo\bar", os.path.join(os.path.sep, "foo", "bar"), etc.)
  • [x ] Is your code formatted using Jupyter Black? You can use Jupyter Black to format your code in the notebook.
  • IF YOU WANT THIS SAMPLE TO BE DISPLAYED ON THE DEVELOPERS.ARCGIS.COM WEBSITE, ping @ mohi9282 so he can add it to the list for the next deploy

one notebook to delete elements in AGOL one by one.
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

This Python code leverages the `arcgis` library to interact with ArcGIS Online. It begins by establishing a session on ArcGIS Online using your credentials (username and password). You'll need to replace `"tu_usuario"` and `"tu_contraseña"` with your actual ArcGIS Online username and password. Next, it identifies a specific Feature Service within ArcGIS Online by its ID, which you should replace with the actual ID of your desired Feature Service. The code then accesses the first layer within this Feature Service and performs a query to retrieve a list of elements from the layer.

Subsequently, it goes through each retrieved element one by one, deleting them individually using the `edit_features` method with the 'deletes' operation. The 'OBJECTID' attribute is used to uniquely identify and remove each element. Finally, it prints a success message to indicate that the elements have been successfully deleted. It's important to ensure that you have the necessary permissions to perform editing operations on the Feature Service you are working with.

This is an update of this FAQ: https://support.esri.com/en-us/knowledge-base/faq-is-it-possible-to-batch-delete-features-in-arcgis-o-000013805
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant