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.
os.startfile and webbrowser.open are two very useful functions in the Python library. However, due to some conflicts in the way the Windows libraries expect to be called, they can fail or crash when called within ArcGIS for Desktop in an add-in script or geoprocessing script tool (see the Remarks section on this MSDN reference page).
# A decorator that will run its wrapped function in a new thread
# functool.wraps will copy over the docstring and some other metadata
# from the original function
def fn_(*args, **kwargs):
thread = threading.Thread(target=function, args=args, kwargs=kwargs)
# Our new wrapped versions of os.startfile and webbrowser.open
startfile = run_in_other_thread(os.startfile)
openbrowser = run_in_other_thread(webbrowser.open)
The local functions startfile and openbrowser will be made available, which have the same parameters as the versions in the standard library but will run in another thread and therefore work as expected.