Esri / arcgis-osm-editor

ArcGIS Editor for OpenStreetMap is a toolset for GIS users to access and contribute to OpenStreetMap through their Desktop or Server environment.
Apache License 2.0
392 stars 129 forks source link

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

Open BrettFrahm opened 4 years ago

BrettFrahm commented 4 years ago

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 commented 4 years ago

@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 commented 4 years ago

@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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

@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 commented 4 years ago

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 commented 4 years ago

@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: