Hi,

If your version and environment requires escaping, then you need to do

"select geometry, \"building\" as bldg,\"building:levels\" as 
bldg_levels,\”height\” as height from multipolygons ... "
It may work also without escaping as
"select geometry, "building" as bldg,"building:levels" as bldg_levels,height as 
height from multipolygons ... "

If you plan to follow the SQL route I really recommend you to read some SQL 
tutorials and exercise at home. I am sure that you will learn the basics soon 
and tutorials are always in the web while I am not. SQL is so close to English 
and that you can think that you are making a (comma separated) shopping list
“SELECT milk,bread,juice FROM Wal-Mart”.

-Jukka-




Lähettäjä: Djordje Spasic [mailto:issworld2...@yahoo.com]
Lähetetty: 14. marraskuuta 2016 17:21
Vastaanottaja: Rahkonen Jukka (MML) 
<jukka.rahko...@maanmittauslaitos.fi<mailto:jukka.rahko...@maanmittauslaitos.fi>>;
 gdal-dev@lists.osgeo.org<mailto:gdal-dev@lists.osgeo.org>
Aihe: Re: VS: [gdal-dev] How to replace an osm key?

Thank you Jukka,

How should I edit the command you gave me:
"C:\gdal\ogr2ogr.exe" --config OSM_USE_CUSTOM_INDEXING NO -skipfailures -f 
"ESRI Shapefile" -dialect sqlite -sql "select geometry, \"building\" as bldg 
from multipolygons where \"building\" is not null limit 1" 
"C:\output_shp_files" "C:\input.osm"
so that "building", "building:levels", and "height" fields are included, not 
only the "building" field?

On Monday, November 14, 2016 2:10 PM, Rahkonen Jukka (MML) 
<jukka.rahko...@maanmittauslaitos.fi<mailto:jukka.rahko...@maanmittauslaitos.fi>>
 wrote:

Hi,

If you enclose something between single quotes in SQL it becomes a string.
SELECT ’building’  -> selects literally the given *string* –building—
However,

SELECT "building" -> selects the *value* of *field* –building-- (or 
“identifier” as is it called in SQL)

See for example https://www.sqlite.org/lang_keywords.html

I tested on Windows with trunk version of GDAL that this syntax works:

ogrinfo -dialect sqlite -sql "select geometry, "building" as bldg
from multipolygons where "building" is not null limit 1" hamburg-latest.osm.pbf

By reading this old thread 
http://osgeo-org.1560.x6.nabble.com/gdal-dev-OGR-SQL-Excecuting-select-where-column-name-contains-quot-quot-td5006377.html
 some older GDAL versions may need some more tweaking and inner double quotes 
must be escaped by back slash as \”

ogrinfo -dialect sqlite -sql "select geometry, \"building\" as bldg
from multipolygons where \"building\" is not null limit 1" 
hamburg-latest.osm.pbf


-Jukka Rahkonen-

_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to