-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issues with OSM Driver and interleaved error message and output #2100
Comments
The name of the open option is not the same as the name of the config option. It is documented but you must be awake when reading. This works for me with GDAL 3.1.0dev
|
Hi @jratike80 I am awake, but new to working with GDAL at the command line, apologies. I think the commit above makes the message clearer, many thanks for the quick fix @rouault. The second part of the question was related to the output, which for me is:
As I say I'm new to this, but would you expect to see more data? Running
Seems to generate 10+MB of data but yield the error messages noted above. The question is how to make GDAL output the data with the interleaving mode? Apologies for a beginners question and hoping to learn. |
P.s. I can also reproduce the output in your reproducible example @jratike80 on my older version of GDAL:
|
I was blind myself for the difference between OGR_INTERLEAVED_READING and INTERLEAVED_READING for a long time. I don't know why ogrinfo does not list the data. Perhaps Feature Count: -1 means that it is too ineffective to show full ogrinfo output from .pbf format. You can pretty fast convert all data (remembering the importance of osmconf.ini) into geopackage and read ogrinfo from that
|
Thanks for the reply @jratike80 but it still does not resolve the issue: how to use GDAL to read-in a medium sized dataset using the interleaved mode that is needed for the result to contain all the features in large files? The commands that one would expect to work from the documentation yield an empty object, is this not not a bug or was it designed to work like this? Very useful to see how to convert the file into a GeoPackage file, but that would not be computationally efficient in cases when you need to read in large files.
I'm not quit sure what this means but should the output of
Can you do that on a per layer basis? Nudge @edzer who developed the |
You can trigger random layer reading with the -rl switch of ogrinfo: https://gdal.org/programs/ogrinfo.html#cmdoption-ogrinfo-rl $ ogrinfo -rl greater-london-latest.osm.pbf lines But as noted by @jratike80 , direct reading from (large enough) .osm.pbf file is inefficient due to how the format is structured. Conversion to something else like GeoPackage is the recommended way of using them. |
Many thanks for the quick and enlightening reply Even. I will try that out now and let you know how I get on. |
Yes that seems to solve the issue:
|
And, as you say the conversion is quicker than the read: read = function() system("ogrinfo -rl greater-london-latest.osm.pbf lines > x4")
convert = function() system("ogr2ogr out.gpkg greater-london-latest.osm.pbf lines")
bench::mark(iterations = 1, check = FALSE, read(), convert())
|
Hi @rouault apologies but I have another follow-up question: how does one make the conversion respect the |
Use the -oo switch of ogr2ogr : https://gdal.org/programs/ogr2ogr.html#cmdoption-ogr2ogr-oo |
Hi @rouault thanks for the pointer, that works, but I'm getting some strange results (way more features in the output when the # get data
wget http://download.geofabrik.de/europe/great-britain/england/greater-london-latest.osm.pbf
# too many features error
# ogrinfo -oo OGR_INTERLEAVED_READING=YES *pbf lines > x2
# no data
# ogrinfo -oo INTERLEAVED_READING=YES *pbf lines > x3
# with random layers
# ogrinfo -rl greater-london-latest.osm.pbf lines > x4
# ogrinfo -so x4
# head x4 -n 32
# convert format - works but no custom .ini
ogr2ogr -f gpkg -oo INTERLEAVED_READING=YES osm.gpkg greater-london-latest.osm.pbf
ogrinfo -so osm.gpkg lines
# convert format - works with custom osmconf2.ini file - with these contents:
# [lines]
# # common attributes
# osm_id=yes
# osm_version=no
# osm_timestamp=no
# osm_uid=no
# osm_user=no
# osm_changeset=no
#
# # keys to report as OGR fields
# attributes=name,highway,waterway,aerialway,barrier,man_made,maxspeed,oneway,building,surface,landuse,natural,start_date,wall,service,lanes,layer,tracktype,bridge,foot,bicycle,lit,railway,footway
ogr2ogr -f gpkg -oo CONFIG_FILE=osmconf2.ini osm2.gpkg greater-london-latest.osm.pbf
ogrinfo -so osm2.gpkg lines # why does it have double the number of features?
ogr2ogr -f gpkg -oo CONFIG_FILE=osmconf2.ini INTERLEAVED_READING=YES osm3.gpkg greater-london-latest.osm.pbf
ogrinfo -so osm2.gpkg lines # fails |
You need to specify -oo in front of each open option: -oo CONFIG_FILE=osmconf2.ini -oo INTERLEAVED_READING=YES |
Many thanks Even, I'm gradually getting my head around this and am very grateful. Will help hugely with our work on sustainable transport. |
Dear GDAL dev team, I think there is an issue with the osm driver. The error message it produces does not seem to be useful (it says
Use OGR_INTERLEAVED_READING=YES
when that option is specified) and when usingINTERLEAVED_READING=YES
, which I think is correctly documented here https://gdal.org/drivers/vector/osm.html#interleaved-reading , the results seem to have no features.Please could you try to reproduce the (hopefully reproducible) example below?
This may be related to #1785.
See here for use case and some additional tests from within R: r-spatial/sf#1213
The text was updated successfully, but these errors were encountered: