[gdal-dev] How to replace an osm key?

Djordje Spasic issworld2000 at yahoo.com
Mon Nov 14 08:31:52 PST 2016


Thank you Jukka,

> 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”.
I will definitely have to do this. It's just I need a quick solution to this specific issue, for now.



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

We tried something similar few days ago:

"C:\gdal\ogr2ogr.exe" --config OSM_USE_CUSTOM_INDEXING NO -skipfailures -f "ESRI Shapefile" -dialect sqlite -sql "select geometry, building as bldg, \"building:levels\" as bldg_level, height as height from multipolygons" "C:\output_shp_files" "C:\input.osm"

and it created a .shp file with invalid "building:level" values.What confuses me now is where to insert the newly added "is not null limit 1" part.


By the way, I have just tested the syntax you gave me today, with "building:levels" field:
"C:\gdal\ogr2ogr.exe" --config OSM_USE_CUSTOM_INDEXING NO -skipfailures -f "ESRI Shapefile" -dialect sqlite -sql "select geometry, \"building:levels\" as bldg_level from multipolygons where \"building:levels\" is not null limit 1" "C:\output_shp_files" "C:\input.osm"

and it again creates shapes with "bldg_level" field, and a value "building:levels" for each shape, under the "bldg_level" key.

I used ogr2ogr.exe from both GDAL 1.11.4 and GDAL 2.1.0 (downloaded from gisinternals.com).

They both resulted in the same error of all shapes having the "building:levels" value for "bldg_level" key.

I tried testing on a couple of .osm files, and got the same errors on all of them.

Is this a bug in ogr2ogr.exe?

If it is, whom do I need to contact?

Or is this a conflict with the osmconf.ini file's settings?
I uploaded it in here:
https://www.dropbox.com/s/rp242or1lhwggoo/osmconf.ini?dl=0

Thank you and my apologies for further disturbance.
 


----------------
    On Monday, November 14, 2016 4:44 PM, Rahkonen Jukka (MML) <jukka.rahkonen at maanmittauslaitos.fi> wrote:
 

  #yiv9851596120 #yiv9851596120 -- filtered {font-family:Helvetica;panose-1:2 11 6 4 2 2 2 2 2 4;}#yiv9851596120 filtered {panose-1:2 4 5 3 5 4 6 3 2 4;}#yiv9851596120 filtered {font-family:Calibri;panose-1:2 15 5 2 2 2 4 3 2 4;}#yiv9851596120 filtered {font-family:Verdana;panose-1:2 11 6 4 3 5 4 4 2 4;}#yiv9851596120 p.yiv9851596120MsoNormal, #yiv9851596120 li.yiv9851596120MsoNormal, #yiv9851596120 div.yiv9851596120MsoNormal {margin:0cm;margin-bottom:.0001pt;font-size:12.0pt;}#yiv9851596120 a:link, #yiv9851596120 span.yiv9851596120MsoHyperlink {color:blue;text-decoration:underline;}#yiv9851596120 a:visited, #yiv9851596120 span.yiv9851596120MsoHyperlinkFollowed {color:purple;text-decoration:underline;}#yiv9851596120 p.yiv9851596120msonormal, #yiv9851596120 li.yiv9851596120msonormal, #yiv9851596120 div.yiv9851596120msonormal {margin-right:0cm;margin-left:0cm;font-size:12.0pt;}#yiv9851596120 p.yiv9851596120msochpdefault, #yiv9851596120 li.yiv9851596120msochpdefault, #yiv9851596120 div.yiv9851596120msochpdefault {margin-right:0cm;margin-left:0cm;font-size:12.0pt;}#yiv9851596120 p.yiv9851596120msonormal1, #yiv9851596120 li.yiv9851596120msonormal1, #yiv9851596120 div.yiv9851596120msonormal1 {margin:0cm;margin-bottom:.0001pt;font-size:12.0pt;}#yiv9851596120 p.yiv9851596120msochpdefault1, #yiv9851596120 li.yiv9851596120msochpdefault1, #yiv9851596120 div.yiv9851596120msochpdefault1 {margin-right:0cm;margin-left:0cm;font-size:10.0pt;}#yiv9851596120 span.yiv9851596120msohyperlink {}#yiv9851596120 span.yiv9851596120msohyperlinkfollowed {}#yiv9851596120 span.yiv9851596120shkpostityyli17 {}#yiv9851596120 span.yiv9851596120shkpostityyli18 {}#yiv9851596120 span.yiv9851596120msohyperlink1 {color:blue;text-decoration:underline;}#yiv9851596120 span.yiv9851596120msohyperlinkfollowed1 {color:purple;text-decoration:underline;}#yiv9851596120 span.yiv9851596120shkpostityyli171 {color:#1F497D;}#yiv9851596120 span.yiv9851596120shkpostityyli181 {color:windowtext;}#yiv9851596120 span.yiv9851596120Shkpostityyli29 {color:#1F497D;}#yiv9851596120 span.yiv9851596120Shkpostityyli30 {color:#1F497D;}#yiv9851596120 .yiv9851596120MsoChpDefault {font-size:10.0pt;}#yiv9851596120 filtered {margin:70.85pt 2.0cm 70.85pt 2.0cm;}#yiv9851596120 div.yiv9851596120WordSection1 {}#yiv9851596120 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:issworld2000 at yahoo.com]
Lähetetty: 14. marraskuuta 2016 17:21
Vastaanottaja: Rahkonen Jukka (MML) <jukka.rahkonen at maanmittauslaitos.fi>;gdal-dev at 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.rahkonen at 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 examplehttps://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 threadhttp://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-   

   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20161114/b484832b/attachment-0001.html>


More information about the gdal-dev mailing list