[gdal-dev] trying create a new SHP with Ogr2ogr from ODBC: SQL SERVER

Jose Gomez-Dans jgomezdans at gmail.com
Tue Feb 2 12:33:05 EST 2010


On 2 February 2010 17:11, Antonio Castillo <gantonio.castillo at gmail.com>wrote:

> ogr2ogr -f "ESRI Shapefile" -a_srs "EPSG:4326" "puentes.shp"
> p.nombre,t.latitud,t.longitud,t.altura FROM puente p,trayectoria t WHERE
> p.id_trajectory = t.id_trayectoria"

I think your problem stems from the fact that the DBF created in the
previous command has two fields that need to be related to a point geometry.
There's an example in how to translate this query into a virtual dataset,
which can then be translated into a shapefile easily in <
http://www.gdal.org/ogr/drv_vrt.html>. Not tested, but basically create a
file called the following file:

    <OGRVRTLayer name="MyQuery">
*        <SrcSQL*>SELECT p.nombre AS nombre,t.latitud AS
lat,t.longitud AS long,t.altura AS altura FROM puente p,trayectoria t
WHERE p.id_trajectory = t.id_trayectoria</SrcSQL>
	<GeometryField encoding="PointFromColumns" x="long" y="lat"/>

and then convert it into a Shapefile using ogr2ogr.

Hope that helps!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20100202/51e9c7e7/attachment.html

More information about the gdal-dev mailing list