Python for GIS – A Personal Love Affair

If you’ve used ArcGIS for more than a day, you will know about shapefiles, one of the most pervasive GIS file formats across the industry. If your data is neither too complex nor voluminous, you’ll be by using shapefiles. Do you have any idea, though, what is the guts of a shapefile ? I don’t. There is an ESRI White Paper  (http://www.esri.com/library/whitepapers/pdfs/shapefile.pdf)  that explains the format. But I’ve never bothered to look at it. If you’re like me, you convert data from and to shapefile format quite often without bothering what’s inside the SHP.

For more sophisticated organization and better performance of your data, there are geodatabases. To read about the benefits of geodatabases, read this (http://www.pop.psu.edu/gia-core/pdfs/gis_rd_02-40.pdf). Personally, I get by with shapefiles in ArcGIS most of the time.

Also, there are other common data formats I use every day. Field technicians email me GPX files for GPS data collected in the field. Co-workers email me data saved in Google Earth as KML/KMZ. Or there is the occasional XLS spreadsheet from a surveyor containing State Plane Coordinates or a piece of paper with Lat/Long data scribbled on it…

Much of this data is simple point data for borehole locations as they were staked and surveyed in the field. Very simple geometry. One of the things I do is plot the data in ArcGIS to get a quick overview of the location – city,county, topography, geology, hydrology, etc… which later leads to some pretty maps that will go in a report.

When I first began using ArcGIS, to create a shapefile of point data I would start with an Excel spreadsheet with coordinates and then go the rather tedious route through ArcCatalog of creating a shapefile (of feature class) and populating it with Excel data, something like this.

Then, Google Earth happened, and I started working a lot with KML data. Plotting a point in GE is such a quick and easy way to see what a place looks like and to get data on a map. You save the data in KML (Keyhole Markup Language) or KMZ. To convert to shapefiles for use in ArcGIS I once used Arc2Earth. But I never really like the program. It tended to great junk data (e.g. empty feature classes I didn’t need). So when it stopped working after an ArcGIS upgrade, I simply switched to converting KML to SHP using a Python script like this one (http://arcscripts.esri.com/details.asp?dbid=15603)

That’s when I started believing in Python. Working with Python is simple and gives you so much flexibility because you are able to change the code at will. Much easier than pulling menus and clicking button within ArcGIS. Personally, I sometimes have a hard time remembering where certain functionality is hidden in ArcGIS, especially if I only use it from time to time. By keeping my Python scripts in one folder and documenting their use and functionality appropriately, I find I am better organized and have the flexibility to change and adjust functionality on demand.

To get started with ArcGIS geoprocessing scripts in Python, take a look at Writing Geoprcessing Scripts. Or you could just google the solution to your code question. I’ve posted a number of times about Python/ArcGIS Resources on my old blog. The truth is that, while Python capabilities in ArcGIS 10 have improved, there still isn’t a good manual that you could just read from cover to cover.

I got into Python through ArcGIS, and have become more interested in using Python for other GIS applications. Most of the time ArcGIS is really easy to use. But often enough it drives me crazy, and while my transition from version 9.3 to 10 is incomplete, 9.3 has been crashing on me a lot lately…. Well, this just to give you some background in case you were interested. Hope to document more of Python GIS discoveries soon.

4 Comments

Filed under Uncategorized

4 Responses to Python for GIS – A Personal Love Affair

  1. Pingback: GIS Topics and Themes for this blog « gis-programming.com

  2. I saw that you referenced my blog (allthingsgeography.blogspot.com). Thank you! FYI, I am working on a “to be” Python for ArcGIS book. I am still months out, but will be using it in my Online GIS Programming class at American River College as a primary “draft” text. See Geog 375, Introduction to GIS Programming. Fully online, fully Python (and ArcGIS 10).

    I don’t know if mine will be a love affair or a lover’s quarrel now that I get to deal with various versions of ArcGIS, Python, OS, and 32 v 64 bit….Yeah!

    http://search.arc.losrios.edu/cgi-bin/webdata_online.pl?cgifunction=Search&Course=^G
    http://www.losrios.edu/class_schedules_reader.php?loc=arc/spring/ethan/Geography-GEOG.htm

    Thank you for the reference.
    Nate

    • Arne

      Thanks for the comment. Send me a copy of your book when you’re done :-) It will be the missing manual. I always find that the information is all out there – sometimes one google search away, sometimes harder to find. But someone needs to write THE manual…

  3. Derek

    And if, at some point, you can’t afford to drink the ESRI KoolAid anymore (case in point, recent massive price hikes that have blitzed us “poor” users in second/third world countries), you’ll find Python hard at work in open source GIS solutions. A few examples:

    http://jetfar.com/python-geo-resources/
    http://pyogclib.sourceforge.net/
    http://www.carsonfarmer.com/?p=761

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>