[OSGeo Africa] Fwd: GIS automation
Zoltan
zoltans at geograph.co.za
Sun Mar 19 10:06:10 PDT 2017
Hi Charles/List,
> Hi list
>
> I am in the process of teaching myself some python programming. Now I
> need to move into real development of scripts for automation which I
> hope to donate to Open Source initiatives if possible. If anyone has
> ideas for repetitive tasks in any field please kindly assist. Your
> intellectual contribution will be considered.
Good for you.
"Repetitive tasks" is not really something that everyone has a finite
list of, but rather ends up being pertinent to some of the problems you
may be dealing with at any moment.
Also, there are many ways to skin a cat, so, List, feel free to flay my
thoughts or better still to add to them - but I think that as a
community let's take this opportunity to help someone get started, and
to also learn as a collective.
A couple of thoughts:
* Python v2.7 or v3?
Obviously, start with the newer - but be aware that some products
whose libraries you might want to use, might not yet be available
for v3.
(GDAL? QGIS? - keep google as your closest friend)
* Python.
You mentioned "...donate to Open Source..."
CPython is suggested in article at
http://docs.python-guide.org/en/latest/starting/which-python/
List: How definitive is above article?)
* My gut feel (not knowledge or experience, but gut feel) is to use
Python as a glue to join together other library routines (written in
faster languages) rather than create complicated numerical
processing in python code. Whilst most of the things you might use
Python for will run faster than your fingers can type, there will
come a time when the relative speed of your programme/process is
more important than the absolute speed.
So, why not start learning by being aware of the performance
implications of the code you are writing.
List: Chime in please - let's make this a community effort.
So, to your (Charles's) query:
As a kick-off, you might find that far too often when you start a
job/contract, you are given a pile of orthos, and told to "use these" -
only to later find out that (for example) they do not cover your area of
interest.
So a useful routine might be to create something that will visually show
you the coverage of the orthos that may be in a folder.
The cynical may say "Just load them into QGIS", but I say: "I've just
received a HD of 38526 orthos from NGI - I wonder which ones I don't
have?" :-)
As a first exercise perhaps try this:
pick a pile of orthos _that you know are on the same CRS_, and write
a python script that:
* lists the folder(s) containing your orthos
* Uses gdal python bindings to interrogate the ortho for its
geographic extents (and confirms the CRS)
* Using these extents write a WKT file that creates a polygon (box)
with an attribute as the file-name of the ortho.
You can then read this WKT file with QGIS and visually see the coverage
of the ortho extents.
I suggest staying in one CRS so that you don't have the extra hassle of
re-projecting your extents.
Hope this helps,
Kind regards,
Zoltan
PS:
Yes, there are many other ways to achieve the goals of this example, but
this method will allow one to learn how to dive out of Python into the
OS to list a directory, link to external libraries, and output a text
file for input to another system.
--
===========================================
Zoltan Szecsei PrGISc [PGP0031]
Geograph (Pty) Ltd.
GIS and Photogrammetric Services
P.O. Box 7, Muizenberg 7950, South Africa.
Mobile: +27-83-6004028
Fax: +27-86-6115323 www.geograph.co.za
===========================================
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/africa/attachments/20170319/db73f634/attachment-0001.html>
More information about the Africa
mailing list