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.
Dave On Wed, Oct 29, 2008 at 4:56 PM, Alex Mandel <[EMAIL PROTECTED]>wrote: > Tyler Erickson wrote: > >> I am interested in approaches for adding a populated field to a shapefile >> (for example, adding a new field named 'source_url' with the value >> 'http://somewebsite.com'). I would like to do this for several thousand >> files. >> >> At first I thought that I might be able to accomplish it using ogr2org >> with >> a sql clause, such as: >> >> ogr2ogr -sql "select *, 'http://somewebsite.com' as source_url from >> infile" >> outfile.shp infile.shp >> >> but that didn't work since ogr2ogr supports a limited set of SQL, >> described >> at: >> http://www.gdal.org/ogr/ogr_sql.html >> >> Any ideas on how to accomplish this? (I would prefer suggestions that can >> be >> scripted with python.) >> >> - Tyler >> > > Open a data connection the dbf with python, add a field to the properties > of the table and populate the field. > > 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. > I haven't looked closely but there might be a dbf driver in the ogr python > bindings already. > > 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. > > 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. > > Alex > > _______________________________________________ > Discuss mailing list > Discuss@lists.osgeo.org > http://lists.osgeo.org/mailman/listinfo/discuss >
_______________________________________________ Discuss mailing list Discuss@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/discuss