[gdal-dev] ogr sql issue

Murat Beyhan beyhan at deprem.gov.tr
Mon May 28 05:55:14 PDT 2012


Dear All,

I would like to create a KML file using ogr2ogr with using following but
sql statement part does not filter data from csv file and draw all
points on the map, please help me what I'm doing wrong.

the code I used as follows

ogr2ogr -f "KML"  "villages.kml" "villages.csv" -dsco NameField=id


I also used -sql obtion on ogr2ogr command by deleting srcSQL line from
vrt and code as follows 


ogr2ogr -f "KML"  "villages.kml" "villages.csv" -dsco NameField=id 
-sql "SELECT * FROM villages where id > 1000"




My csv file as follows 

"id","lon","lat","acc"
1,30.5400,38.7581,27.95
2,30.5400,38.7889,28.23
3,30.6139,38.9781,26.34
.
.
.


vrt file as follows 

<OGRVRTDataSource>
    <OGRVRTLayer name="villages">
        <SrcDataSource>villages.csv</SrcDataSource>
        <SrcSQL>SELECT * from villages WHERE acc >100 </SrcSQL>
        <GeometryType>wkbPoint</GeometryType>
        <LayerSRS>WGS84</LayerSRS>
        <GeometryField encoding="PointFromColumns" x="lon" y="lat"/>
    </OGRVRTLayer>
</OGRVRTDataSource>


kml file as follows

<?xml version="1.0" encoding="utf-8" ?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document><Folder><name>villages_pga</name>
<Schema name="villages_pga" id="villages_pga">
        <SimpleField name="Name" type="string"></SimpleField>
        <SimpleField name="Description" type="string"></SimpleField>
        <SimpleField name="id" type="string"></SimpleField>
        <SimpleField name="lon" type="string"></SimpleField>
        <SimpleField name="lat" type="string"></SimpleField>
        <SimpleField name="acc" type="string"></SimpleField>
</Schema>
  <Placemark>
        <ExtendedData><SchemaData schemaUrl="#villages_pga">
                <SimpleData name="id">2</SimpleData>
                <SimpleData name="lon">30.5400</SimpleData>
                <SimpleData name="lat">38.7889</SimpleData>
                <SimpleData name="acc">28.23</SimpleData>
        </SchemaData></ExtendedData>
  </Placemark>
  <Placemark>
        <ExtendedData><SchemaData schemaUrl="#villages_pga">
                <SimpleData name="id">3</SimpleData>
                <SimpleData name="lon">30.6139</SimpleData>
                <SimpleData name="lat">38.9781</SimpleData>
                <SimpleData name="acc">26.34</SimpleData>
        </SchemaData></ExtendedData>
  </Placemark>
  <Placemark>
        <ExtendedData><SchemaData schemaUrl="#villages_pga">
                <SimpleData name="id">4</SimpleData>
                <SimpleData name="lon">30.7461</SimpleData>
                <SimpleData name="lat">38.7719</SimpleData>
                <SimpleData name="acc">21.64</SimpleData>
        </SchemaData></ExtendedData>
  </Placemark>
. 
.
.



Murat


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.



More information about the gdal-dev mailing list