Professional Documents
Culture Documents
Lec01 Intro GIS Database Programming
Lec01 Intro GIS Database Programming
Interactive window
Test lines of code
Report messages
Basics of Python
Comment: A non-executable line of code
Variables in Python
Variables are dynamically typed
No declaration required
No type assignment required
fc = C:\\ProjectData\\SanDiego.mdb\\Freeways.shp
Numbers
Variables can hold numbers and expressions
num1 = 1.2
num2 = 3 + 5
Strings
Variables can hold strings
folder = c:/Student
Strings are surrounded in double () or
single () quotes
Pathnames use two back (\\) or one
forward (/) slash
One backslash (\) is a reserved escape
character and a line continuation character
Strings
Strings can be combined together
gdbPath = c:\\SanDiego.mdb
fc = Roads
fullPath = gdbPath + \\ + fc
C:\SanDiego.mdb\Roads
Lists
Variables can hold lists
numList = [1, 2, 3]
fcList = [Roads, Streets, Parcels, Zipcodes]
---> Streets
---> Roads, Streets
---> Roads, Streets, Parcels
---> Parcels, Zipcodes
Line continuation
Line continuation characters
Parentheses ( ), brackets [ ], and braces { }
Backslash \
Indentation is automatic
fcList = [Roads, Climate, Streams,
Zipcodes, Coastlines]
distanceValues = 100, 200, 300, 400, 500, \
1000, 1500
gp.Buffer_analysis(fcList[2], BuffStreams1000,
distanceValues[5])