SlideShare a Scribd company logo
Python &  Drive Time Analyses Python 2.6 ArcCatalog 9.3.1 ArcMap 9.3.1 Project technologies Programming language: Software products: Janice Poehlman Division of Forestry, Dept. Natural Resources [email_address]
Use python scripts to summarize the total number of people who are within drive times of a location. 30 Minute 60 Minute 90 Minute 120 Minute Drive Time Service Area Network Analyst }
Data WI, MN, MI, IL, IA Census 2000  Block Groups TIGER 2000 Road PLSS Township
 
 
 
 
 
 
 
 
 
 
 
#--------------------------------------------------------------------- #Author: JP  # #Last Update: December, 2010 # #Purpose:  #Use cursors to select individual records (rows) in  feature class.  The #individual record is saved to an individual feature class and used to #clip census block groups.  A town-range field is added and calculated #for each census block group feature class.  The block group individual #files are merged into a single feature class, which can be summarized #by DTR for total population for each drive time service area. #-----------------------------------------------------------------------
What is a cursor and how does it work.
What is a cursor and how does it work.
What is a cursor and how does it work.
What is a cursor and how does it work.
What is a cursor and how does it work.
The cursor selects an individual record  in a feature class and uses the python    tool to create a new feature class with one feature. (data export selected set):   gp.SearchCursor
What the python script does inside the cursor with one record: 2. Creates a new feature class from the record gp.Select_Analysis   3. Clips block groups by the new feature class gp.Clip_Analysis 4. Calculates a total population for the service area gp.Calculate_Field  40417
#import modules import arcgisscripting, sys, os, time #create the geoproccessor object and set file overwrite gp = arcgisscripting.create() gp.overwriteoutput = 1 #set workspace variables and add toolboxes gp.workspace = "D:\drivetime\RoadsTigerResultsDT120Min_processing4.gdb” gp.addtoolbox("C:/Program Files/ArcGIS/ArcToolBox/Toolboxes/Data Management Tools.tbx") gp.addtoolbox("C:/Program Files/ArcGIS/ArcToolBox/Toolboxes/Analysis Tools.tbx") servicearea = "DriveTime120Minutes_SEW_NN” log = open('D:/drivetime/logprocessing.log', 'a’) log.write('\n\nFile is ' + servicearea) timestamp = time.strftime('%I:%M:%S %p', time.localtime()) log.write('\nStarting time is ' + timestamp)
What the python script does inside the cursor with one record: 2. Creates a new feature class from the record gp.Select_Analysis   3. Clips block groups by the new feature class gp.Clip_Analysis 4. Calculates a total population for the service area gp.Calculate_Field  40417
try: rows = gp.SearchCursor(servicearea) row = rows.Next() while row <> None: ShapeName = str(row.DTR) gp.Select_analysis(servicearea, &quot;xxsel&quot; +ShapeName, '&quot;DTR&quot;=' +ShapeName) gp.clip_analysis(&quot;pop2000&quot;, &quot;xxsel&quot;+ShapeName, &quot;xxclipSEWNN&quot;+ShapeName, &quot;&quot;)  gp.calculatefield_management(&quot;xxclipSEWNN&quot;+ShapeName, &quot;DTR&quot;, row.DTR) gp.delete_management (&quot;xxsel&quot; +ShapeName)  row = rows.next() del row, rows except: if not gp.getmessages() == &quot;”: gp.addmessage(gp.getmessages(2)) if 'row' in dir(): del row if 'rows' in dir(): del rows
After the cursor is used for geoprocessing every record, the individual feature classes containing block groups for each service area are merged together using a value table.  gp.merge_management  vTab = gp.createobject(&quot;ValueTable”) fcList = gp.listfeatureclasses(&quot;xxclipSEWNN*”) fc = fcList.Next() while fc: fcpath = gp.workspace + &quot;\\&quot; + fc vTab.Addrow(fcpath) fc = fcList.Next() gp.merge_management(vTab, &quot;AMergedDriveTime120MinutesSEWNN&quot;, &quot;”) print &quot;Completed merged file for features of %s&quot; %(servicearea) timestamp = time.strftime('%I:%M:%S %p', time.localtime()) log.write('\nFinishing time is ' + timestamp) print&quot;Done.” del vTab del fc del fcpath del servicearea del timestamp log.close()
 
 
A  supply and demand  analysis of location to people.  Using hunting or fishing licensing information to determine if quality or quantity of lands support types of recreation. Using the density of people to determine where to build facilities or infrastructure. Voila !
Thank you for your attention.

More Related Content

What's hot (19)

PPTX
GeoTuple a Framework for Web Based Geo-Analytics with R and PostGIS
Roland Hansson
 
PPT
150970116028 2140705
Manoj Shahu
 
PDF
Apache flink: data streaming as a basis for all analytics by Kostas Tzoumas a...
Big Data Spain
 
PDF
PG Day'14 Russia, GIN — Stronger than ever in 9.4 and further, Александр Коро...
pgdayrussia
 
DOCX
R Data Visualization-Spatial data and Maps in R: Using R as a GIS
Dr. Volkan OBAN
 
PPTX
From Trill to Quill: Pushing the Envelope of Functionality and Scale
Badrish Chandramouli
 
PDF
確率的プログラミングライブラリEdward
Yuta Kashino
 
PDF
Ragel talk
elliando dias
 
PDF
Using PyPy instead of Python for speed
Enplore AB
 
PDF
Network Analysis with networkX : Real-World Example-2
Kyunghoon Kim
 
PPTX
Building a real time Tweet map with Flink in six weeks
Matthias Kricke
 
PPTX
Megadata With Python and Hadoop
ryancox
 
PPT
Hight Work
Nutron
 
PDF
Map Analytics in Starcraft II
gy8
 
PDF
Resource management
Ahmed Gamal
 
PPTX
Python en la Plataforma ArcGIS
Xander Bakker
 
PPT
Schema Design by Chad Tindel, Solution Architect, 10gen
MongoDB
 
PDF
Building maps for apps in the cloud - a Softlayer Use Case
Timan Rebel
 
GeoTuple a Framework for Web Based Geo-Analytics with R and PostGIS
Roland Hansson
 
150970116028 2140705
Manoj Shahu
 
Apache flink: data streaming as a basis for all analytics by Kostas Tzoumas a...
Big Data Spain
 
PG Day'14 Russia, GIN — Stronger than ever in 9.4 and further, Александр Коро...
pgdayrussia
 
R Data Visualization-Spatial data and Maps in R: Using R as a GIS
Dr. Volkan OBAN
 
From Trill to Quill: Pushing the Envelope of Functionality and Scale
Badrish Chandramouli
 
確率的プログラミングライブラリEdward
Yuta Kashino
 
Ragel talk
elliando dias
 
Using PyPy instead of Python for speed
Enplore AB
 
Network Analysis with networkX : Real-World Example-2
Kyunghoon Kim
 
Building a real time Tweet map with Flink in six weeks
Matthias Kricke
 
Megadata With Python and Hadoop
ryancox
 
Hight Work
Nutron
 
Map Analytics in Starcraft II
gy8
 
Resource management
Ahmed Gamal
 
Python en la Plataforma ArcGIS
Xander Bakker
 
Schema Design by Chad Tindel, Solution Architect, 10gen
MongoDB
 
Building maps for apps in the cloud - a Softlayer Use Case
Timan Rebel
 

Similar to Python Coding Examples for Drive Time Analysis (16)

PPTX
Working with space time data in ArcGIS
Aileen Buckley
 
