Archive for the tag 'python'

Python and GIS - Beyond ModelBuilder and PythonWin

This is a presentation I gave last February at the ESRI Petroleum User Group conference in Houston, TX. I just discovered SlideShare the other day.

pyArkansas 2008 a huge success

I’m way behind on posting this, but here goes.

The first annual pyArkansas Python conference was held by pyar^2, the Python Artists of Arkansas , on October 4th on the campus of the University of Central Arkansas in Conway. We were very graciously hosted by the Department of Computer Science in their very fine facilities. To our surprise, 57 people attended. Honestly, when Greg Lindstrom and myself starting planning this conference earlier this year, I think we would’ve been shocked to have 25 attend. Our registration numbers actually went above 70 folks, but the weather turned bad that morning, so that might have held some people away. We had a nice mix of beginner and experienced Pythonistas. People came from Branson, MO, Dallas, TX, and all over the state of Arkansas.

In the morning, we had classes including introductory Python (taught by Dr. Chen of UCA ), intermediate Python (taught of Jeff Rush ), and Python for systems administration (taught by Noah Gift ). These classes were very well received. The afternoon consisted of talks on pyGame, text/file processing, One Laptop Per Child (OLPC), Python eggs, the Python standard library, and Python with Eclipse. Elegant Stitches was on hand selling their great assortment of officially-licensed Python shirts and gear (thanks again for the shirt, Janet!). I highly recommend the Python logo long-sleeved easy-care oxford - go order one today.

We had great sponsorship for this event. Major monetary sponsors included the Conway Area Chamber of Commerce , Southwestern Energy Company , Novasys Health , and the Python Software Foundation . Wingware graciously provided THREE 3-OS Wingware IDE Professional seats for us to give as prizes - many thanks for those. O’Reilly publishing gave us a box of about 15 books to give away. Python Magazine and ESRI’s ArcUser both pitched in free issues of magazines for our swag bags.

We have received some pretty good press on the event as well. Overall, I’d have to say that for a first stab and for having 50 people, we pulled it off quite nicely. We are already planning next year’s conference, which will surely be bigger and better than this one was.

I’m published in ArcUser!

My (hopefully first of many) article on GIS and Python has been published in the Spring 2008 edition of ESRI’s ArcUser magazine. You can get the pdf here , and the code listings here .

flickruploadr.py now in svn

I finally got around to getting a Subversion repository setup, so the latest development version of my flickuploadr.py can be checked out:

svn co http://svn.super-cooper.com/flickruploadr/trunk

or you can just get it at:

http://svn.super-cooper.com/flickruploadr/trunk

Flickr Uploadr for Mac sucks, Python and the Flickr API to the rescue!

I’ve attempted to use the Flickr Uploadr for the last few years, and it never has impressed me. It always fails, usually after only about 10 pictures, which really sucks when you are trying to upload hundreds of pictures, which I usually do. So last night, I had over 300 shots to upload, and after several attempts, the Flickr Uploadr just kept on failing to upload for me. I’ve been working on my own upload script (most of which is hacked from other peoples code, I must admit) for months now off and on, so I decided to give it a shot - and of course, it uploaded over 100 pics in one shot, without a single blip. As soon as I get a Subversion repository setup on my host server, I’ll get the code in there.

OOPs

Generally, when most people learn that I am a geologist by training, they are surprised. Maybe I just give off some sort of geeky aura, or maybe they are surprised that I’m not "using my degree" (actually I am in a way, but that is too convoluted a story to get into here). At any rate, the point is that I am not a programmer by training. I’d say that at least 75%+ of what I know about programming I taught myself through the ole School of Hard Knocks. I’ve had my share of training courses, but the vast majority of my experience has been just sitting down and cranking out code over the last eight years or so. But I digress. Today was a good day. Today I wrote my first object-oriented Python script from scratch . And it works. It’s not much, about a 100-line geoprocessing script; but it works. And I understand it and now realize how much easier this makes programming in Python. Look out.

Move to WebFaction

Finding the right Web host isn’t easy. Google "<web host name> review" for virtually any host out there, and you will find a plethora of both positive and negative feedback. Chances are, you’re going to find more negative feedback than positive just about every time. A month or so ago, when I was looking for a Web host for super-cooper.com, I spent alot, and I mean alot of time researching Web hosts. Apparently I didn’t do that great of a job the first time around. I chose AN Hosting , mostly because they were recommended by WordPress (although rumor has it that the WP folks get a kickback from those recommendations, which would not surprise me at all) and also because the number of negative reviews I found about them was small. Don’t get me wrong, the service was OK, and their plans are well-stocked, but the reliability and the speed just weren’t there. So last week, when I came across Brian’s post where he asked for options on a new host, I realized from the comments that I had to look into WebFaction - almost everyone who commented on his post recommended them. So I decided to switch. What a charm. Sign up was a breeze, and boy is this site faster. WebFaction claims to not "max out" their servers, and so far, I believe them. The list of what they provide is unique, so go check it out . I’m really dyin’ to get my GeoDjango on…

Mapping point locations with Python and Microsoft Live Search Maps

This article was first published in the February 2008 issue of Python Magazine . It is being reproduced here with the permission of Marco Tabini and Associates .

Requirements

Python 2.4+
pyExcelerator module (http://sourceforge.net/projects/pyexcelerator/ )
Anthony Tuininga’s ceODBC module (http://sourceforge.net/html/ceODBC.html )
John Machin’s xlrd module (http://www.lexicon.net/sjmachin/xlrd.htm )
Michael Foord’s cgiutils module (http://www.voidspace.org.uk/python/cgiutils.html )

Lets face it, using Python, we can pull data from virtually anywhere in the corporate enterprise - databases, text files, or other documents. But how can we easily visualize data that has place associated with it? Well, we turn to Python and the API of a popular web-mapping application, that’s how.

Read more »

Codeviewer plugin test

Back a few years ago, I used a code syntax highlighter called Code Viewer that was created by Aaron Schaefer at Elastic Dog. That has since been taken over by Håkan Carlström. I spent too many hours this weekend getting this plugin setup to parse Python source code. It uses GeSHi to highlight the code syntax, and I had to hack up the GeSHi CSS and my own CSS to get the Python source code to look like I wanted, but it’s about there. I highly recommend this plugin if you are looking to highlight source code of virtually any modern language. The coolest part of it is that it links to a source code file and you just point to that file, you don’t have to include the code in the post. Below is a sampling of the output, with my own CSS styling applied.

  1. def grabNewImages( self ):
  2. """ Recurses thru directories and looks for images to upload. I only want to upload my ‘5-star’ images, so we scan the IPTC tags for ‘r5′, my way of tagging my pics I really like (usually get prints of r5s) """
  3. images = []
  4. for dirpath, dirnames, filenames in os.walk(IMAGE_DIR):
  5. for f in filenames :
  6. # Grab IPTC keywords
  7. info = IPTCInfo(os.path.join(dirpath, f))
  8. # Is it a 5-star photo?
  9. if ‘r5′ in info.keywords:
  10. print ‘File to upload:’,os.path.join(dirpath, f)
  11. ext = f.lower().split(‘.’)[-1]
  12. if ( ext == ‘jpg’ or ext == ‘gif’ or ext == ‘png’ ):
  13. images.append( os.path.normpath( dirpath + ‘/’ + f ) )
  14. images.sort()
  15. return images

IPython - first thoughts

After I got back from the ESRI PUG a few weeks ago, I installed and started playing around with IPython. I gave a talk at the PUG, and afterwards met a guy who told me I had to try it. Boy was he right. IPython is worth its weight in gold just on the surface for its color-coding of text and history access (hit the up arrow key to get the previous commands, like at the DOS prompt). Another gem is that you can CTRL-C code from your editor and CTRL-V it into the IPython prompt - nice. I plan on playing around with this some more, and need to install it on my Mac as well - after the impending Leopard upgrade I need to do.