overview cursors arcpy.da module geometrys arrays spatialreferences licensing and installation
Post on 29-Dec-2015
226 Views
Preview:
TRANSCRIPT
Overview
Cursors
arcpy.da module
Geometrys
Arrays
SpatialReferences
Licensing and Installation
arcpy.*Cursor functions
SearchCursor Syntax
SearchCursor Example
Update Cursor Syntax
Update cursor example
InsertCursor Example
Insert/Update and Locked data
Can not Insert/Update if data is lockedFeature class or table can be locked if it is:
Part of a map in an MXD that is open in ArcMapPart of a workspace being viewed by ArcCatalog
Best practices include:Exit ArcGIS applications when running scripts that create or modify tables or feature classesDelete cursor objects when you have finished using them …
The Data Access (da) module
arcpy.da.Walk( ) – an ArcGIS-aware version of os.path.walk ( )
New at 10.1
SearchCursor Function and Classarcpy Function
arcpy.da Class
SearchCursor Function and Class Example
262 sec for Function0.66 sec for Class~ 400 times faster in this case
Output:
arcpy.da.SearchCursor Class syntaxSearchCursor (in_table, field_names, {where_clause}, {spatial_reference}, {explode_to_points}, {sql_clause})
arcpy.SearchCursor Function syntaxSearchCursor (dataset, {where_clause}, {spatial_reference}, {fields}, {sort_fields})
The Geometry Class
Geometry Properties
Geometry Methods
… and clipcontainsconvexHullcrossesdifferencedisjointdistanceToequalsgetAreagetLengthgetPartintersectoverlapspositionAlongLineprojectAssymmetricDifferencetouchesunionwithin
Reading geometries
Writing geometries using Python
Problem: We have a text file containing a line identifier andx,y coordinates that we would like to use to createpolylines in an new feature class similar to an existing feature class
Solution:Create a script tool that has two inputs (text file name andtemplate feature class) and one output feature class.The script will - Create a new feature class based on the template feature class- Read the ID and coords for each line from the text file- Use an insert cursor to add each line to the new feature class
Before writing polylines to a feature class …
… need some other background
Polylines are created from an array of points
How is a point created?How is an array points created?
Polyline
Writing geometries using Python
For Update/InsertCursor objects, test your scripts on a copy of the dataset. It is sometimes hard to undo modifications to data!
Input file structure:
Spatial reference and cursors
Creating a spatial reference
Licensing and Installation
Licensing and Installation
Check to see if a license is available
Returns license to license manager
Check out license from license manager
See if requested product is available
Information about installation
Install types that used with GetInstallInfo
Current product license
Legacy … replaced by
top related