This is a piece of code i’ve written and re-written dozens of times. Typically I code it on a whim for a single use.
Today I went the extra mile and made the output really nice, so here it is in case somebody has use for it.
And this is what you get as output in the python window*.
* this is the nice and new ArcGIS Pro’s python window.
The output is a bit too wide for use in terminal (80 characters) but within the app it’s nice and clear.
A lot of people are posting requests asking for a particular snippet in the comments section of this blog.
By all means, continue to do so, we do enjoy tackling the more generic and broadly useful requests… but we just can’t tackle all of them, and not in a timely manner.
So if you need help with code, and you need it fairly soon, please consider also opening a discussion on the Esri geonet site.
Once upon a time, there was but a single tech workshop at the Esri international user conference which featured everybody’s favorite scripting language. No longer is the Python offering so paltry. Behold, the 2014 user conference technical workshops & demo theaters returned when you search for “python”.
Consult the online agenda for date and time when these are offered.
- Python: Getting started
- Python: Beyond the Basics
- Python: Map Automation
- Python Map Automation: An Introduction to arcpy.mapping
- Python Map Automation: Beyond the Basics of arcpy.mapping
- Python: Raster Analysis
- Python: Building Geoprocessing Tools
- Python for Analysis
- Analyzing Multidimensional Scientific Data in ArcGIS
- Automating Geodatabase Creation with Geoprocessing Tools
- Creating Geoprocessing Services
- Desktop Mapping: Building Map Books
- ArcGIS Online: Administering your ArcGIS Organization Through Scripting
- ArcGIS for Server Administrative Scripting and Automation
- ArcGIS Network Analyst: Automating Workflows with Geoprocessing
- Integrating Open-Source Statistical Packages with ArcGIS
- Useflul Python Libraries for The GIS Professional
Demo theater presentations
- Administering ArcGIS for Server with Python
- Building Live Data Feeds Using Python
- Consuming Geoprocessing and Hosted Analytic Services in ArcGIS for Desktop
- Debugging Python Scripts
- Esri Production Mapping: Automating Map Production Workflows Using the ArcPyProduction Site Package
- Geoprocessing on Image Services
- Getting Started With Map Algebra Using the Raster Calculator and Python
- Getting Started with Python in ArcGIS
- Interacting with the ArcGIS Server Admin API using Python
- Managing an Online Data Warehouse: Using Python to Publish Data to ArcGIS Online
- Python Add-ins: Tips and Tricks
The 2014 PyCon US conference ran from April 9 to the 13th in Montreal, Canada.
For those of you looking to expand your knowledge of Python, this can be a good source of tutorial/tech workshops.
All presentations and tutorials are recorded and published here: PyCon 2014 videos
A few days ago Tony asked for a py script that will write out the OID + x + y for each feature in a polyline feature class / shapefile. No problem we say, see code example at bottom.
This was quick and fun exercise and we were happy to write this code. But for more timely technical help i’d direct people to the esri forums, or gis stack exchange.
Cheers and happy coding.
it was great meeting and talking to everybody at the dev summit.
A number of python/arcpy presenters already shared their code to github repos below.
Somebody on the team was having trouble tracing streams due to breaks in the streams introduced when converting raster to feature.
So here is slick little solution which takes n paths in a line features and makes a 1 path (aka 1 part) out of it.
None of the vertices are moved. Where there were two paths separated by a gap you will have one path with no gap.
To work property the paths have to be pointed in the same direction and not be converging. To deal with that would require quite a bit more logic.
As is script modified data in place, so back up your data before using.