UGIC 2009 Introduction to Open Source RS/GIS programming with Python Chris Garrard RS/GIS Laboratory Utah State University.

Slides:



Advertisements
Similar presentations
1 ShareGeo Discovering and Sharing Geospatial Data
Advertisements

Intro to Python Welcome to the Wonderful world of GIS programing!
Geoprocessing with GDAL and Numpy in Python Delong Zhao
Geographic Information Systems GIS Software. 1. The Early GISs SURFACE II, by Kansa Geological Survey SYMAP, by Harvard Laboratory for Computer Graphics.
Why python? Automate processes Batch programming Faster Open source Easy recognition of errors Good for data management What is python? Scripting programming.
ESRI Software ArcGIS –ArcMap –ArcEdit –ArcInfo –ArcView.
Introduction to Python. Python is a high-level programming language Open source and community driven “Batteries Included” – a standard distribution includes.
Introduction to GIS and ArcGIS How a GIS works Introduction to ArcGIS The ArcGIS Interface.
Introduction to Cartography GEOG 2016 E
ArcGIS Geodatabase Miles Logsdon Spatial Information Technologies, UW Garry Trudeau - Doonesbury.
ANALYSIS 3 - RASTER What kinds of analysis can we do with GIS? 1.Measurements 2.Layer statistics 3.Queries 4.Buffering (vector); Proximity (raster) 5.Filtering.
Introduction to ArcGIS Reading: “What is ArcGIS?”, ESRI Press, 2001, pp Acknowledgement: Dr Francisco Olivera developed some of the slides in this.
NR 422: GIS Review Jim Graham Fall What is GIS? Geographic Information System? Geographic Information Science? A system that provides the ability.
Python & ModelBuilder. Overview Python/ModelBuilder Concepts – The Geoprocessor – Checking some environment variables – Providing feedback from your model/script.
So What is GIS??? “A collection of computer hardware, software and procedures that are used to organize, manage, analyze and display.
Introduction to ArcView ArcView_module_2 May 12, 10:40 AM.
What Geoprocessing? Geoprocessing is the processing of geographic information. Commonly used to describe a process when geographic objects are manipulated.
ESRM 250/CFR 520 Winter 2010 Phil Hurvitz (with thanks to J. Lawler & P. Schiess) Introduction to GIS and ArcGIS 1 of 48.
Dr. David Liu Objectives  Understand what a GIS is  Understand how a GIS functions  Spatial data representation  GIS application.
School of Geography FACULTY OF ENVIRONMENT Introduction to ArcGIS 1.
ESRM 250 & CFR 520: Introduction to GIS © Phil Hurvitz, KEEP THIS TEXT BOX this slide includes some ESRI fonts. when you save this presentation,
ESRM 250 & CFR 520: Introduction to GIS © Phil Hurvitz, KEEP THIS TEXT BOX this slide includes some ESRI fonts. when you save this presentation,
Introduction to ArcGIS for Environmental Scientists Module 3 – GIS Analysis ArcGIS Toolbox.
CE 525 1/17/2013. Quiz #3 Question 1 You look in the phone book and see names associated with phone numbers. Is this geographic data?
Intro. To GIS Lecture 4 Data: data storage, creation & editing
Python & ModelBuilder. Continuing Education Python and ModelBuilder Overview Python/ModelBuilder Concepts –The Geoprocessor –Checking some environment.
NR 422: Topology Jim Graham Fall 2010 See: odatabase-topology.pdf.
Spatial Analyst Toolbox Lecture 17. Spatial Analyst Tool Sets  Conditional  Density  Distance  Generalization  Ground Water  Interpolation  Conditional.
Spatial (coordinate) data model Relational (tabular) data model
ESRM 250 & CFR 520: Introduction to GIS © Phil Hurvitz, KEEP THIS TEXT BOX this slide includes some ESRI fonts. when you save this presentation,
2006 GIS Jam: ArcGIS Python Scripting
Extending Python Doing more than just interfacing with the geoprocessor Free example utility for NZ Projections Kim Ollivier.
Introduction to Spatial Analysis and Spatial Modeling
Introduction to Python John Reiser May 5 th, 2010.
Introduction to ArcPy. Topics What is ArcPy? Accessing geoprocessing tools using ArcPy Writing scripts using ArcPy.
Python: An Introduction
A Basic Introduction to Free and Open Source Software Presented by John Bocan.
Introduction to ArcView NPS Introduction to GIS: Lecture 2 Based on NINC, ESRI and Other Sources.
The world of RASTER data Modeling... Elevation....etc. The Spatial Analyst Extension.
Data Interoperability Basics Bruce Harold & Dale Lutz.
Vaduz.library.oregonstate.edu:9090/ metadataexplorer_find/explorer.jsp If interested in job contact NEXT week.
GDAL/OGR. GDAL/OGR GDAL/OGR : Frank Warmerdam Tools for reading, writing, and processing GDAL - Geospatial Data Abstraction Library GDAL - Geospatial.
A.Batchimeg GDAL Geospatial Data Abstraction Library GDAL Geospatial Data Abstraction Library
Raster Concepts.
CS 4720 Dynamic Web Applications CS 4720 – Web & Mobile Systems.
Arch: 383 Introduction to GIS Week 2 Introduction to GEOGRAPHIC INFORMATION SYSTEMS Can Kara Faculty of Architecture 2011 ARC 383.
Web Development Web development never ends: 1.Find out what the stakeholders need (sponsors, users, etc.) 2.Investigate available technology 3.Plan the.
CFR 250/590 Introduction to GIS, Autumn 1999 View Basics © Phil Hurvitz, intro.ppt 1 Overview Getting data into ArcView Displaying themes Theme.
Intro to GIS | Summer 2012 Attribute Tables – Part 1.
GIS & Health ESPM 9: W 5-8 April 7, 2010 Instructors: Maggi Kelly Kevin Koy Mark O’Connor Geospatial Innovation Facility College of Natural Resources -
Finding Geospatial Data A closer look at several useful sources of free geospatial data René Duplain Data Analyst,
1 Overview Importing data from generic raster files Creating surfaces from point samples Mapping contours Calculating summary attributes for polygon features.
Geographic Data in GIS. Components of geographic data Three general components to geographic information Three general components to geographic information.
DEM TRAINING (DIGITAL ELEVATION MODEL). STEP 1 OPEN GIS.
Introduction to Geodatabases
Lecture 18: Spatial Analysis Using Rasters Jeffery S. Horsburgh CEE 5190/6190 Geographic Information Systems for Civil Engineers Spring 2016.
Geospatial Data Abstraction Library(GDAL) Sabya Sachi.
Graduate Students, CEE-6190
Web Development Web development never ends:
Desktop ArcGIS GIS File Types
Spatial Models – Raster Stacy Bogan
PYTHON: AN INTRODUCTION
Introduction to Quantum GIS
Data Analysis using Python-I
Geographic Information Systems
Using QGIS, GRASS and PostGIS to answer some difficult questions
Introduction to ArcGIS
To Be Safe For Now: Keep your shapefiles simple
Clip & Convert to ASCII Program Kelly Knapp Spring 2010
Presentation transcript:

UGIC 2009 Introduction to Open Source RS/GIS programming with Python Chris Garrard RS/GIS Laboratory Utah State University

UGIC 2009 Why bother with FOSS? Free and Open Source Software (FOSS) Affordable (free, as in free beer) Fits the budget of small companies or individuals Open (as in free speech) Use it for whatever you want Distribute it if you want Modify it if you want

UGIC 2009 Why bother with FOSS? Helpful user community Including the developers themselves Fast bug fixes Not limited to Windows Lightweight

UGIC 2009 Cons Lightweight Not the ESRI geoprocessor Smaller user community than some other packages

UGIC 2009 Free != inferior Apache, MySQL, Linux, Firefox, etc. ESRI likes Python GDAL is used by popular commercial packages ArcGIS, Erdas Imagine, ER Mapper

UGIC 2009 Python Free, even for resale Powerful and has extensive libraries Easy to integrate with other tools Runs on many different operating systems Easy to learn

UGIC 2009 GDAL and OGR libraries Free, even for resale Available for many different operating systems Written in ANSI C and C++ Bindings exist for Python, C#, Perl, Java, Ruby, R, VB6

UGIC 2009 OGR OGR Simple Features Library Vector data access Software-specific formats shapefiles, personal geodatabases, ArcSDE, MapInfo, GRASS, Microstation Open formats TIGER/Line, SDTS, GML, KML Databases MySQL, PostgreSQL, Oracle Spatial, Informix, ODBC

UGIC 2009 GDAL Geospatial Data Abstraction Library Raster data access Supports about 100 different formats ArcInfo grids, ArcSDE raster, Imagine, Idrisi, ENVI, GRASS, GeoTIFF HDF4, HDF5 USGS DOQ, USGS DEM ECW, MrSID TIFF, JPEG, JPEG2000, PNG, GIF, BMP

UGIC 2009 Real-world examples Drill through a few hundred raster images and pull out cell values at several hundred points (~3.5 million values in output) Batch compute NDWI (Normalized Difference Water Index) for Landsat imagery Batch clip extraneous data from edges of images

UGIC 2009 Real-world examples Created a text file with info (bounding coordinates, dimensions, etc) about several hundred MSS images which was then used to input data into a database Created polygons showing bounding coordinates of actual data in several hundred raster images Logistic regression

UGIC 2009 Location Calculator

UGIC 2009

def getdata (keys=''): ''' possible ways to call this function: value=getdata('key') dict=getdata(('key1','key2')) #get subset dict=getdata() #return everything It assumes you don't have the same key for GET and POST methods ''' import types key_type=type(keys) d_data={} #initialize dictionary if keys=='': #if they don't supply keys then return everything for key in Request.Form: d_data[key]=Request.Form(key) for key in Request.QueryString: d_data[key]=Request.QueryString(key) return d_data elif key_type == types.StringType: #if they provide a single string value=Request.Form(keys) if (value != 'None') and (str(value) == 'None'): return Request.QueryString(keys) else: return value #if they provide a list then return a dictionary with all the key/values elif key_type == types.TupleType or key_type == types.ListType: for key in keys: value=Request.Form(key) #now check if the data was empty, if so look at QueryString if (value != 'None') and (str(value) == 'None'): value=Request.QueryString(key) data[key]=value return d_data if str(key) == 'utm': X_UTM=getdata('UTMx') Y_UTM=getdata('UTMy') datum=getdata('datumutm')

UGIC 2009 UTM NAD27 Zone 12 North Projects to:

UGIC 2009 UTM NAD27 Zone 12 North Projects to:

UGIC 2009 UTM NAD27 Zone 12 North Projects to:

UGIC 2009 Geocoding

UGIC 2009 Shapefile from SQL

UGIC 2009 Ex. 1: Reading vector data Open a point shapefile For each point: Get the “id” and “cover” attributes Get the x,y coordinates for the point Print “id x y cover”

UGIC 2009 Ex. 2: Extracting vector data Extract all “Quacking aspen woodland alliance” SWReGAP field sites in Wasatch county from the statewide data set Open a point shapefile with SWReGAP sample sites Open a Utah counties polygon shapefile Create a new point shapefile Use the county file to limit the SWReGAP shapefile to Wasatch County

UGIC 2009 Ex. 2: Extracting vector data Limit SWReGAP to “Quaking aspen woodland alliance” For each point in SWReGAP (remember it is now filtered spatially and by attribute): Copy the feature into the new shapefile Close all of the files

UGIC 2009 Ex. 3: Generate Near Table tool Given a point shapefile (SWReGAP field sites) and a line shapefile (roads), calculate the distance from each point to the nearest road Open both shapefiles For each point: Limit the search to the provided radius by buffering the point and using that to set a spatial filter on the roads

UGIC 2009 Ex. 3: Generate Near Table tool For each point, continued: Get the distance to the first line and its FID Loop through the rest of the lines and if the distance is less than the “remembered” distance, then remember the new distance and FID Write out the point FID and the remembered line FID and distance to a text file Close the shapefiles and the text file Needs an ArcInfo license in ArcMap (can probably write your own script, though)

UGIC 2009 Ex. 4: Extract pixel values Open a point shapefile Open a 3-band raster file For each point in the shapefile: Print out the pixel values at that location for all three bands “Sample” tool requires Spatial Analyst (to be fair, I think I may have done this with the arcgisscripting module without SA)

UGIC 2009 Ex. 5: Compute NDVI Create a Normalized Difference Vegetation Index for an ASTER image Open the image Get the image dimensions and block size Use this info to create a new image Read in one block at a time from the image Compute the NDVI: (band3-band2)/(band3+band2) Write the block to the new image Compute the statistics for the new image

UGIC 2009 Ex. 5: Compute NDVI Set the georeferencing and projection for the new image Build pyramids for the new image Needs the Spatial Analyst extension, and I don’t know if you could do it with anything in the geoprocessor without SA – I’m sure you could do it with ArcObjects

UGIC 2009 Ex. 6: NDVI in ArcMap Run the NDVI script in ArcMap Change the script to accept parameters Change the script to send error messages to the geoprocessor Add the script to a toolbox

UGIC 2009 Thanks! Course materials at I can be contacted at