Skip to content
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

given key was not present in the dictionary - OSMGPFileLoader_osmtools #215

Open
BrettFrahm opened this issue Mar 25, 2020 · 7 comments
Open

Comments

@BrettFrahm
Copy link

Using ArcMap 10.7.1's Python 2.7 exe and ran into this error when trying to Load a .osm file I generated using Download OSM Data (XAPI).The Load OSM File tool worked when I used it through ArcMap.

Code Used:

import arcpy
print "Importing Toolbox.."
arcpy.ImportToolbox("C:\Program Files (x86)\ArcGIS\Desktop10.7\ArcToolbox\Toolboxes\OpenStreetMap Toolbox.tbx")
print "Loading OSM File..."
arcpy.OSMGPFileLoader_osmtools(in_osmFile=r"\\...\Desktop\test_osm.osm",
                               in_conserveMemory="DO_NOT_CONSERVE_MEMORY", in_attributeselect="",
                               out_targetdataset=".../GISADMIN@test.sde/test.GISADMIN.OSM_5",
                               out_osmPoints=".../GISADMIN@test.sde/test.GISADMIN.OSM_5/test.GISADMIN.OSM_5_osm_pt",
                               out_osmLines=".../GISADMIN@test.sde/test.GISADMIN.OSM_5/test.GISADMIN.OSM_5_osm_ln",
                               out_osmPolygons=".../GISADMIN@test.sde/test.GISADMIN.OSM_5/test.GISADMIN.5_osm_ply")

test_osm.zip

Error:

arcgisscripting.ExecuteError: The given key was not present in the dictionary.
at System.ThrowHelper.ThrowKeyNotFoundException()
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at ESRI.ArcGIS.OSM.GeoProcessing.OSMGPFileLoader.Execute(IArray paramvalues, ITrackCancel TrackCancel, IGPEnvironmentManager envMgr, IGPMessages message)
Failed to execute (OSMGPFileLoader).

@ThomasEmge
Copy link
Member

@mboeringa you have been very active in the scripting environment using the tools. Do you have a suggestion about what could cause the error message?

@mboeringa
Copy link

mboeringa commented Mar 31, 2020

@ThomasEmge

Well, yes and no, although I have done an enormous amount of development work regarding OpenStreetMap data and the toolboxes output, I only call one tool directly from my Python scripting code, the "OSM Attribute Selector".

@BrettFrahm

I do see one potential issue though, in the ImportToolbox statement, it is recommended to set an alias for these kind of toolboxes, so like this:

arcpy.ImportToolbox(<TOOLBOX_PATH>,'osmtools')

Notice the comma separated 'osmtools' alias. However, if that is causing the issue I am not sure. It seems to fail on a dictionary lookup in the actual tool code.

This does work though with my usage of the "OSM Attribute Selector" tool.

@BrettFrahm
Copy link
Author

I appreciate you 2 looking at this. I think it was failing due to in_conserveMemory="DO_NOT_CONSERVE_MEMORY". I switched it to conserve memory and it seems to be working now.

@ThomasEmge
Copy link
Member

I am glad you found a workaround. There is only a small percentage of use cases where this parameter would actually make sense and it is more of a historical marker at this point in time. Depending on your OSM data usage, the newer read only version of tool might be another way to go. 'Read only' meaning that you are not planning to upload data back to the OSM servers.

@BrettFrahm
Copy link
Author

@ThomasEmge

(What is the name/where can I find) this read-only version of the tool? I don't see information on this, but it would fit my use case since I am just trying to create a Network Dataset atm. Currently having trouble with the Load OSM tool with a large regional osm file and it would be nice to have another tool to try.

@ThomasEmge
Copy link
Member

The tool is mentioned here

However, since you would like to create a network dataset, you still need to use the 'old' tool. Unfortunately, dropping turn directions was one of the optimization steps for the read only version.

@mboeringa
Copy link

@BrettFrahm ,

@ThomasEmge refers to the OSM File Loader (Load only) tool in the same toolbox.

It essentially does the same thing as the Load OSM File tool, but has a few distinct traits that set it apart from this other tool:

  • It is multi-core capable via the Parallel Processing Factor enviroment setting that you can set in the ArcGIS geoprocessing environment settings (setting to 100% will use all cores), and is therefor considerably faster than the Load OSM File tool (allthough not all steps of the processing involved can be parallelized, so some of the steps are still single core).
  • It does NOT load full relation information in the resulting File Geodatabase, meaning you can not use the Editor's edit capabilities and load data back to OSM. Therefor "read only" or "import only".
  • As Thomas says, you cannot use it to create a Network Dataset
  • Note that the tool will load OpenStreetMap Multipolygon relations properly, so you don't lose data for cartographic purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants