Tyler, Here is a link to some python code that I wrote to read a delimited text file and write out a shapefile. It uses the ogr and osr python modules. The code is not particularly clean or efficient, but it does include the case of creating a shapefile, creating columns, and populating the columns.
http://code.google.com/p/flatlandmaps/source/browse/trunk/csv2shp.py You can email me directly if you have any questions about how it works. David. -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tyler Erickson Sent: Wednesday, October 29, 2008 4:49 PM To: discuss@lists.osgeo.org Subject: [OSGeo-Discuss] methods for programatically adding fields toshapefiles 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 -- View this message in context: http://n2.nabble.com/methods-for-programatically-adding-fields-to-shapef iles-tp1395535p1395535.html Sent from the OSGeo Discuss mailing list archive at Nabble.com. _______________________________________________ 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