LightOSM/Agents KeyError "way" not found

Hi, I have osm.pbf (from osm-geofabrics) file which I converted to an .osm file using osmosis

osmosis \                          
--read-pbf guadeloupe-latest.osm.pbf \
--tf accept-ways highway=motorway \
--used-node \
--write-xml guadeloupe-latest.osm

However when I input this file into the OpenStreetMap() function from Agents.jl (under the hood uses LightOSM from what I understand) I get a key error stating KeyError: key "way" not found. Any Idea what I am doing incorrectly?

using Agents: AbstractAgent, OpenStreetMapSpace, @agent,OSMAgent, ABM

@agent Zombie OSMAgent begin 
    infected::Bool 
    speed::Float64 
end 

map_path = "misc/data/guadeloupe-latest.osm"
model = ABM(
    Zombie,
    OpenStreetMapSpace(map_path);
    properties = Dict(:dt => 1/60),
)

>>> ERROR: KeyError: key "way" not found

You may want to try converting your map to .json instead of .osm, if that’s possible. Once you’ve done this, you should (hopefully) be able to just create the OSM model via Agents.jl with the built-in functionality.

P.s.: Mind you, I haven’t ever tested it like this. I just remember something about json being the preferred and fastest format for LightOSM. Personally, I normally just use the built-in overpass download function from LightOSM to get my map data.

Thanks will give it a try. However I will have to do some filtering because its an entire country and as such the file is just too big.

Alright managed to sort it, Its was actually a problem with the filtering side of things. There were no highways in Guadeloupe, hence why it was giving a ‘key “way” not found error’

osmosis \
--read-pbf guadeloupe-latest.osm.pbf \ 
--tf accept-ways highway=primary,trunk,secondary \ 
--used-node \
--write-xml guadeloupe-trunk-primary-secondary.osm
1 Like

Ah, such a simple thing. Awesome you figured it out. :slight_smile: