python programming

gorgeousvassalSoftware and s/w Development

Nov 7, 2013 (3 years and 8 months ago)

72 views

Python Programming

How can I use Python to help me
with GIS?

What?


Give you an idea of what is possible with
Python


Provide you with a resource to perform the
processes I describe


Point you in the right direction for further
research

Python


A dynamic programming language


Scripting


Indentation (Code blocks)


High level data types


Interpreted language (no need to compile)


Fast for programmer


Debugging (error checking)


Free

Cooking


From scratch


Making bread


Using one product for another


Using bread to make stuffing


Buying premade


Getting already made programs to do what you
want

Writing Simple Program

1 Line in Java, takes 5 lines. Sweet!!!!

Using Python for ArcGIS


ArcGIS Desktop Help

Or!!!


www.esri.com

(scripts)


www.arcgisdevelopersonline.esri.com


www.python.org


Python
-
> help
-
> python Manuals

Python Manual


Conventions:


“#” Ignores everything
that comes after


“” directory or name


“C:/GIS/shapefiles.shp”


“The output is” x


If variable no “ ”
necessary


Capitalization matters

Import Modules

Where does this
come from?

GIS function script syntax


Go to Toolbox in ArcGIS


Click on relevant tool


Click Help


Help again


Batching Code


You use y=x.next() to set y

to be equal to the next element in list x.
x.reset() sets list x back to

the start.


While Y:


Output= Output + fc #(
concatenation)


# perform erase


GP.erase(Input, EraseFeature, Output, “”)


Y.next

Batch Processing


Different Commands for Different data types

ModelBuilder

Right Click toolbox


New Toolbox



New Model




Drag Shapefiles and Tools

File
-
> Export
-
>Script
-
> Python

Easier Ways

Export Script


Add Batching





Import Batch Script
back to ArcGIS


Right Click “your”
toolbox


Click Add


Script

Select Script and

Voila!!!


If any questions



E
-
mail: Mike.knetzger@gmail.com