[OSGeo-Discuss] Need for to to convert/deconstruct a shapefile to create a relational table

Fawcett, David (MPCA) David.Fawcett at state.mn.us
Fri Mar 16 09:18:59 PDT 2012


This could also likely be scripted using OGR’s Python bindings.

From: discuss-bounces at lists.osgeo.org [mailto:discuss-bounces at lists.osgeo.org] On Behalf Of Micha Silver
Sent: Friday, March 16, 2012 11:04 AM
To: OSGeo Discussions
Subject: Re: [OSGeo-Discuss] Need for to to convert/deconstruct a shapefile to create a relational table

On 03/16/2012 06:52 AM, Simon Cropper wrote:
Hi,

Does anyone know of a simple means to take a shapefile and create a either a SQLite or xBase table?

Essentially it is taking an attached attribute table, inserting the coordinates in a field and saving the new file in a designated format.

Most of the data being converted is point data or fixed area samples. Ideally the converter could record the centroid for grid cells with details of the furthest point.

I know of various tools that can do this 'manually' one step at a time but as I have many files that come regularly, I would like to somehow automate the process.
Since spatialite can be run with SQL commands as parameters on the command line (i.e. spatialite data.sqlite "SELECT * FROM table1;") you could pass the '.loaddbf' command to spatialite, and with some wildcard trickery loop thru all your shapefiles:
for f in *.shp; do spatialite data.sqlite ".loaddbf ${f}"; done
or so.



--

Micha Silver

Arava Development Co. +972-52-3665918

http://surfaces.co.il


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/discuss/attachments/20120316/0e1a2a89/attachment-0002.html>


More information about the Discuss mailing list