PPTX
Geoprocessing(Building Your Own Tool) and Geostatistical Analysis(An Introdu...
Nepal Flying Labs
 
RTF
py_AutoMapMaker
Clint Pearce
 
PPT
Arcgis 10中的python
fengdjhy
 
PDF
Python gis
John Zhou
 
PDF
spatial analysis introduction and vector type of data.pdf
Shahvidhi11
 
PPTX
Python and GIS: Improving Your Workflow
John Reiser
 
PDF
3_Geoprocessing tasks (1) bbjb bbhbhb b,bjj,jj
merongetahun3
 
PPT
Geographic Information System unit 4
sridevi5983
 
PPT
INAC Online Hazards Database App
Gerry James
 
PPTX
Python at 10.1
Simon Jackson
 
PDF
Python Programming for ArcGIS: Part II
DUSPviz
 
PPTX
Shrug2017 arcpy data_and_you
SHRUG GIS
 
ODT
Duncan_doc
Lance Duncan
 
PPT
Arcgis training day_2
yashasweesharma
 
PDF
2008-03-04 - Geoprocessing with ArcGIS.pdf
ssuseref75f1
 
Working with space time data in ArcGIS
Aileen Buckley
 
Geoprocessing(Building Your Own Tool) and Geostatistical Analysis(An Introdu...
Nepal Flying Labs
 
py_AutoMapMaker
Clint Pearce
 
Arcgis 10中的python
fengdjhy
 
Python gis
John Zhou
 
spatial analysis introduction and vector type of data.pdf
Shahvidhi11
 
Python and GIS: Improving Your Workflow
John Reiser
 
3_Geoprocessing tasks (1) bbjb bbhbhb b,bjj,jj
merongetahun3
 
Geographic Information System unit 4
sridevi5983
 
INAC Online Hazards Database App
Gerry James
 
Python at 10.1
Simon Jackson
 
Python Programming for ArcGIS: Part II
DUSPviz
 
Shrug2017 arcpy data_and_you
SHRUG GIS
 
Duncan_doc
Lance Duncan
 
Arcgis training day_2
yashasweesharma
 
2008-03-04 - Geoprocessing with ArcGIS.pdf
ssuseref75f1
 
Ad

More from Wisconsin Land Information Association (20)

PPTX
A wikimap of landscape values in the bad river watershed carl sack
Wisconsin Land Information Association
 
PPTX
Workshop using open source software for mobile data collection workshop - a...
Wisconsin Land Information Association
 
PPTX
Wigicc's role in wisconsin jon schwitchtenberg
Wisconsin Land Information Association
 
PPTX
Wi 590 nutrient management web application lisa morrison
Wisconsin Land Information Association
 
PPTX
Surveying and land records management dean roth
Wisconsin Land Information Association
 
PPTX
Mapping spatial patterns of whai finder usage to measure community outreach e...
Wisconsin Land Information Association
 
PPTX
Local gis in the statewide voter registration system sarah whitt
Wisconsin Land Information Association
 
PPTX
Li dar quality control a client's perspective - tyler grosshuesch
Wisconsin Land Information Association
 
PPTX
Li dar meets wisconsinview jc nelson
Wisconsin Land Information Association
 
PPTX
Lakesheds and riverscapes extending wisconsin's hydro database with landsca...
Wisconsin Land Information Association
 
PPTX
Lake habitat mapping with side scan sonar in nine wisconsin lakes - christine...
Wisconsin Land Information Association
 
PPTX
Integrative mapping strategies jeremy bixby
Wisconsin Land Information Association
 
PPTX
Integrating sanitary televising data with utility gis data within the city of...
Wisconsin Land Information Association
 
PPTX
Integrating high accuracy gps with esri's arc gis for windows mobile field so...
Wisconsin Land Information Association
 
PPTX
Implementing arc gis 10.1 for the wisconsin dnr nhi portal levi felling
Wisconsin Land Information Association
 
PPTX
Gis in parks and recreation the proragis website - trish nau
Wisconsin Land Information Association
 
PPTX
Geo moose project update brian fischer
Wisconsin Land Information Association
 
PPTX
Elevation hydrology tools kent pena
Wisconsin Land Information Association
 
PPTX
Developing mobile apps pick your poison - levi felling
Wisconsin Land Information Association
 
A wikimap of landscape values in the bad river watershed carl sack
Wisconsin Land Information Association
 
Workshop using open source software for mobile data collection workshop - a...
Wisconsin Land Information Association
 
Wigicc's role in wisconsin jon schwitchtenberg
Wisconsin Land Information Association
 
Wi 590 nutrient management web application lisa morrison
Wisconsin Land Information Association
 
Surveying and land records management dean roth
Wisconsin Land Information Association
 
Mapping spatial patterns of whai finder usage to measure community outreach e...
Wisconsin Land Information Association
 
Local gis in the statewide voter registration system sarah whitt
Wisconsin Land Information Association
 
Li dar quality control a client's perspective - tyler grosshuesch
Wisconsin Land Information Association
 
Li dar meets wisconsinview jc nelson
Wisconsin Land Information Association
 
Lakesheds and riverscapes extending wisconsin's hydro database with landsca...
Wisconsin Land Information Association
 
Lake habitat mapping with side scan sonar in nine wisconsin lakes - christine...
Wisconsin Land Information Association
 
Integrative mapping strategies jeremy bixby
Wisconsin Land Information Association
 
Integrating sanitary televising data with utility gis data within the city of...
Wisconsin Land Information Association
 
Integrating high accuracy gps with esri's arc gis for windows mobile field so...
Wisconsin Land Information Association
 
Implementing arc gis 10.1 for the wisconsin dnr nhi portal levi felling
Wisconsin Land Information Association
 
Gis in parks and recreation the proragis website - trish nau
Wisconsin Land Information Association
 
Geo moose project update brian fischer
Wisconsin Land Information Association
 
Elevation hydrology tools kent pena
Wisconsin Land Information Association
 
Developing mobile apps pick your poison - levi felling
Wisconsin Land Information Association
 
Ad

Recently uploaded (20)

PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
Biography of Daniel Podor.pdf
Daniel Podor
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
July Patch Tuesday
Ivanti
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
Biography of Daniel Podor.pdf
Daniel Podor
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
July Patch Tuesday
Ivanti
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 

Python Coding Examples for Drive Time Analysis

  • 1. Python & Drive Time Analyses Python 2.6 ArcCatalog 9.3.1 ArcMap 9.3.1 Project technologies Programming language: Software products: Janice Poehlman Division of Forestry, Dept. Natural Resources [email_address]
  • 2. Use python scripts to summarize the total number of people who are within drive times of a location. 30 Minute 60 Minute 90 Minute 120 Minute Drive Time Service Area Network Analyst }
  • 3. Data WI, MN, MI, IL, IA Census 2000 Block Groups TIGER 2000 Road PLSS Township
  • 4.  
  • 5.  
  • 6.  
  • 7.  
  • 8.  
  • 9.  
  • 10.  
  • 11.  
  • 12.  
  • 13.  
  • 14.  
  • 15. #--------------------------------------------------------------------- #Author: JP # #Last Update: December, 2010 # #Purpose: #Use cursors to select individual records (rows) in feature class. The #individual record is saved to an individual feature class and used to #clip census block groups. A town-range field is added and calculated #for each census block group feature class. The block group individual #files are merged into a single feature class, which can be summarized #by DTR for total population for each drive time service area. #-----------------------------------------------------------------------
  • 16. What is a cursor and how does it work.
  • 17. What is a cursor and how does it work.
  • 18. What is a cursor and how does it work.
  • 19. What is a cursor and how does it work.
  • 20. What is a cursor and how does it work.
  • 21. The cursor selects an individual record in a feature class and uses the python tool to create a new feature class with one feature. (data export selected set): gp.SearchCursor
  • 22. What the python script does inside the cursor with one record: 2. Creates a new feature class from the record gp.Select_Analysis 3. Clips block groups by the new feature class gp.Clip_Analysis 4. Calculates a total population for the service area gp.Calculate_Field 40417
  • 23. #import modules import arcgisscripting, sys, os, time #create the geoproccessor object and set file overwrite gp = arcgisscripting.create() gp.overwriteoutput = 1 #set workspace variables and add toolboxes gp.workspace = &quot;D:\drivetime\RoadsTigerResultsDT120Min_processing4.gdb” gp.addtoolbox(&quot;C:/Program Files/ArcGIS/ArcToolBox/Toolboxes/Data Management Tools.tbx&quot;) gp.addtoolbox(&quot;C:/Program Files/ArcGIS/ArcToolBox/Toolboxes/Analysis Tools.tbx&quot;) servicearea = &quot;DriveTime120Minutes_SEW_NN” log = open('D:/drivetime/logprocessing.log', 'a’) log.write('\n\nFile is ' + servicearea) timestamp = time.strftime('%I:%M:%S %p', time.localtime()) log.write('\nStarting time is ' + timestamp)
  • 24. What the python script does inside the cursor with one record: 2. Creates a new feature class from the record gp.Select_Analysis 3. Clips block groups by the new feature class gp.Clip_Analysis 4. Calculates a total population for the service area gp.Calculate_Field 40417
  • 25. try: rows = gp.SearchCursor(servicearea) row = rows.Next() while row <> None: ShapeName = str(row.DTR) gp.Select_analysis(servicearea, &quot;xxsel&quot; +ShapeName, '&quot;DTR&quot;=' +ShapeName) gp.clip_analysis(&quot;pop2000&quot;, &quot;xxsel&quot;+ShapeName, &quot;xxclipSEWNN&quot;+ShapeName, &quot;&quot;) gp.calculatefield_management(&quot;xxclipSEWNN&quot;+ShapeName, &quot;DTR&quot;, row.DTR) gp.delete_management (&quot;xxsel&quot; +ShapeName) row = rows.next() del row, rows except: if not gp.getmessages() == &quot;”: gp.addmessage(gp.getmessages(2)) if 'row' in dir(): del row if 'rows' in dir(): del rows
  • 26. After the cursor is used for geoprocessing every record, the individual feature classes containing block groups for each service area are merged together using a value table. gp.merge_management vTab = gp.createobject(&quot;ValueTable”) fcList = gp.listfeatureclasses(&quot;xxclipSEWNN*”) fc = fcList.Next() while fc: fcpath = gp.workspace + &quot;\\&quot; + fc vTab.Addrow(fcpath) fc = fcList.Next() gp.merge_management(vTab, &quot;AMergedDriveTime120MinutesSEWNN&quot;, &quot;”) print &quot;Completed merged file for features of %s&quot; %(servicearea) timestamp = time.strftime('%I:%M:%S %p', time.localtime()) log.write('\nFinishing time is ' + timestamp) print&quot;Done.” del vTab del fc del fcpath del servicearea del timestamp log.close()
  • 27.  
  • 28.  
  • 29. A supply and demand analysis of location to people. Using hunting or fishing licensing information to determine if quality or quantity of lands support types of recreation. Using the density of people to determine where to build facilities or infrastructure. Voila !
  • 30. Thank you for your attention.