[gdal-dev] ogr sql issue

Jukka Rahkonen jukka.rahkonen at mmmtike.fi
Mon May 28 06:32:05 PDT 2012


Murat Beyhan <beyhan <at> deprem.gov.tr> writes:

> 
> 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
.....
> <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>


Hi,

As you see, ogr is interpreting the id is of type "string". It cannot do greater
than comparison with strings.

I believe you must create a villages.csvt file for giving exact data types for
attributes. With this single line file stored in the same directory than
villages.csv you will perhaps have success.

"integer","real","real","real"

-Jukka Rahkonen-



More information about the gdal-dev mailing list