sub-title

Also check Orama's Quora and Orama's GitHub
I shall not claim to know so much, but only that I learn new things everyday

Saturday, 25 October 2014

Python debugger has been elusive


Sometimes, when we are faced with a problem, we look for possible solutions and we may quickly resolve them. Then that same solution can be replicated to solve many other future problems of a similar nature.

That is my story about Python programming language. 


About three years ago, I had this little, but strategic, problem that required a strategic solution. I just heard from a friend that Python is very good for automation. So, I set out to read and research about Python ... and being a programmer, I was able to start using Python immediately, while I continued to build my knowledge of the language. Today, Python has become our language of choice for little, but powerful automation projects. I stress "little" for good measure.

Today, too, many of our users have expressed full satisfaction with the number of little, but powerful automation projects that we have developed using Python. For the end-users, of course, they have no idea that we use Python. In any case, it is none of their business.


The more we use Python, the more it becomes apparent that we need a fully fledged IDE for development purposes. So far, we use IDLE and PythonWin for writing our Python code. These are very basic editors, if you know what I mean; but they are the native editors for Python, so things like indentation - a key requirement for Python code - are well taken care of.


Recently, I was faced with a major hurdle in one of our numerous Python projects (one using Python 2.7 and AcGIS 10.1 - arcPy to be specific). I had been requested to make a major revision in the application, which I did using IDLE and PythonWin. Now, there were a few bugs that I needed to deal with. Unfortunately - but as expected - I was not to see any debugging tools in IDLE or PythonWin. This took me far backwards.


Again, reading and researching (of course using Google) are the key to knowledge acquisition. The dividend is that just yesterday, I just realized that Python has a debugging module called pdb (for “Python DeBugger”). Note that this is a module available in standard Python installation. This (pdb) was my savior because I was able to unearth the offending code in a matter of minutes, yet I had wasted several days before without a debugger.


To use pdb, first import the module like this:

import pdb

Then at the offending line, add the following code:

pdb.set_trace() 

You will then be able to do several standard debugging tasks. 


Listen to this: "A day that passes without learning something new is a day well wasted". I couldn't agree more.


Sunday, 19 October 2014

QGIS has come of age!

Surely, QGIS (previously Quantum GIS) has come of age!

That is the statement I can make without fear or favor. All this because of the new functionality that come with QGIS 2.4. Frankly, I cannot hide my excitement at these developments.

I will not enumerate the new exciting functionality, but suffice to say that one of my biggest - if not only - problem with QGIS has been the lack of a good tool for generating good presentation-quality maps. I am not sure whether Print Composer has only just improved in QGIS 2.4, but I am really thrilled either way.

I have always had reason to fall back to ArcGIS whenever a map output was required, but now, I can achieve exactly the same - if not better - with QGIS. Print Composer is so much fun to use now, and the amount of flexibility it offers is amazing.

Whereas in the past I have had issues with Print Composer in QGIS as pointed out above, it has always been a breeze to use most other QGIS functionality, and in fact most of the geo-processing and data management tools in QGIS have always been so user-friendly compared to ArcGIS. I would sometimes do geo-processing or data-processing in QGIS and only revert to ArcGIS at the point of generating maps.

Now, I have no more worries about buying many licenses for ArcGIS. Just a few licenses will suffice to take care of highly specialized functionality that may only be available in ArcGIS.

The other beauty of QGIS is the vast availability of Python plugins that are very easy to install and use. I think it is safe to say "no turning back" at this point. I will now consider migrating some of my automated Python scripts from ArcGIS to QGIS and preserve ArcGIS licenses for "Super Users" only.

It's all about the power of opensource.

I am happy. What more can I say?