SlideShare uma empresa Scribd logo
1 de 58
Baixar para ler offline
ModelBuilder to Python:
Step-by-Step
Zeke Houk
GIS Developer
ModelBuilder Model:
Delete Features from
simple_conduits:
Pull snapshot from SDE:
Get Rid of Conduit 0:
Dissolve on Conduit Number:
Guido Van Rossum
BDFL
Where did the name come from?
Python script:
Clean up names:
• >>> # Local variables:
• >>> simple_conduits__3_ =
R:ARG_ProjectsConduitMapBookDissolvedConduits.gdbsimple_conduits"
• >>> dissolved_conduits__3_ = "R:ARG_ProjectsConduit
MapBookDissolvedConduits.gdbdissolved_conduits"
• >>> ARG_CONDUIT__3_ = "Database ConnectionsConnection to
DWGIS3.sdeARG.DistributionSystemARG.CONDUIT"
• >>> simple_conduits__4_ = "R:ARG_ProjectsConduit
MapBookDissolvedConduits.gdbsimple_conduits"
• >>> N0_Zero_Conduits = "R:ARG_ProjectsConduit
MapBookDissolvedConduits.gdbN0_Zero_Conduits"
• >>> dissolved_conduits = "R:ARG_ProjectsConduit
MapBookDissolvedConduits.gdbdissolved_conduits"
• >>> simple_conduits__6_ = "R:ARG_ProjectsConduit
MapBookDissolvedConduits.gdbsimple_conduits"
>>> simple_conduits_3_,
>>> simple_conduits_4_,
>>> simple_Conduits_6_
>>> redundant…
Replace with simple_conduits:
• >>> # Local variables:
• >>> simple_conduits = "R:ARG_ProjectsConduit
MapBookDissolvedConduits.gdbsimple_conduits"
• >>> dissolved_conduits__3_ = "R:ARG_ProjectsConduit
MapBookDissolvedConduits.gdbdissolved_conduits"
• >>> ARG_CONDUIT__3_ = "Database ConnectionsConnection to
DWGIS3.sdeARG.DistributionSystemARG.CONDUIT"
• >>> simple_conduits = "R:ARG_ProjectsConduit
MapBookDissolvedConduits.gdbsimple_conduits"
• >>> N0_Zero_Conduits = "R:ARG_ProjectsConduit
MapBookDissolvedConduits.gdbN0_Zero_Conduits"
• >>> dissolved_conduits = "R:ARG_ProjectsConduit
MapBookDissolvedConduits.gdbdissolved_conduits"
• >>> simple_conduits = "R:ARG_ProjectsConduit
MapBookDissolvedConduits.gdbsimple_conduits"
Global replace simple_conduits
For simple_conduits_3_,
simple_conduits_4_, and
simple_conduits_6_.
Duplicates dropped:
>>> # Local variables:
>>> simple_conduits = "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdbsimple_conduits"
>>> dissolved_conduits__3_ = "R:ARG_ProjectsConduit
MapBookDissolvedConduits.gdbdissolved_conduits"
>>> ARG_CONDUIT__3_ = "Database ConnectionsConnection to
DWGIS3.sdeARG.DistributionSystemARG.CONDUIT"
>>> N0_Zero_Conduits = "R:ARG_ProjectsConduit
MapBookDissolvedConduits.gdbN0_Zero_Conduits"
>>> dissolved_conduits = "R:ARG_ProjectsConduit
MapBookDissolvedConduits.gdbdissolved_conduits"
Global replace simple_conduits
For simple_conduits_3_,
simple_conduits_4_, and
simple_Conduits_6_.
Now fix dissolved_conduits:
# Local variables:
simple_conduits = "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdbsimple_conduits"
dissolved_conduits = "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdbdissolved_conduits"
ARG_CONDUIT__3_ = "Database ConnectionsConnection to
DWGIS3.sdeARG.DistributionSystemARG.CONDUIT"
N0_Zero_Conduits = "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdbN0_Zero_Conduits"
Becomes…
# Local variables:
simple_conduits = "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdbsimple_conduits"
dissolved_conduits__3_ = "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdbdissolved_conduits"
ARG_CONDUIT__3_ = "Database ConnectionsConnection to DWGIS3.sdeARG.DistributionSystemARG.CONDUI
N0_Zero_Conduits = "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdbN0_Zero_Conduits"
dissolved_conduits = "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdbdissolved_conduits"
Use File Geodatabase Name:
• # Local variables:
• file_gdb = "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdb"
• simple_conduits = file_gdb + "simple_conduits"
• dissolved_conduits = file_gdb + "dissolved_conduits"
• N0_Zero_Conduits = file_gdb + "N0_Zero_Conduits"
• ARG_CONDUIT = "Database ConnectionsConnection to
DWGIS3.sdeARG.DistributionSystemARG.CONDUIT"
Becomes…
• # Local variables:
• simple_conduits = "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdbsimple_conduits"
• dissolved_conduits = "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdbdissolved_conduits"
• ARG_CONDUIT = "Database ConnectionsConnection to DWGIS3.sdeARG.DistributionSystemARG.CONDUI
• N0_Zero_Conduits = "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdbN0_Zero_Conduits"
Use File Geodatabase Name:
file_gdb = "R:ARG_ProjectsConduit
MapBookDissolvedConduits.gdb"
simple_conduits = file_gdb + "simple_conduits"
dissolved_conduits = file_gdb + "dissolved_conduits"
N0_Zero_Conduits = file_gdb + "N0_Zero_Conduits"
Use SDE Connection Name:
# Local variables:
file_gdb = "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdb"
simple_conduits = file_gdb + "simple_conduits"
dissolved_conduits = file_gdb + "dissolved_conduits"
N0_Zero_Conduits = file_gdb + "N0_Zero_Conduits"
sde_connection = "Database ConnectionsConnection to DWGIS3.sde"
ARG_CONDUIT = sde_connection + "ARG.CONDUIT"
Becomes…
# Local variables:
file_gdb = "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdb"
simple_conduits = file_gdb + "simple_conduits"
dissolved_conduits = file_gdb + "dissolved_conduits"
N0_Zero_Conduits = file_gdb + "N0_Zero_Conduits"
ARG_CONDUIT = "Database ConnectionsConnection to DWGIS3.sdeARG.DistributionSystemARG.CONDUIT"
Use SDE Connection Name:
sde_connection = "Database ConnectionsConnection to
DWGIS3.sde"
ARG_CONDUIT = sde_connection + "ARG.CONDUIT"
Cleaned up names:
# Local variables:
file_gdb = "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdb"
simple_conduits = file_gdb + "simple_conduits"
dissolved_conduits = file_gdb + "dissolved_conduits"
N0_Zero_Conduits = file_gdb + "N0_Zero_Conduits"
sde_connection = "Database ConnectionsConnection to DWGIS3.sde"
ARG_CONDUIT = sde_connection + "ARG.CONDUIT"
Congratulations!
PyWin:
PyWin
Python for Windows extensions
by
Mark Hammond
http://sourceforge.net/projects/pywin32/
pywin32-218.win32-py2.7.exe
Process Steps:
Delete Features from simple_conduits
Append from SDE into simple_conduits,
just COND_NUM and WATER_TYPE
Delete NO_Zero_Conduits
Select from simple_conduits into N0_Zero_Conduits
Delete dissolved_conduits
Dissolve N0_Zero_Conduits into dissolved_conduits
Fix up Process Steps:
• # Process: Append
• arcpy.Append_management(ARG_CONDUIT, simple_conduits, "NO_TEST",
"COND_NUM "COND_NUM" true true false 2 Short 0 0 ,First,#,Database
ConnectionsConnection to
DWGIS3.sdeARG.DistributionSystemARG.CONDUIT,COND_NUM,-1,-
1;WATER_TYPE "WATER_TYPE" true true false 5 Text 0 0 ,First,#,Database
ConnectionsConnection to
DWGIS3.sdeARG.DistributionSystemARG.CONDUIT,WATER_TYPE,-1,-
1;Shape_Length "Shape_Length" false true true 8 Double 0 0 ,First,#", "")
Becomes…
• # Process: Append
• arcpy.Append_management(
• "'Database ConnectionsConnection to DWGIS3.sde
• ARG.DistributionSystemARG.CONDUIT'", simple_conduits,
• "NO_TEST", "COND_NUM "COND_NUM" true true false 2 Short 0 0 ,First,#,Database C
Fix up Process Steps:
• # Process: Delete
• arcpy.Delete_management(N0_Zero_Conduits, "FeatureClass")
Becomes…
• # Process: Delete
• arcpy.Delete_management(
• "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdb
• NO_Zero_Conduits",
• "FeatureClass")
Fix up Process Steps:
• # Process: Delete
• arcpy.Delete_management(dissolved_conduits, "FeatureClass")
Becomes…
• # Process: Delete
• arcpy.Delete_management(
• "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdb
• dissolved_conduits",
• "FeatureClass")
All Scrubbed Up:
# Process:
arcpy.DeleteFeatures_management(simple_conduits)
arcpy.Delete_management(N0_Zero_Conduits, "FeatureClass")
arcpy.Delete_management(dissolved_conduits, "FeatureClass")
arcpy.Append_management(ARG_CONDUIT, simple_conduits, "NO_TEST", "COND_NUM
"COND_NUM" true true false 2 Short 0 0 ,First,#,Database ConnectionsConnection to
DWGIS3.sdeARG.DistributionSystemARG.CONDUIT,COND_NUM,-1,-1;WATER_TYPE
"WATER_TYPE" true true false 5 Text 0 0 ,First,#,Database ConnectionsConnection to
DWGIS3.sdeARG.DistributionSystemARG.CONDUIT,WATER_TYPE,-1,-1;Shape_Length
"Shape_Length" false true true 8 Double 0 0 ,First,#", "")
arcpy.Select_analysis(simple_conduits, N0_Zero_Conduits, ""COND_NUM" <> 0")
arcpy.Dissolve_management(N0_Zero_Conduits, dissolved_conduits,
"COND_NUM;WATER_TYPE", "", "SINGLE_PART", "DISSOLVE_LINES")
Geek Speak - If:
if arcpy.Exists(something):
# do something with it
if not arcpy.Exists(something):
# it does not exist
Avoid Errors:
if arcpy.Exists(dissolved_conduits):
arcpy.Delete_management(dissolved_conduits, "FeatureClass")
Becomes…
arcpy.Delete_management(dissolved_conduits, "FeatureClass")
Delete Processes:
if arcpy.Exists(N0_Zero_Conduits):
arcpy.Delete_management(N0_Zero_Conduits, "FeatureClass")
if arcpy.Exists(dissolved_conduits):
arcpy.Delete_management(dissolved_conduits, "FeatureClass")
if arcpy.Exists(simple_conduits):
arcpy.DeleteFeatures_management(simple_conduits)
else:
print "Missing feature class -> " + simple_conduits
Alternative:
>>> from arcpy import env
>>> env.overwriteOutput = True
>>> env.workspace = “C:/EsriPress/Python/Data/”
Either way, explain:
>>> # There feature classes probably already exist.
>>> # They are left over from the last time we ran this script.
>>> # Deleting the old versions makes room for the new ones.
Geek Speak – Try / Catch:
>>> try:
>>> # .. To do something that might blow up
>>> # and it “throws” an Exception
>>> except Exception ex:
>>> print ex
>>>
Catch Exception:
>>> try:
>>> arcpy.Append_management(CONDUIT
>> except Exception as ex:
>>> print ex
Test Exception:
>>> try:
>>> bogus = 1.0 / 0.0 # forces exception
>>> arcpy.Append_management(ARG_CONDUIT,
>>> except Exception as ex:
>>> print ex
Logging:
import logging
logfile = "C:/temp/demo.log"
logging.basicConfig(
level=logging.INFO,
filename=logfile)
logger = logging.getLogger()
logger.info("A swallow beats its wings 43 times every second.")
logger.warning("Go away or I shall taunt you a second time.")
logger.error("Run away! Run away!")
print "Done."
C:tempdemo.log:
INFO:A swallow beats its wings 43 times every second.
WARNING:Go away or I shall taunt you a second time.
ERROR:Run away! Run away!
Logging:
logging.info(" checking for " + HYDRANT_BRANCH )
if arcpy.Exists(HYDRANT_BRANCH ):
try:
arcpy.Append_management(APPEND_HYD_BR, hyd_branch, ...)
logging.info(" HYDRANT_BRANCH_shp appended to SDE")
except Exception as ex:
logging.error(" HYDRANT_BRANCH_shp append FAILED")
logging.Exeception(ex)
Recap – Do These 3 Things…
1. Organize variable names
2. Trap Errors
3. Write a log file
"First shalt thou take out the Holy Pin.
Then shalt thou count to three, no more, no less.
Three shall be the number thou shalt count, and the
number of the counting shall be three.”
Pythonic:
• Explicit is better than implicit.
• Simple is better than complex.
• Readability counts.
The Zen of Python, by Tim Peters,
includes:
Geek Speak - Blocks:
>>> if arcpy.Exists(simple_conduits):
>>>
arcpy.DeleteFeatures_management(simple_conduits)
>>> # maybe do something else
>>> # some additional processing
>>> else:
>>> print "Missing feature class -> " + simple_conduits
Duck Typing:
If it looks like a duck, quacks like a duck, etc.
Works with strings,
integers,
floating point,
lists,
etc.
Strings:
Enclosed in either ‘single’ or “double” quotes.
Concatenate using + sign.
>>> topic = "GIS"
>>> location = "Rockies“
>>> event = topic + " in the " + location
>>> print event
GIS in the Rockies
Strings:
More built-in functions:
>>> event = "GIS in the Rockies"
>>> print event.lower()
>>> print event.upper()
>>> print event.title()
>>> string_length = len(event)
>>> print string_length
>>> print event.find("Rockies",0,string_length)
gis in the rockies
GIS IN THE ROCKIES
Gis In The Rockies
18
11
Triple quotes can span multiple
lines:
“””The Dead Collector: Bring out yer dead.
Large Man: Here's one.
The Dead Collector: That'll be ninepence.
The Dead Body: I'm not dead.
The Dead Collector: 'Ere, he says he's not dead.
Large Man: Yes he is.
The Dead Body: I'm not.
The Dead Collector: He isn't.
Large Man: Well, he will be soon, he's very ill.
The Dead Body: I'm getting better. “””
Lists:
>>> python_sketch = ['Dead Parrot', 'Confuse-a-Cat', 'Silly
Walks', 'Four Yorkshiremen','Fish Slap'];
>>> # notice duck typing
>>> print python_sketch [0]
>>> print python_sketch [1]
>>> python_sketch.append('Limberjack Song')
>>> print len(python_sketch)
Dead Parrot
Confuse-a-Cat
6
For loop:
>>> for funny_bit sketch in python_sketch:
>>> print funny_bit + ' hahaha‘
Dead Parrot hahaha
Confuse-a-Cat hahaha
Silly Walks hahaha
Four Yorkshiremen hahaha
Fish Slap hahaha
Limberjack Song hahaha
Command Line Args:
>>> userid = arcpy.GetParameterAsText(0)
>>> if not userid:
>>> print ‘Usage: python.exe my_script.py userid password ‘
>>> pword = arcpy.GetParameterAsText(1)
>>> if not pword:
>>> print ‘Usage: python.exe my_script.py userid password ‘
Command Line Args:
C:> D:python27python.exe my_script.py zeke password
Python.exe is located on D:python27
my_script.py is some python code
Userid is zeke
My Oracle password is at the end
Command Line Args:
>>> userid = arcpy.GetParameterAsText(0)
>>> pword = arcpy.GetParameterAsText(1)
Oracle connection:
connection_string = userid + '/' + pword + '@dwsde'
# looks like this -> zeke/password@dwsde
import cx_Oracle
connection = cx_Oracle.connect(connection_string)
cursor = connection.cursor()
cursor.execute('select distinct water_type from conduit')
for result in cursor:
print result
Oracle connection:
cursor.execute('select distinct diameter from conduit')
allresults = cursor.fetchall()
for result in allresults:
print result
cursor.close()
connection.close()
print "Done."
Nee
Here is a shrubbery.
Not Habit Forming:
But is considered a “Gateway”
language,
which frequently leads to more
nerdy behavior.
Good Book:
Good Book:
GIS Day November 22:
See denverwater.org for directions...
Becomes…

Mais conteúdo relacionado

Semelhante a 2013 Tips and Tricks Mashup, From ModelBuilder to Formal Python Code, Step-by-Step by Zeke Houk

Novalug 07142012
Novalug 07142012Novalug 07142012
Novalug 07142012Mandi Walls
 
Umleitung: a tiny mochiweb/CouchDB app
Umleitung: a tiny mochiweb/CouchDB appUmleitung: a tiny mochiweb/CouchDB app
Umleitung: a tiny mochiweb/CouchDB appLenz Gschwendtner
 
11. From Hadoop to Spark 2/2
11. From Hadoop to Spark 2/211. From Hadoop to Spark 2/2
11. From Hadoop to Spark 2/2Fabio Fumarola
 
Building a Cross Channel Content Delivery Platform with MongoDB
Building a Cross Channel Content Delivery Platform with MongoDBBuilding a Cross Channel Content Delivery Platform with MongoDB
Building a Cross Channel Content Delivery Platform with MongoDBMongoDB
 
Lens: Data exploration with Dask and Jupyter widgets
Lens: Data exploration with Dask and Jupyter widgetsLens: Data exploration with Dask and Jupyter widgets
Lens: Data exploration with Dask and Jupyter widgetsVíctor Zabalza
 
Gmaps Railscamp2008
Gmaps Railscamp2008Gmaps Railscamp2008
Gmaps Railscamp2008xilinus
 
(BDT203) From Zero to NoSQL Hero: Amazon DynamoDB Tutorial | AWS re:Invent 2014
(BDT203) From Zero to NoSQL Hero: Amazon DynamoDB Tutorial | AWS re:Invent 2014(BDT203) From Zero to NoSQL Hero: Amazon DynamoDB Tutorial | AWS re:Invent 2014
(BDT203) From Zero to NoSQL Hero: Amazon DynamoDB Tutorial | AWS re:Invent 2014Amazon Web Services
 
Automating Research Data Flows and Introduction to the Globus Platform
Automating Research Data Flows and Introduction to the Globus PlatformAutomating Research Data Flows and Introduction to the Globus Platform
Automating Research Data Flows and Introduction to the Globus PlatformGlobus
 
Webinar: Applikationsentwicklung mit MongoDB : Teil 5: Reporting & Aggregation
Webinar: Applikationsentwicklung mit MongoDB: Teil 5: Reporting & AggregationWebinar: Applikationsentwicklung mit MongoDB: Teil 5: Reporting & Aggregation
Webinar: Applikationsentwicklung mit MongoDB : Teil 5: Reporting & AggregationMongoDB
 
Improving Apache Spark Downscaling
 Improving Apache Spark Downscaling Improving Apache Spark Downscaling
Improving Apache Spark DownscalingDatabricks
 
What's new in Redis v3.2
What's new in Redis v3.2What's new in Redis v3.2
What's new in Redis v3.2Itamar Haber
 
Gradle: The Build System you have been waiting for!
Gradle: The Build System you have been waiting for!Gradle: The Build System you have been waiting for!
Gradle: The Build System you have been waiting for!Corneil du Plessis
 
Big Data - Lab A1 (SC 11 Tutorial)
Big Data - Lab A1 (SC 11 Tutorial)Big Data - Lab A1 (SC 11 Tutorial)
Big Data - Lab A1 (SC 11 Tutorial)Robert Grossman
 
Living the Nomadic life - Nic Jackson
Living the Nomadic life - Nic JacksonLiving the Nomadic life - Nic Jackson
Living the Nomadic life - Nic JacksonParis Container Day
 
1403 app dev series - session 5 - analytics
1403   app dev series - session 5 - analytics1403   app dev series - session 5 - analytics
1403 app dev series - session 5 - analyticsMongoDB
 
Tuning and Debugging in Apache Spark
Tuning and Debugging in Apache SparkTuning and Debugging in Apache Spark
Tuning and Debugging in Apache SparkDatabricks
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overviewYehuda Katz
 
Android gradle-build-system-overview
Android gradle-build-system-overviewAndroid gradle-build-system-overview
Android gradle-build-system-overviewKevin He
 

Semelhante a 2013 Tips and Tricks Mashup, From ModelBuilder to Formal Python Code, Step-by-Step by Zeke Houk (20)

Novalug 07142012
Novalug 07142012Novalug 07142012
Novalug 07142012
 
Umleitung: a tiny mochiweb/CouchDB app
Umleitung: a tiny mochiweb/CouchDB appUmleitung: a tiny mochiweb/CouchDB app
Umleitung: a tiny mochiweb/CouchDB app
 
11. From Hadoop to Spark 2/2
11. From Hadoop to Spark 2/211. From Hadoop to Spark 2/2
11. From Hadoop to Spark 2/2
 
Building a Cross Channel Content Delivery Platform with MongoDB
Building a Cross Channel Content Delivery Platform with MongoDBBuilding a Cross Channel Content Delivery Platform with MongoDB
Building a Cross Channel Content Delivery Platform with MongoDB
 
Lens: Data exploration with Dask and Jupyter widgets
Lens: Data exploration with Dask and Jupyter widgetsLens: Data exploration with Dask and Jupyter widgets
Lens: Data exploration with Dask and Jupyter widgets
 
Gmaps Railscamp2008
Gmaps Railscamp2008Gmaps Railscamp2008
Gmaps Railscamp2008
 
(BDT203) From Zero to NoSQL Hero: Amazon DynamoDB Tutorial | AWS re:Invent 2014
(BDT203) From Zero to NoSQL Hero: Amazon DynamoDB Tutorial | AWS re:Invent 2014(BDT203) From Zero to NoSQL Hero: Amazon DynamoDB Tutorial | AWS re:Invent 2014
(BDT203) From Zero to NoSQL Hero: Amazon DynamoDB Tutorial | AWS re:Invent 2014
 
Automating Research Data Flows and Introduction to the Globus Platform
Automating Research Data Flows and Introduction to the Globus PlatformAutomating Research Data Flows and Introduction to the Globus Platform
Automating Research Data Flows and Introduction to the Globus Platform
 
Capistrano2
Capistrano2Capistrano2
Capistrano2
 
Webinar: Applikationsentwicklung mit MongoDB : Teil 5: Reporting & Aggregation
Webinar: Applikationsentwicklung mit MongoDB: Teil 5: Reporting & AggregationWebinar: Applikationsentwicklung mit MongoDB: Teil 5: Reporting & Aggregation
Webinar: Applikationsentwicklung mit MongoDB : Teil 5: Reporting & Aggregation
 
Improving Apache Spark Downscaling
 Improving Apache Spark Downscaling Improving Apache Spark Downscaling
Improving Apache Spark Downscaling
 
What's new in Redis v3.2
What's new in Redis v3.2What's new in Redis v3.2
What's new in Redis v3.2
 
Gradle: The Build System you have been waiting for!
Gradle: The Build System you have been waiting for!Gradle: The Build System you have been waiting for!
Gradle: The Build System you have been waiting for!
 
Big Data - Lab A1 (SC 11 Tutorial)
Big Data - Lab A1 (SC 11 Tutorial)Big Data - Lab A1 (SC 11 Tutorial)
Big Data - Lab A1 (SC 11 Tutorial)
 
Living the Nomadic life - Nic Jackson
Living the Nomadic life - Nic JacksonLiving the Nomadic life - Nic Jackson
Living the Nomadic life - Nic Jackson
 
1403 app dev series - session 5 - analytics
1403   app dev series - session 5 - analytics1403   app dev series - session 5 - analytics
1403 app dev series - session 5 - analytics
 
Tuning and Debugging in Apache Spark
Tuning and Debugging in Apache SparkTuning and Debugging in Apache Spark
Tuning and Debugging in Apache Spark
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overview
 
Android gradle-build-system-overview
Android gradle-build-system-overviewAndroid gradle-build-system-overview
Android gradle-build-system-overview
 
Overview of Spark for HPC
Overview of Spark for HPCOverview of Spark for HPC
Overview of Spark for HPC
 

Mais de GIS in the Rockies

GISCO Fall 2018: Bike Network Equity: A GIS and Qualitative Analysis of Ameri...
GISCO Fall 2018: Bike Network Equity: A GIS and Qualitative Analysis of Ameri...GISCO Fall 2018: Bike Network Equity: A GIS and Qualitative Analysis of Ameri...
GISCO Fall 2018: Bike Network Equity: A GIS and Qualitative Analysis of Ameri...GIS in the Rockies
 
GISCO Fall 2018: Colorado 811: Changes and Challenges – Brian Collison
GISCO Fall 2018: Colorado 811: Changes and Challenges – Brian CollisonGISCO Fall 2018: Colorado 811: Changes and Challenges – Brian Collison
GISCO Fall 2018: Colorado 811: Changes and Challenges – Brian CollisonGIS in the Rockies
 
GISCO Fall 2018: Senate Bill 18-167 and GIS – Dave Murray
GISCO Fall 2018: Senate Bill 18-167 and GIS – Dave MurrayGISCO Fall 2018: Senate Bill 18-167 and GIS – Dave Murray
GISCO Fall 2018: Senate Bill 18-167 and GIS – Dave MurrayGIS in the Rockies
 
2018 GIS in the Rockies Workshop: Coordinate Systems and Projections
2018 GIS in the Rockies Workshop: Coordinate Systems and Projections 2018 GIS in the Rockies Workshop: Coordinate Systems and Projections
2018 GIS in the Rockies Workshop: Coordinate Systems and Projections GIS in the Rockies
 
2018 GIS in Emergency Management: Denver Office of Emergency Management Overview
2018 GIS in Emergency Management: Denver Office of Emergency Management Overview2018 GIS in Emergency Management: Denver Office of Emergency Management Overview
2018 GIS in Emergency Management: Denver Office of Emergency Management OverviewGIS in the Rockies
 
2018 GIS in the Rockies Vendor Showcase (Th): The Data Driven Government
2018 GIS in the Rockies Vendor Showcase (Th): The Data Driven Government2018 GIS in the Rockies Vendor Showcase (Th): The Data Driven Government
2018 GIS in the Rockies Vendor Showcase (Th): The Data Driven GovernmentGIS in the Rockies
 
2018 GIS in the Rockies Vendor Showcase (Th): Solving Real World Issues With ...
2018 GIS in the Rockies Vendor Showcase (Th): Solving Real World Issues With ...2018 GIS in the Rockies Vendor Showcase (Th): Solving Real World Issues With ...
2018 GIS in the Rockies Vendor Showcase (Th): Solving Real World Issues With ...GIS in the Rockies
 
2018 GIS in the Rockies Vendor Showcase (Th): ERDAS Imagine What's New and Ti...
2018 GIS in the Rockies Vendor Showcase (Th): ERDAS Imagine What's New and Ti...2018 GIS in the Rockies Vendor Showcase (Th): ERDAS Imagine What's New and Ti...
2018 GIS in the Rockies Vendor Showcase (Th): ERDAS Imagine What's New and Ti...GIS in the Rockies
 
2018 GIS in the Rockies Vendor Showcase (Th): Building High Performance Gover...
2018 GIS in the Rockies Vendor Showcase (Th): Building High Performance Gover...2018 GIS in the Rockies Vendor Showcase (Th): Building High Performance Gover...
2018 GIS in the Rockies Vendor Showcase (Th): Building High Performance Gover...GIS in the Rockies
 
2018 GIS in Recreation: The Making of a Trail
2018 GIS in Recreation: The Making of a Trail2018 GIS in Recreation: The Making of a Trail
2018 GIS in Recreation: The Making of a TrailGIS in the Rockies
 
2018 GIS in Recreation: The Latest Trail Technology Crowdsourcing Maps and Apps
2018 GIS in Recreation: The Latest Trail Technology Crowdsourcing Maps and Apps2018 GIS in Recreation: The Latest Trail Technology Crowdsourcing Maps and Apps
2018 GIS in Recreation: The Latest Trail Technology Crowdsourcing Maps and AppsGIS in the Rockies
 
2018 GIS in the Rockies: Riparian Shrub Assessment of the Mancos River Canyon...
2018 GIS in the Rockies: Riparian Shrub Assessment of the Mancos River Canyon...2018 GIS in the Rockies: Riparian Shrub Assessment of the Mancos River Canyon...
2018 GIS in the Rockies: Riparian Shrub Assessment of the Mancos River Canyon...GIS in the Rockies
 
2018 GIS in Development: Partnerships Lead to Additional Recreational Content...
2018 GIS in Development: Partnerships Lead to Additional Recreational Content...2018 GIS in Development: Partnerships Lead to Additional Recreational Content...
2018 GIS in Development: Partnerships Lead to Additional Recreational Content...GIS in the Rockies
 
2018 GIS in Recreation: Adding Value to Colorado the Beautiful Initiative carr
2018 GIS in Recreation: Adding Value to Colorado the Beautiful Initiative carr2018 GIS in Recreation: Adding Value to Colorado the Beautiful Initiative carr
2018 GIS in Recreation: Adding Value to Colorado the Beautiful Initiative carrGIS in the Rockies
 
2018 GIS in Recreation: A Creek Runs Through It
2018 GIS in Recreation: A Creek Runs Through It2018 GIS in Recreation: A Creek Runs Through It
2018 GIS in Recreation: A Creek Runs Through ItGIS in the Rockies
 
2018 GIS in Recreation: Virtually Touring the National Trails
2018 GIS in Recreation: Virtually Touring the National Trails2018 GIS in Recreation: Virtually Touring the National Trails
2018 GIS in Recreation: Virtually Touring the National TrailsGIS in the Rockies
 
2018 GIS in the Rockies PLSC Track: Turning Towards the Future
2018 GIS in the Rockies PLSC Track: Turning Towards the Future2018 GIS in the Rockies PLSC Track: Turning Towards the Future
2018 GIS in the Rockies PLSC Track: Turning Towards the FutureGIS in the Rockies
 
2018 GIS in the Rockies PLSC: Intro to PLSS
2018 GIS in the Rockies PLSC: Intro to PLSS2018 GIS in the Rockies PLSC: Intro to PLSS
2018 GIS in the Rockies PLSC: Intro to PLSSGIS in the Rockies
 
2018 GIS in the Rockies PLSC Track: Grid to Ground NATRF2022
2018 GIS in the Rockies PLSC Track: Grid to Ground NATRF20222018 GIS in the Rockies PLSC Track: Grid to Ground NATRF2022
2018 GIS in the Rockies PLSC Track: Grid to Ground NATRF2022GIS in the Rockies
 
2018 GIS in Development: USGS and Citizen Science Success and Enhancements fo...
2018 GIS in Development: USGS and Citizen Science Success and Enhancements fo...2018 GIS in Development: USGS and Citizen Science Success and Enhancements fo...
2018 GIS in Development: USGS and Citizen Science Success and Enhancements fo...GIS in the Rockies
 

Mais de GIS in the Rockies (20)

GISCO Fall 2018: Bike Network Equity: A GIS and Qualitative Analysis of Ameri...
GISCO Fall 2018: Bike Network Equity: A GIS and Qualitative Analysis of Ameri...GISCO Fall 2018: Bike Network Equity: A GIS and Qualitative Analysis of Ameri...
GISCO Fall 2018: Bike Network Equity: A GIS and Qualitative Analysis of Ameri...
 
GISCO Fall 2018: Colorado 811: Changes and Challenges – Brian Collison
GISCO Fall 2018: Colorado 811: Changes and Challenges – Brian CollisonGISCO Fall 2018: Colorado 811: Changes and Challenges – Brian Collison
GISCO Fall 2018: Colorado 811: Changes and Challenges – Brian Collison
 
GISCO Fall 2018: Senate Bill 18-167 and GIS – Dave Murray
GISCO Fall 2018: Senate Bill 18-167 and GIS – Dave MurrayGISCO Fall 2018: Senate Bill 18-167 and GIS – Dave Murray
GISCO Fall 2018: Senate Bill 18-167 and GIS – Dave Murray
 
2018 GIS in the Rockies Workshop: Coordinate Systems and Projections
2018 GIS in the Rockies Workshop: Coordinate Systems and Projections 2018 GIS in the Rockies Workshop: Coordinate Systems and Projections
2018 GIS in the Rockies Workshop: Coordinate Systems and Projections
 
2018 GIS in Emergency Management: Denver Office of Emergency Management Overview
2018 GIS in Emergency Management: Denver Office of Emergency Management Overview2018 GIS in Emergency Management: Denver Office of Emergency Management Overview
2018 GIS in Emergency Management: Denver Office of Emergency Management Overview
 
2018 GIS in the Rockies Vendor Showcase (Th): The Data Driven Government
2018 GIS in the Rockies Vendor Showcase (Th): The Data Driven Government2018 GIS in the Rockies Vendor Showcase (Th): The Data Driven Government
2018 GIS in the Rockies Vendor Showcase (Th): The Data Driven Government
 
2018 GIS in the Rockies Vendor Showcase (Th): Solving Real World Issues With ...
2018 GIS in the Rockies Vendor Showcase (Th): Solving Real World Issues With ...2018 GIS in the Rockies Vendor Showcase (Th): Solving Real World Issues With ...
2018 GIS in the Rockies Vendor Showcase (Th): Solving Real World Issues With ...
 
2018 GIS in the Rockies Vendor Showcase (Th): ERDAS Imagine What's New and Ti...
2018 GIS in the Rockies Vendor Showcase (Th): ERDAS Imagine What's New and Ti...2018 GIS in the Rockies Vendor Showcase (Th): ERDAS Imagine What's New and Ti...
2018 GIS in the Rockies Vendor Showcase (Th): ERDAS Imagine What's New and Ti...
 
2018 GIS in the Rockies Vendor Showcase (Th): Building High Performance Gover...
2018 GIS in the Rockies Vendor Showcase (Th): Building High Performance Gover...2018 GIS in the Rockies Vendor Showcase (Th): Building High Performance Gover...
2018 GIS in the Rockies Vendor Showcase (Th): Building High Performance Gover...
 
2018 GIS in Recreation: The Making of a Trail
2018 GIS in Recreation: The Making of a Trail2018 GIS in Recreation: The Making of a Trail
2018 GIS in Recreation: The Making of a Trail
 
2018 GIS in Recreation: The Latest Trail Technology Crowdsourcing Maps and Apps
2018 GIS in Recreation: The Latest Trail Technology Crowdsourcing Maps and Apps2018 GIS in Recreation: The Latest Trail Technology Crowdsourcing Maps and Apps
2018 GIS in Recreation: The Latest Trail Technology Crowdsourcing Maps and Apps
 
2018 GIS in the Rockies: Riparian Shrub Assessment of the Mancos River Canyon...
2018 GIS in the Rockies: Riparian Shrub Assessment of the Mancos River Canyon...2018 GIS in the Rockies: Riparian Shrub Assessment of the Mancos River Canyon...
2018 GIS in the Rockies: Riparian Shrub Assessment of the Mancos River Canyon...
 
2018 GIS in Development: Partnerships Lead to Additional Recreational Content...
2018 GIS in Development: Partnerships Lead to Additional Recreational Content...2018 GIS in Development: Partnerships Lead to Additional Recreational Content...
2018 GIS in Development: Partnerships Lead to Additional Recreational Content...
 
2018 GIS in Recreation: Adding Value to Colorado the Beautiful Initiative carr
2018 GIS in Recreation: Adding Value to Colorado the Beautiful Initiative carr2018 GIS in Recreation: Adding Value to Colorado the Beautiful Initiative carr
2018 GIS in Recreation: Adding Value to Colorado the Beautiful Initiative carr
 
2018 GIS in Recreation: A Creek Runs Through It
2018 GIS in Recreation: A Creek Runs Through It2018 GIS in Recreation: A Creek Runs Through It
2018 GIS in Recreation: A Creek Runs Through It
 
2018 GIS in Recreation: Virtually Touring the National Trails
2018 GIS in Recreation: Virtually Touring the National Trails2018 GIS in Recreation: Virtually Touring the National Trails
2018 GIS in Recreation: Virtually Touring the National Trails
 
2018 GIS in the Rockies PLSC Track: Turning Towards the Future
2018 GIS in the Rockies PLSC Track: Turning Towards the Future2018 GIS in the Rockies PLSC Track: Turning Towards the Future
2018 GIS in the Rockies PLSC Track: Turning Towards the Future
 
2018 GIS in the Rockies PLSC: Intro to PLSS
2018 GIS in the Rockies PLSC: Intro to PLSS2018 GIS in the Rockies PLSC: Intro to PLSS
2018 GIS in the Rockies PLSC: Intro to PLSS
 
2018 GIS in the Rockies PLSC Track: Grid to Ground NATRF2022
2018 GIS in the Rockies PLSC Track: Grid to Ground NATRF20222018 GIS in the Rockies PLSC Track: Grid to Ground NATRF2022
2018 GIS in the Rockies PLSC Track: Grid to Ground NATRF2022
 
2018 GIS in Development: USGS and Citizen Science Success and Enhancements fo...
2018 GIS in Development: USGS and Citizen Science Success and Enhancements fo...2018 GIS in Development: USGS and Citizen Science Success and Enhancements fo...
2018 GIS in Development: USGS and Citizen Science Success and Enhancements fo...
 

Último

The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 

Último (20)

The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 

2013 Tips and Tricks Mashup, From ModelBuilder to Formal Python Code, Step-by-Step by Zeke Houk

  • 5. Get Rid of Conduit 0:
  • 8. Where did the name come from?
  • 10. Clean up names: • >>> # Local variables: • >>> simple_conduits__3_ = R:ARG_ProjectsConduitMapBookDissolvedConduits.gdbsimple_conduits" • >>> dissolved_conduits__3_ = "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdbdissolved_conduits" • >>> ARG_CONDUIT__3_ = "Database ConnectionsConnection to DWGIS3.sdeARG.DistributionSystemARG.CONDUIT" • >>> simple_conduits__4_ = "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdbsimple_conduits" • >>> N0_Zero_Conduits = "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdbN0_Zero_Conduits" • >>> dissolved_conduits = "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdbdissolved_conduits" • >>> simple_conduits__6_ = "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdbsimple_conduits" >>> simple_conduits_3_, >>> simple_conduits_4_, >>> simple_Conduits_6_ >>> redundant…
  • 11. Replace with simple_conduits: • >>> # Local variables: • >>> simple_conduits = "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdbsimple_conduits" • >>> dissolved_conduits__3_ = "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdbdissolved_conduits" • >>> ARG_CONDUIT__3_ = "Database ConnectionsConnection to DWGIS3.sdeARG.DistributionSystemARG.CONDUIT" • >>> simple_conduits = "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdbsimple_conduits" • >>> N0_Zero_Conduits = "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdbN0_Zero_Conduits" • >>> dissolved_conduits = "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdbdissolved_conduits" • >>> simple_conduits = "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdbsimple_conduits" Global replace simple_conduits For simple_conduits_3_, simple_conduits_4_, and simple_conduits_6_.
  • 12. Duplicates dropped: >>> # Local variables: >>> simple_conduits = "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdbsimple_conduits" >>> dissolved_conduits__3_ = "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdbdissolved_conduits" >>> ARG_CONDUIT__3_ = "Database ConnectionsConnection to DWGIS3.sdeARG.DistributionSystemARG.CONDUIT" >>> N0_Zero_Conduits = "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdbN0_Zero_Conduits" >>> dissolved_conduits = "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdbdissolved_conduits" Global replace simple_conduits For simple_conduits_3_, simple_conduits_4_, and simple_Conduits_6_.
  • 13. Now fix dissolved_conduits: # Local variables: simple_conduits = "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdbsimple_conduits" dissolved_conduits = "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdbdissolved_conduits" ARG_CONDUIT__3_ = "Database ConnectionsConnection to DWGIS3.sdeARG.DistributionSystemARG.CONDUIT" N0_Zero_Conduits = "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdbN0_Zero_Conduits" Becomes… # Local variables: simple_conduits = "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdbsimple_conduits" dissolved_conduits__3_ = "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdbdissolved_conduits" ARG_CONDUIT__3_ = "Database ConnectionsConnection to DWGIS3.sdeARG.DistributionSystemARG.CONDUI N0_Zero_Conduits = "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdbN0_Zero_Conduits" dissolved_conduits = "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdbdissolved_conduits"
  • 14. Use File Geodatabase Name: • # Local variables: • file_gdb = "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdb" • simple_conduits = file_gdb + "simple_conduits" • dissolved_conduits = file_gdb + "dissolved_conduits" • N0_Zero_Conduits = file_gdb + "N0_Zero_Conduits" • ARG_CONDUIT = "Database ConnectionsConnection to DWGIS3.sdeARG.DistributionSystemARG.CONDUIT" Becomes… • # Local variables: • simple_conduits = "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdbsimple_conduits" • dissolved_conduits = "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdbdissolved_conduits" • ARG_CONDUIT = "Database ConnectionsConnection to DWGIS3.sdeARG.DistributionSystemARG.CONDUI • N0_Zero_Conduits = "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdbN0_Zero_Conduits"
  • 15. Use File Geodatabase Name: file_gdb = "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdb" simple_conduits = file_gdb + "simple_conduits" dissolved_conduits = file_gdb + "dissolved_conduits" N0_Zero_Conduits = file_gdb + "N0_Zero_Conduits"
  • 16. Use SDE Connection Name: # Local variables: file_gdb = "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdb" simple_conduits = file_gdb + "simple_conduits" dissolved_conduits = file_gdb + "dissolved_conduits" N0_Zero_Conduits = file_gdb + "N0_Zero_Conduits" sde_connection = "Database ConnectionsConnection to DWGIS3.sde" ARG_CONDUIT = sde_connection + "ARG.CONDUIT" Becomes… # Local variables: file_gdb = "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdb" simple_conduits = file_gdb + "simple_conduits" dissolved_conduits = file_gdb + "dissolved_conduits" N0_Zero_Conduits = file_gdb + "N0_Zero_Conduits" ARG_CONDUIT = "Database ConnectionsConnection to DWGIS3.sdeARG.DistributionSystemARG.CONDUIT"
  • 17. Use SDE Connection Name: sde_connection = "Database ConnectionsConnection to DWGIS3.sde" ARG_CONDUIT = sde_connection + "ARG.CONDUIT"
  • 18. Cleaned up names: # Local variables: file_gdb = "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdb" simple_conduits = file_gdb + "simple_conduits" dissolved_conduits = file_gdb + "dissolved_conduits" N0_Zero_Conduits = file_gdb + "N0_Zero_Conduits" sde_connection = "Database ConnectionsConnection to DWGIS3.sde" ARG_CONDUIT = sde_connection + "ARG.CONDUIT"
  • 20.
  • 21. PyWin: PyWin Python for Windows extensions by Mark Hammond http://sourceforge.net/projects/pywin32/ pywin32-218.win32-py2.7.exe
  • 22. Process Steps: Delete Features from simple_conduits Append from SDE into simple_conduits, just COND_NUM and WATER_TYPE Delete NO_Zero_Conduits Select from simple_conduits into N0_Zero_Conduits Delete dissolved_conduits Dissolve N0_Zero_Conduits into dissolved_conduits
  • 23. Fix up Process Steps: • # Process: Append • arcpy.Append_management(ARG_CONDUIT, simple_conduits, "NO_TEST", "COND_NUM "COND_NUM" true true false 2 Short 0 0 ,First,#,Database ConnectionsConnection to DWGIS3.sdeARG.DistributionSystemARG.CONDUIT,COND_NUM,-1,- 1;WATER_TYPE "WATER_TYPE" true true false 5 Text 0 0 ,First,#,Database ConnectionsConnection to DWGIS3.sdeARG.DistributionSystemARG.CONDUIT,WATER_TYPE,-1,- 1;Shape_Length "Shape_Length" false true true 8 Double 0 0 ,First,#", "") Becomes… • # Process: Append • arcpy.Append_management( • "'Database ConnectionsConnection to DWGIS3.sde • ARG.DistributionSystemARG.CONDUIT'", simple_conduits, • "NO_TEST", "COND_NUM "COND_NUM" true true false 2 Short 0 0 ,First,#,Database C
  • 24. Fix up Process Steps: • # Process: Delete • arcpy.Delete_management(N0_Zero_Conduits, "FeatureClass") Becomes… • # Process: Delete • arcpy.Delete_management( • "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdb • NO_Zero_Conduits", • "FeatureClass")
  • 25. Fix up Process Steps: • # Process: Delete • arcpy.Delete_management(dissolved_conduits, "FeatureClass") Becomes… • # Process: Delete • arcpy.Delete_management( • "R:ARG_ProjectsConduit MapBookDissolvedConduits.gdb • dissolved_conduits", • "FeatureClass")
  • 26. All Scrubbed Up: # Process: arcpy.DeleteFeatures_management(simple_conduits) arcpy.Delete_management(N0_Zero_Conduits, "FeatureClass") arcpy.Delete_management(dissolved_conduits, "FeatureClass") arcpy.Append_management(ARG_CONDUIT, simple_conduits, "NO_TEST", "COND_NUM "COND_NUM" true true false 2 Short 0 0 ,First,#,Database ConnectionsConnection to DWGIS3.sdeARG.DistributionSystemARG.CONDUIT,COND_NUM,-1,-1;WATER_TYPE "WATER_TYPE" true true false 5 Text 0 0 ,First,#,Database ConnectionsConnection to DWGIS3.sdeARG.DistributionSystemARG.CONDUIT,WATER_TYPE,-1,-1;Shape_Length "Shape_Length" false true true 8 Double 0 0 ,First,#", "") arcpy.Select_analysis(simple_conduits, N0_Zero_Conduits, ""COND_NUM" <> 0") arcpy.Dissolve_management(N0_Zero_Conduits, dissolved_conduits, "COND_NUM;WATER_TYPE", "", "SINGLE_PART", "DISSOLVE_LINES")
  • 27. Geek Speak - If: if arcpy.Exists(something): # do something with it if not arcpy.Exists(something): # it does not exist
  • 28. Avoid Errors: if arcpy.Exists(dissolved_conduits): arcpy.Delete_management(dissolved_conduits, "FeatureClass") Becomes… arcpy.Delete_management(dissolved_conduits, "FeatureClass")
  • 29. Delete Processes: if arcpy.Exists(N0_Zero_Conduits): arcpy.Delete_management(N0_Zero_Conduits, "FeatureClass") if arcpy.Exists(dissolved_conduits): arcpy.Delete_management(dissolved_conduits, "FeatureClass") if arcpy.Exists(simple_conduits): arcpy.DeleteFeatures_management(simple_conduits) else: print "Missing feature class -> " + simple_conduits
  • 30. Alternative: >>> from arcpy import env >>> env.overwriteOutput = True >>> env.workspace = “C:/EsriPress/Python/Data/”
  • 31. Either way, explain: >>> # There feature classes probably already exist. >>> # They are left over from the last time we ran this script. >>> # Deleting the old versions makes room for the new ones.
  • 32. Geek Speak – Try / Catch: >>> try: >>> # .. To do something that might blow up >>> # and it “throws” an Exception >>> except Exception ex: >>> print ex >>>
  • 33. Catch Exception: >>> try: >>> arcpy.Append_management(CONDUIT >> except Exception as ex: >>> print ex
  • 34. Test Exception: >>> try: >>> bogus = 1.0 / 0.0 # forces exception >>> arcpy.Append_management(ARG_CONDUIT, >>> except Exception as ex: >>> print ex
  • 35. Logging: import logging logfile = "C:/temp/demo.log" logging.basicConfig( level=logging.INFO, filename=logfile) logger = logging.getLogger() logger.info("A swallow beats its wings 43 times every second.") logger.warning("Go away or I shall taunt you a second time.") logger.error("Run away! Run away!") print "Done."
  • 36. C:tempdemo.log: INFO:A swallow beats its wings 43 times every second. WARNING:Go away or I shall taunt you a second time. ERROR:Run away! Run away!
  • 37. Logging: logging.info(" checking for " + HYDRANT_BRANCH ) if arcpy.Exists(HYDRANT_BRANCH ): try: arcpy.Append_management(APPEND_HYD_BR, hyd_branch, ...) logging.info(" HYDRANT_BRANCH_shp appended to SDE") except Exception as ex: logging.error(" HYDRANT_BRANCH_shp append FAILED") logging.Exeception(ex)
  • 38. Recap – Do These 3 Things… 1. Organize variable names 2. Trap Errors 3. Write a log file "First shalt thou take out the Holy Pin. Then shalt thou count to three, no more, no less. Three shall be the number thou shalt count, and the number of the counting shall be three.”
  • 39. Pythonic: • Explicit is better than implicit. • Simple is better than complex. • Readability counts. The Zen of Python, by Tim Peters, includes:
  • 40. Geek Speak - Blocks: >>> if arcpy.Exists(simple_conduits): >>> arcpy.DeleteFeatures_management(simple_conduits) >>> # maybe do something else >>> # some additional processing >>> else: >>> print "Missing feature class -> " + simple_conduits
  • 41. Duck Typing: If it looks like a duck, quacks like a duck, etc. Works with strings, integers, floating point, lists, etc.
  • 42. Strings: Enclosed in either ‘single’ or “double” quotes. Concatenate using + sign. >>> topic = "GIS" >>> location = "Rockies“ >>> event = topic + " in the " + location >>> print event GIS in the Rockies
  • 43. Strings: More built-in functions: >>> event = "GIS in the Rockies" >>> print event.lower() >>> print event.upper() >>> print event.title() >>> string_length = len(event) >>> print string_length >>> print event.find("Rockies",0,string_length) gis in the rockies GIS IN THE ROCKIES Gis In The Rockies 18 11
  • 44. Triple quotes can span multiple lines: “””The Dead Collector: Bring out yer dead. Large Man: Here's one. The Dead Collector: That'll be ninepence. The Dead Body: I'm not dead. The Dead Collector: 'Ere, he says he's not dead. Large Man: Yes he is. The Dead Body: I'm not. The Dead Collector: He isn't. Large Man: Well, he will be soon, he's very ill. The Dead Body: I'm getting better. “””
  • 45. Lists: >>> python_sketch = ['Dead Parrot', 'Confuse-a-Cat', 'Silly Walks', 'Four Yorkshiremen','Fish Slap']; >>> # notice duck typing >>> print python_sketch [0] >>> print python_sketch [1] >>> python_sketch.append('Limberjack Song') >>> print len(python_sketch) Dead Parrot Confuse-a-Cat 6
  • 46. For loop: >>> for funny_bit sketch in python_sketch: >>> print funny_bit + ' hahaha‘ Dead Parrot hahaha Confuse-a-Cat hahaha Silly Walks hahaha Four Yorkshiremen hahaha Fish Slap hahaha Limberjack Song hahaha
  • 47. Command Line Args: >>> userid = arcpy.GetParameterAsText(0) >>> if not userid: >>> print ‘Usage: python.exe my_script.py userid password ‘ >>> pword = arcpy.GetParameterAsText(1) >>> if not pword: >>> print ‘Usage: python.exe my_script.py userid password ‘
  • 48. Command Line Args: C:> D:python27python.exe my_script.py zeke password Python.exe is located on D:python27 my_script.py is some python code Userid is zeke My Oracle password is at the end
  • 49. Command Line Args: >>> userid = arcpy.GetParameterAsText(0) >>> pword = arcpy.GetParameterAsText(1)
  • 50. Oracle connection: connection_string = userid + '/' + pword + '@dwsde' # looks like this -> zeke/password@dwsde import cx_Oracle connection = cx_Oracle.connect(connection_string) cursor = connection.cursor() cursor.execute('select distinct water_type from conduit') for result in cursor: print result
  • 51. Oracle connection: cursor.execute('select distinct diameter from conduit') allresults = cursor.fetchall() for result in allresults: print result cursor.close() connection.close() print "Done."
  • 52. Nee
  • 53. Here is a shrubbery.
  • 54. Not Habit Forming: But is considered a “Gateway” language, which frequently leads to more nerdy behavior.
  • 57. GIS Day November 22: See denverwater.org for directions...