I have experience using Perl and the DBI module to do work like this.  I've read from dbf files in the past, but have not written to one.  Still, I see no reason why it would be a hangup.    Let me know if you'd like to go in that direction.<br>
<br>Dave<br><br><br><div class="gmail_quote">On Wed, Oct 29, 2008 at 4:56 PM, Alex Mandel <span dir="ltr"><<a href="mailto:tech_dev@wildintellect.com">tech_dev@wildintellect.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">Tyler Erickson wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I am interested in approaches for adding a populated field to a shapefile<br>
(for example, adding a new field named 'source_url' with the value<br>
'<a href="http://somewebsite.com" target="_blank">http://somewebsite.com</a>').  I would like to do this for several thousand<br>
files.<br>
<br>
At first I thought that I might be able to accomplish it using ogr2org with<br>
a sql clause, such as:<br>
<br>
ogr2ogr -sql "select *, '<a href="http://somewebsite.com" target="_blank">http://somewebsite.com</a>' as source_url from infile"<br>
outfile.shp infile.shp<br>
<br>
but that didn't work since ogr2ogr supports a limited set of SQL, described<br>
at:<br>
<a href="http://www.gdal.org/ogr/ogr_sql.html" target="_blank">http://www.gdal.org/ogr/ogr_sql.html</a><br>
<br>
Any ideas on how to accomplish this? (I would prefer suggestions that can be<br>
scripted with python.)<br>
<br>
- Tyler<br>
</blockquote>
<br></div>
Open a data connection the dbf with python, add a field to the properties of the table and populate the field.<br>
<br>
There are several ways to connect to a dbf depending on the OS, you could use an ODBC connector, or use some other type of dbf driver.<br>
I haven't looked closely but there might be a dbf driver in the ogr python bindings already.<br>
<br>
I think my quick fix was to use python windows tools to wrap the dbf com object as a python object I could call, but that was a quick a dirty solution on windows.<br>
<br>
The other thing I've done is to create a blank shapefile with the exact same scheme + one field. Do an ogr2ogr -f "ESRI Shapefile" -a (append) of the blank shapefile and your existing one, and now you have a new field.<br>
<font color="#888888">
<br>
Alex</font><div><div></div><div class="Wj3C7c"><br>
_______________________________________________<br>
Discuss mailing list<br>
<a href="mailto:Discuss@lists.osgeo.org" target="_blank">Discuss@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/discuss" target="_blank">http://lists.osgeo.org/mailman/listinfo/discuss</a><br>
</div></div></blockquote></div><br>