<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>gis-programming.com</title>
	<atom:link href="http://gis-programming.com/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://gis-programming.com</link>
	<description>Arne&#039;s Adventures in GIS...</description>
	<lastBuildDate>Fri, 06 Jan 2012 23:52:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Python Standard Library &#8211; Book</title>
		<link>http://gis-programming.com/?p=259</link>
		<comments>http://gis-programming.com/?p=259#comments</comments>
		<pubDate>Fri, 06 Jan 2012 15:32:08 +0000</pubDate>
		<dc:creator>Arne</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Python Standard LIbrary Book Reviewed]]></category>

		<guid isPermaLink="false">http://gis-programming.com/?p=259</guid>
		<description><![CDATA[Working in Python, I find myself googling for solutions to programming snags all the time. More and more often, my questions turn out to be about use of the Python Standard Library, be it hashlib for file comparison purposes or &#8230; <a href="http://gis-programming.com/?p=259">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.amazon.com/gp/product/0321767349/ref=as_li_qf_sp_asin_il_tl?ie=UTF8&amp;tag=gisprogrammin-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=0321767349"><img class="alignleft size-full wp-image-260" style="margin: 10px;" title="Python_StandardLib" src="http://gis-programming.com/wp-content/uploads/2012/01/Python_StandardLib.jpg" alt="" width="150" height="200" /></a>Working in Python, I find myself googling for solutions to programming snags all the time. More and more often, my questions turn out to be about use of the Python Standard Library, be it <em>hashlib</em> for file comparison purposes or <em>shutil </em>for standard file system operations, or whatever. So I finally took the plunge and placed the Standard Library on my desk &#8211; the Addison-Wesley Professional/Developers Library text. I&#8217;ve said before, I learn more from reading 2 pages in a book than googling 20 pages.</p>
<p>This is not a beginners book on how to learn Python. This is the book you need, being the bookish type, if you use Python every day and would like to learn to finer details of how to use the standard modules effectively. This is a great book to just browse and start reading anywhere. I promise you that you will learn a lot.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://gis-programming.com/?feed=rss2&#038;p=259</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FME Desktop 2011 Class – Safe Software, Vancouver</title>
		<link>http://gis-programming.com/?p=253</link>
		<comments>http://gis-programming.com/?p=253#comments</comments>
		<pubDate>Fri, 30 Sep 2011 21:19:18 +0000</pubDate>
		<dc:creator>Arne</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ArcGIS Modelbuilder]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[FME Desktop]]></category>
		<category><![CDATA[Safe Software]]></category>
		<category><![CDATA[training]]></category>

		<guid isPermaLink="false">http://gis-programming.com/?p=253</guid>
		<description><![CDATA[I recently had the pleasure of escaping the Texas summer heat and traveling to Vancouver, BC, for a Safe Software training class. I had stopped at the Safe Software booth at ESRI UC for a few minutes this July, and &#8230; <a href="http://gis-programming.com/?p=253">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://gis-programming.com/wp-content/uploads/2011/09/safe-logo-top.gif"><img class="alignleft size-full wp-image-254" title="safe-logo-top" src="http://gis-programming.com/wp-content/uploads/2011/09/safe-logo-top.gif" alt="" width="177" height="90" /></a>I recently had the pleasure of escaping the Texas summer heat and traveling to Vancouver, BC, for a Safe Software training class. I had stopped at the Safe Software booth at ESRI UC for a few minutes this July, and one of their rep’s gave me a quick intro to FME Desktop. Well, one thing led to another, and so I was signed up for the class this month.</p>
<p>I haven’t taken a whole lot of similar classes but enough to know which ones are a failure, and which ones are worth your time. The one for FME Desktop 2011 was one of the best I’ve taken. In fact, I couldn’t help myself and had to rave to the friends at Safe about it. So let me quote from my own email:</p>
<p><span style="color: #333399;">First of all, let me share with you that I found the FME Desktop class to be top-notch ! I have taken a few similar classes or workshops in the past and this one stands out. Not only did I get the impression that Robyn really knows her stuff never mind the occasional FATAL ERROR <img src="http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif?m=1305848398g" alt=":-)" />  but the format of the class (30 minutes teaching, 10 minutes hands-on), plus the quality of the manual, made for a real good package that I would recommend to anyone interested in FME. Well done ! —  That said, I think FME is fantastic. I think I mentioned to both of you that I have pulled my hair out trying to wrap my brain around ESRI’s ModelBuilder more than once. FME makes more sense to me, is a lot more intuitive to my thinking and the work flows I deal with …</span></p>
<p>So, there you have it. If you haven’t taken a look at FME and deal with lots of ETL (extraction-transformation-loading) procedures, then this may be for you. Funny thing is (and I think both instructor and manual shared this with us), they say, that 90% of all FME transformations consist of shapefile &gt;&gt;&gt; shapefile conversion e.g. reprojection, adding attributes… What does that say about ArcGIS user friendliness or annoyance ? I’ve certainly tried to use ModelBuilder more than once, and every time I found that is was much easier and straight forward to just write things out in Python. With FME, I felt that – while maybe not easy to use – it’s very powerful and much more intuitive.</p>
]]></content:encoded>
			<wfw:commentRss>http://gis-programming.com/?feed=rss2&#038;p=253</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting PETRA well bore paths into ArcMAP using Python</title>
		<link>http://gis-programming.com/?p=228</link>
		<comments>http://gis-programming.com/?p=228#comments</comments>
		<pubDate>Fri, 23 Sep 2011 13:56:52 +0000</pubDate>
		<dc:creator>Arne</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://gis-programming.com/?p=228</guid>
		<description><![CDATA[I recently had to bring in some IHS well data from Petra (or IHS Enerdeq) into ArcMap. While I endured 2 days of Introduction to Petra for Geoscientists this summer, I easy and expertise when it comes to using Petra &#8230; <a href="http://gis-programming.com/?p=228">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I recently had to bring in some IHS well data from Petra (or IHS Enerdeq) into ArcMap. While I endured 2 days of Introduction to Petra for Geoscientists this summer, I easy and expertise when it comes to using Petra is rather limited. I agree with many online posters who complain about how clumsy, cluttered, and counter-intuitive PETRA is. But that&#8217;s another story. I was told by a well seasoned PETRA user that PETRA does not export to SHP file format, upon which she exported a well data table with lat/long&#8217;s for me as XLS. Whether the SHP limitation is indeed the case, I have not further investigated. I simply created an ESRI feature class from the LL data. Another needed step was exporting the well bore paths for directional wells into a polyline feature class for use in ArcMap. Again, the only way to get the data out of PETRA appeared to be as a table. I chose CSV.</p>
<p>The table has the following headers:</p>
<p>UWI | NAME | MD | TVD | EWOFFSET | NSOFFSET | DIP | AZM | TVDSS | XPATH | YPATH | SURNAME | SURSTAT</p>
<p>and provides a row of data for each survey depth, with UWI(API) repeating for all rows belonging to the same well.</p>
<p>To read this into Python, I did this:</p>
<pre>import csv

### Reference to Input CSV File
infile  = open('c:/temp/dirEXPORT.csv', "rb")
reader = csv.reader(infile)

rownum = 0
well = ""
Wells = []
points = []

### Read CSV File, Line by Line
for row in reader:

    if rownum == 0: # First line in file: read headers
        colcount = 0
        for column in row:
            print column,
            if column == "UWI":
                uwi = colcount
            if column == "XPATH":
                xpath = colcount
            if column == "YPATH":
                ypath = colcount
            if column == "MD":
                z = colcount
            colcount = colcount + 1
            rownum=+1

    else:

        print "\n"

        ### Check if row (line) is for the same well as row above
        ### if so, read coordinates from field and assign to xyz as list
        if row[uwi] == well:
            xyz = [row[xpath],row[ypath],row[z]]
            points.append(xyz)
            print row[uwi], xyz
            rownum=+1

        ### If row does not belong to the same well as the the last row,
### then append coordinate list and well name to Wells list, reset
### coordinates list (=[]), and assign the coordinates to the new well
        else:
            Wells.append([well,points])
            print "New Well"
            points = []
            well = row[uwi]
            xyz = [row[xpath],row[ypath],row[z]]
            points.append(xyz)
            print row[uwi], xyz
            rownum=+1
infile.close</pre>
<p>Any remaining print statements allow me to watch what&#8217;s going on when the program is run. It&#8217;s my crude way of debugging code.<br />
Once all the data is loaded into a list, I start some arcpy magic:</p>
<pre>import arcpy
from arcpy import env
import os

env.overwriteOutput = True
env.workspace = "C:/temp"

cnt = 0

mypath = env.workspace
outputFile = r"wormtracks.shp"
template = r"c:\temp\template.shp"
fieldLength = 25

sr = arcpy.Describe(template).spatialReference

arcpy.CreateFeatureclass_management(mypath,outputFile,"POLYLINE","","","",sr)
arcpy.AddField_management(outputFile, 'API', "TEXT", "", "", fieldLength) # add API as new table field

rows = arcpy.InsertCursor(outputFile)
array_container = arcpy.Array()

for well in Wells[1:]: # Ignore first item in Wells list. Poor programming where an empty list is created.
    well_api = well[0] # First item in list is the API

    wellList = well[1] # 2nd item in list is a list of XYZ points

    for pt in wellList:
        point_object = arcpy.Point()
        point_object.X = float(pt[0])
        point_object.Y = float(pt[1])

        print pt[0]
        print pt[1]
        array_container.append(point_object) # I couldn't figure out the difference between array.append and array.add
        print point_object
        del point_object

    row = rows.newRow()
    row.shape = arcpy.Polyline(array_container) # Do not use arcpy.Multipoint which created a really messy polyline w/points ouf of sequence.
    row.API = well_api
    rows.insertRow(row)
    array_container.removeAll()

del row #unlock row
del rows #unlock table

del arcpy
del outputFile</pre>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://gis-programming.com/?feed=rss2&#038;p=228</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Book: Python Geospatial Development</title>
		<link>http://gis-programming.com/?p=215</link>
		<comments>http://gis-programming.com/?p=215#comments</comments>
		<pubDate>Fri, 28 Jan 2011 17:47:15 +0000</pubDate>
		<dc:creator>Arne</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://gis-programming.com/?p=215</guid>
		<description><![CDATA[Everywhere on the web, you find people developing new GIS tools for/in Python. But I&#8217;ve never really come across a book that ties all this together. All the standard Open Source GIS books and manuals (paper and online) have chapters &#8230; <a href="http://gis-programming.com/?p=215">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://gis-programming.com/wp-content/uploads/2011/01/python_geosp.jpg"></a></p>
<p><a href="http://gis-programming.com/wp-content/uploads/2011/01/python_geosp.jpg"><img class="alignleft" style="margin: 0px 10px;" title="python_geosp" src="http://gis-programming.com/wp-content/uploads/2011/01/python_geosp.jpg" alt="" width="130" height="160" /></a>Ever<a href="http://gis-programming.com/wp-content/uploads/2011/01/python_geosp.jpg"></a>ywhere on the web, you find people developing new GIS tools for/in Python. But I&#8217;ve never really come across a book that ties all this together. All the standard Open Source GIS books and manuals (paper and online) have chapters about Python.</p>
<p>All the major packages have Python support, e.g.<a href="http://www.google.com/url?sa=t&amp;source=web&amp;cd=1&amp;sqi=2&amp;ved=0CBMQFjAA&amp;url=http%3A%2F%2Fmapserver.org%2Fmapscript%2Fpython.html&amp;ei=yf1CTfTKBoKclgfjhs01&amp;usg=AFQjCNGkxiynBexvsybbNuiMirED3ennUw"> Mapserver (Python Mapscript)</a> or the <a href="http://linfiniti.com/wp-content/uploads/2010/11/PyQGIS.pdf">Quantum GIS Python Cookbook</a> for QGIS. There a numerous other projects and packages.</p>
<p>So when I saw this new title: <a style="border: none;" href="http://gis-programming.com/wp-admin/%3Ca%20href=%22http://www.amazon.com/gp/product/1849511543?ie=UTF8&amp;tag=gisprogrammin-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1849511543&quot;&gt;&lt;img border=&quot;0&quot; src=&quot; mce_href=&quot; mce_src=&quot; mce_href=&quot;&lt;a href=&quot;http://www.amazon.com/gp/product/1849511543?ie=UTF8&amp;tag=gisprogrammin-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1849511543&quot;&gt;&lt;img border=&quot;0&quot; src=">Python Geospatial Development</a>, I got excited. It covers everything from basic GIS concepts to sources of geospatial/GIS data and imagery. It covers MySQL, PostGIS, <strong><em>and</em></strong> Spatialite, mapnik, and finally even setting up a Geodjango application.</p>
<p>This is probably not the kind of book to read from cover to cover if you&#8217;ve already worked with some of these projects, but it covers a wide range of available tools and is packed with online resources and links to even more tools and resources. I will try to remember to elaborate once I&#8217;ve read a little more.</p>
<p>.</p>
]]></content:encoded>
			<wfw:commentRss>http://gis-programming.com/?feed=rss2&#038;p=215</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>pmapper &#8211; a framework for Mapserver applications</title>
		<link>http://gis-programming.com/?p=208</link>
		<comments>http://gis-programming.com/?p=208#comments</comments>
		<pubDate>Fri, 28 Jan 2011 16:54:47 +0000</pubDate>
		<dc:creator>Arne</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://gis-programming.com/?p=208</guid>
		<description><![CDATA[After playing around with my own HTML/css templates for Mapserver, I started looking for a better solution. In fact, there are a number of frequently used frameworks (see http://maptools.org under Webtools). I briefly looked at Dracones, because it&#8217;s written in Python. &#8230; <a href="http://gis-programming.com/?p=208">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>After playing around with my own HTML/css templates for Mapserver, I started looking for a better solution. In fact, there are a number of frequently used frameworks (see <a href="http://maptools.org">http://maptools.org</a> under Webtools).</p>
<p>I briefly looked at <a href=" http://surveillance.mcgill.ca/dracones/">Dracones</a>, because it&#8217;s written in Python. But I quickly got the sense that setup was less than straight forward. It sound like some of the adventures I had with getting any useful results out of (Geo)Django. <a href="http://www.ominiverdi.org/index.php/kamap/Ka-Map!#">Ka-Map </a>appears to be pretty popular. But I didn&#8217;t like the look of their standard template, and wanted something to work out of the box.</p>
<p><a href="http://gis-programming.com/wp-content/uploads/2011/01/pmapper_logo.gif"><img class="alignleft size-full wp-image-209" style="margin: 5px 10px;" title="pmapper_logo" src="http://gis-programming.com/wp-content/uploads/2011/01/pmapper_logo.gif" alt="" width="124" height="26" /></a>So I turned to<a href="http://www.pmapper.net/"> pmapper</a>. It comes in a <a href="http://sourceforge.net/projects/pmapper/files/">download-ready MS4W package</a> that installs super easily &#8211; no problems at all if you&#8217;ve got a functioning version of MS4W version installed. I found it helpful to first get the sample project up and running &#8211; using the <a href="http://sourceforge.net/projects/pmapper/files/p.mapper%20demo%20data/">demodata</a> provided. This works with a mapfile and some shapefiles of European countries and cities. Depending where you install (copy &#8216;n paste) your pmapper directory, you might have to adjust some of the Apache directives in httpd.conf. But if you&#8217;ve been through this for the MS4W installation, you won&#8217;t have any troubles.</p>
<p>Once you start using your own data, it might be easiest to work with the existing directory structure and slowly start changing/recycling the demodata mapfile. Anyway, now I have a great looking template with a somewhat dynamic legend, pan and continuous zoom, and more. The categories &amp; groups references in config/config_default.xml confused me initially because groups actually refers to GROUP names in the MAPFILE. But with some trial and error, you get all your layers displayed the way you want.</p>
<p> There  are still a few bugs, though, to be ironed out.</p>
<ol>
<li>The feature search still refuses to work properly.</li>
<li>I think I may have made a mistake with my reference map, because the box highlighting my zoom area only adjusts in the north-south directions, but nevre east-west, and coincidentally, my panning now only works north-south but not east-west.</li>
</ol>
<p>Since pmapper uses PHP and Javascript neither of which I understand well, the challenge now lies in adding some Python Mapscript capabilities so that I can extend the framework myself. I&#8217;m thinking about a little drop down input box where you select SHP data that&#8217;s added dynamically&#8230; I will get to that when I have time.</p>
]]></content:encoded>
			<wfw:commentRss>http://gis-programming.com/?feed=rss2&#038;p=208</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Maneuvering Around Directories w/Python in Windows</title>
		<link>http://gis-programming.com/?p=204</link>
		<comments>http://gis-programming.com/?p=204#comments</comments>
		<pubDate>Thu, 23 Dec 2010 17:36:05 +0000</pubDate>
		<dc:creator>Arne</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[GIS]]></category>
		<category><![CDATA[glob]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[shp]]></category>

		<guid isPermaLink="false">http://gis-programming.com/?p=204</guid>
		<description><![CDATA[Working a lot with SHP/TXT/KML files in Python on Windows, I have found it helpful to refresh my how-to memory : To find out where you are: import os WorkingDirectory = os.getcwd() To change directories: import os os.chdir(“NewWorkingDirectory”) Really useful is &#8230; <a href="http://gis-programming.com/?p=204">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Working a lot with SHP/TXT/KML files in Python on Windows, I have found it helpful to refresh my how-to memory :</p>
<p>To find out where you are:</p>
<blockquote><p>import os<br />
WorkingDirectory = os.getcwd()</p></blockquote>
<p>To change directories:</p>
<blockquote><p>import os<br />
os.chdir(“NewWorkingDirectory”)</p></blockquote>
<p>Really useful is the <strong>glob </strong>module if you want to read the contents of a directory into a list, and maybe iterate over that list&#8230;</p>
<blockquote><p>import glob<br />
for file in glob.glob(“*.*”):<br />
    print file # print all file names in dir</p></blockquote>
<p>or</p>
<blockquote><p>import glob<br />
for shp in glob.glob(“*.shp”):<br />
    print shp # print names of all shapefiles in dir</p></blockquote>
<p>Obviously, there is much more, e.g. os.path. See<a href="http://effbot.org/librarybook/os.htm"> here (http://effbot.org/librarybook/os.htm)</a> and <a href="http://docs.python.org/library/os.path.html">here (http://docs.python.org/library/os.path.html)</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://gis-programming.com/?feed=rss2&#038;p=204</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Merging SHP-files with Geoscript</title>
		<link>http://gis-programming.com/?p=202</link>
		<comments>http://gis-programming.com/?p=202#comments</comments>
		<pubDate>Thu, 23 Dec 2010 17:34:44 +0000</pubDate>
		<dc:creator>Arne</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[geoscript]]></category>
		<category><![CDATA[jython]]></category>
		<category><![CDATA[merge]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[shapefile]]></category>

		<guid isPermaLink="false">http://gis-programming.com/?p=202</guid>
		<description><![CDATA[I hadn’t heard of Geoscript until I googled my way to this page. Geoscript is Java but there is a Python implementation for Jython. So if you’re familiar with either one, check it out. The script certainly is shorter and &#8230; <a href="http://gis-programming.com/?p=202">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I hadn’t heard of <a href="http://geoscript.org/">Geoscript </a>until I googled my way <a href="http://geoscriptblog.blogspot.com/2010/06/merging-shapefiles-with-javascript.html">to this page</a>. Geoscript is Java but there is a Python implementation for Jython. So if you’re familiar with either one, check it out.</p>
<p>The script certainly is shorter and looks more straight forward than other Python examples I had looked at. But as Tim Schaub observes, <a href="http://darrencope.com/2010/05/07/merge-a-directory-of-shapefiles-using-ogr/">Darren’s Windows script </a>(which I adapted for my purposes) is much more light weight.</p>
]]></content:encoded>
			<wfw:commentRss>http://gis-programming.com/?feed=rss2&#038;p=202</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OGR &amp; Python – Batch Processing</title>
		<link>http://gis-programming.com/?p=200</link>
		<comments>http://gis-programming.com/?p=200#comments</comments>
		<pubDate>Thu, 23 Dec 2010 17:34:07 +0000</pubDate>
		<dc:creator>Arne</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[merge]]></category>
		<category><![CDATA[OGR]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[shapefile]]></category>
		<category><![CDATA[shapefile.py]]></category>

		<guid isPermaLink="false">http://gis-programming.com/?p=200</guid>
		<description><![CDATA[I have been looking at using OGR in/with Python. Initially I wanted to find an easy way to merge a number of shapefiles with OGR. But there appeared to be no straight forward way to do that using ogr2ogr from &#8230; <a href="http://gis-programming.com/?p=200">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I have been looking at using OGR in/with Python. Initially I wanted to find an easy way to merge a number of shapefiles with OGR. But there appeared to be no straight forward way to do that using ogr2ogr from the commandline.</p>
<p>Python bindings for OGR are included in the installation for FWTools, and provided your PYTHONPATH in Windows is set up properly, all you need to get going is:</p>
<p>import ogr</p>
<p>For other installations, e.g. OSGEO4W, you might need from osgeo import ogr</p>
<p>There is a <a href="http://download.osgeo.org/gdal/presentations/OpenSource_Weds_Andre_CUGOS.pdf">script here (page 22)</a> for merging shapefiles. But it works by iterating through first files and then each feature to write each one into a new shapefile. This took forever ! I guess what I was looking for was a program or way to simply take one shapefile and tack it to the “end” of the next without crawling through one field at a time and copying it over to the next file.</p>
<p>Then I read about <a href="http://code.google.com/p/pyshp/">shapefile.py</a> on <a href="http://geospatialpython.com/">Joel Lawhead’s geospatialpython.com</a>. This is a really neat module that allows you to access features and features parts/points in shapefile directly.</p>
<blockquote><p>import shapefile</p>
<p>r = shapefile.Reader(“yourfile.shp“)<br />
features = r.shapes()<br />
print “Number of features: “,len(features)<br />
cnt=1<br />
for point in features[yourchoice].points:<br />
   print “Coordinates for Point “,cnt, point<br />
   cnt=cnt+1</p></blockquote>
<p>Works like a char. But again, to simply aggregate many shapefile in one SHP, this would take to long. So for now <a href="http://darrencope.com/2010/05/07/merge-a-directory-of-shapefiles-using-ogr/">Darren’s little Windows script</a> to batch process the SHP’s with ogr2ogr has been the best way. I haven’t really used Python for such purposes but I guess you could.</p>
]]></content:encoded>
			<wfw:commentRss>http://gis-programming.com/?feed=rss2&#038;p=200</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OGR &#8211; Merging Multiple SHP files</title>
		<link>http://gis-programming.com/?p=194</link>
		<comments>http://gis-programming.com/?p=194#comments</comments>
		<pubDate>Tue, 21 Dec 2010 22:38:40 +0000</pubDate>
		<dc:creator>Arne</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[merging multiple shapefiles]]></category>
		<category><![CDATA[ogr2ogr]]></category>

		<guid isPermaLink="false">http://gis-programming.com/?p=194</guid>
		<description><![CDATA[So I have 25 shapefiles with data for 25 counties, and I want to merge them all into one shapefile. Using OGR, you can merge 2 files like this: ogr2ogr merge.shp file1.shp ogr2ogr -update -append merged.shp file2.shp -nln merge You &#8230; <a href="http://gis-programming.com/?p=194">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>So I have 25 shapefiles with data for 25 counties, and I want to merge them all into one shapefile.</p>
<p>Using OGR,<a href="http://www.gdal.org/ogr/drv_shapefile.html"> you can merge 2 files like this</a>:</p>
<p><strong>ogr2ogr merge.shp file1.shp<br />
ogr2ogr -update -append merged.shp file2.shp -nln merge</strong></p>
<p>You create a new shapefile <em>merged</em> and copy the contents of <em>file1</em> into the new shapefile. Then you append the contents of <em>file2</em> to the newly created shapefile and name it <em>merged</em>.</p>
<p>What do you do if you don&#8217;t want to do this 25 times ?</p>
<p>On page 22 of this document (<a href="http://download.osgeo.org/gdal/presentations/OpenSource_Weds_Andre_CUGOS.pdf">Using GDAL / OGR for Data Processing and Analysis</a>) is a Python script for doing this. But I couldn&#8217;t get the Python bindings for GDAL to work. The errors were always with importing _gdal which I understand is the gdal dll and references to _gdal are created by <a href="http://swig.org/">SWIG</a>. I don&#8217;t care about the script. I can write my own. But I would like to get GDAL(OGR) working from Python.</p>
<p>So after giving up on this concept temporarily, I resorted to Windows scripting, as modified from <a href="http://darrencope.com/2010/05/07/merge-a-directory-of-shapefiles-using-ogr/">this page</a>:</p>
<p>as above, use: <strong>ogr2ogr merge.shp file1.shp </strong>to create a shapefile <em>merge</em> containing the data of <em>file1</em></p>
<p>then:</p>
<p><strong>for %f in (*.shp) do (<br />
ogr2ogr -update -append merge.shp %f  -f “esri shapefile” -nln merge )<br />
</strong>That worked.</p>
]]></content:encoded>
			<wfw:commentRss>http://gis-programming.com/?feed=rss2&#038;p=194</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Mapserver Project</title>
		<link>http://gis-programming.com/?p=188</link>
		<comments>http://gis-programming.com/?p=188#comments</comments>
		<pubDate>Tue, 21 Dec 2010 22:07:04 +0000</pubDate>
		<dc:creator>Arne</dc:creator>
				<category><![CDATA[Mapserver]]></category>
		<category><![CDATA[arcgis styles]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[html template]]></category>
		<category><![CDATA[mapfile]]></category>
		<category><![CDATA[symbology]]></category>

		<guid isPermaLink="false">http://gis-programming.com/?p=188</guid>
		<description><![CDATA[So I&#8217;ve had a few days to work on my Mapserver project, and I am enjoying every bit of it. I remember setting up an ArcGIS Web Services built around an MXD file. Getting a map to show up in &#8230; <a href="http://gis-programming.com/?p=188">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>So I&#8217;ve had a few days to work on my Mapserver project, and I am enjoying every bit of it. I remember setting up an ArcGIS Web Services built around an MXD file. Getting a map to show up in your browser took forever. Getting the same map to display when served by Mapserver takes only a sec. Don&#8217;t get me wrong, I am not rating technology here. It&#8217;s simply been so much easier to get some useful results with Mapserver.</p>
<p>So I&#8217;ve cobbled together a simple HTML template with a simple CSS (for the design of a few div&#8217;s) and map controls for zoom/pan and adding data layers. Essentially this was based on any number of Mapserver Tutorials, e.g. Mitchell&#8217;s <a href="http://www.amazon.com/dp/0596008651?tag=gisprogrammin-20&amp;camp=213381&amp;creative=390973&amp;linkCode=as4&amp;creativeASIN=0596008651&amp;adid=06G2SD406A0QTMW9WW4B&amp;">Web Mapping book</a> or <a href="http://www.amazon.com/dp/1590594908?tag=gisprogrammin-20&amp;camp=213381&amp;creative=390973&amp;linkCode=as4&amp;creativeASIN=1590594908&amp;adid=15QFJVS8954H39YDHQDE&amp;">Beginning Mapserver</a>. Initially, I was having some problems trying to reference the correct directories for Apache and mapserv. For example, I found that the href=&#8221;&#8230;&#8221; for the css &lt;link&gt; didn&#8217;t work as a relative link. It had to be an absolute link to the location of the CSS file even if that was located in the same directory as the HTML template.</p>
<p><img title="mapserverproject" src="http://gis-programming.com/wp-content/uploads/2010/12/mapserverproject.jpg" alt="" width="805" height="680" /></p>
<p>Also, I remembered the hard way that while you can spread your &lt;form&gt; over multiple &lt;div&gt;&#8217;s you can&#8217;t do this and expect it to work:</p>
<p>&lt;div1&gt;<br />
   &lt;form&gt;<br />
&lt;/div1&gt;<br />
&lt;div2&gt;<br />
   &lt;/form&gt;<br />
&lt;/div2&gt;                 YIKES !!!</p>
<p style="text-align: left;">As you can see, right now, I have 3 zoom controls, and (for trial purposes) 4 data layers &#8211; counties and interstates to help you zoom to your area of interest, and roads and geology for more detail &#8211; that can be turned on and off. As soon as I get around to it, I will add capability to hide certain layers at large scales and add labeling for layers at zoom scales where it makes sense. Then, I would like add a tool that allows the user to add project specific data points, e.g. boreholes stored in SHP files, by selecting from a list of project numbers. In an effort to stay clear of ArcGIS, I will look into using PostGIS for this.</p>
<p style="text-align: left;">It took me a long time re-create some of the color/hatch patterns for the geology map which I have been typically been producing through an ArcGIS style file. This was good practice for a first Mapserver project, but there may be a better/faster/more accurate way to re-produce this map effects. I remember reading somewhere     that creating maps in Quantum GIS and then saving your styles in mapfile format is one way to go. Here is someone <a href="http://forum.qgis.org/viewtopic.php?f=2&amp;t=4550">trying to use ArcGIS styles in QGIS</a>.</p>
<p style="text-align: left;">In the process of wanting to make this an all Open Source project, I had to resort to OGR once again to combine public roads data from 25 counties into one shapefile for Mapserver. Im pretty sure there is a way to use some kind of tiling for this but I haven&#8217;t gotten that far. Anyway&#8230; new lessons learned with OGR int he next post.</p>
<p style="text-align: left;"> </p>
<p style="text-align: center;"><a href="http://gis-programming.com/wp-content/uploads/2010/12/mapserverproject.jpg"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://gis-programming.com/?feed=rss2&#038;p=188</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
