Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Programming ArcGIS with Python Cookbook, Second Edition

You're reading from   Programming ArcGIS with Python Cookbook, Second Edition Over 85 hands-on recipes to teach you how to automate your ArcGIS for Desktop geoprocessing tasks using Python

Arrow left icon
Product type Paperback
Published in Jul 2015
Publisher
ISBN-13 9781785282898
Length 366 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Eric Pimpler Eric Pimpler
Author Profile Icon Eric Pimpler
Eric Pimpler
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

Preface 1. Fundamentals of the Python Language for ArcGIS 2. Managing Map Documents and Layers FREE CHAPTER 3. Finding and Fixing Broken Data Links 4. Automating Map Production and Printing 5. Executing Geoprocessing Tools from Scripts 6. Creating Custom Geoprocessing Tools 7. Querying and Selecting Data 8. Using the ArcPy Data Access Module with Feature Classes and Tables 9. Listing and Describing GIS Data 10. Customizing the ArcGIS Interface with Add-ins 11. Error Handling and Troubleshooting 12. Using Python for Advanced ArcGIS 13. Using Python with ArcGIS Pro A. Automating Python Scripts B. Five Python Recipes Every GIS Programmer Should Know Index

Deleting rows with UpdateCursor


In addition to being used to edit rows in a table or feature class, UpdateCursor can also be used to delete rows. Keep in mind that when rows are deleted outside an edit session, the changes are permanent.

Getting ready

In addition to updating records, UpdateCursor can also delete records from a table or feature class. The UpdateCursor object is created in the same way in either case, but instead of calling updateRow(), you call deleteRow() to delete a record. You can also apply a where clause to UpdateCursor, to limit the records returned. In this recipe, we'll use an UpdateCursor object that has been filtered using a where clause to delete records from our FireIncidents feature class.

How to do it…

Follow these steps to create an UpdateCursor object that will be used to delete rows from a feature class:

  1. Open IDLE and create a new script.

  2. Save the script to C:\ArcpyBook\Ch8\DeleteWildfires.py.

  3. Import the arcpy and os modules:

    import arcpy
    import os
  4. Set the workspace...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime