# LightOSM/Agents KeyError "way" not found

**URL:** <https://discourse.julialang.org/t/lightosm-agents-keyerror-way-not-found/87367>\
**Category:** Specific Domains\
**Tags:** agents\
**Created:** [September 16, 2022, 1:24pm UTC](https://discourse.julialang.org/t/lightosm-agents-keyerror-way-not-found/87367 "2022-09-16T13:24:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![imantha](https://avatars.discourse-cdn.com/v4/letter/i/6a8cbe/32.png) [@imantha](https://discourse.julialang.org/u/imantha)\
**Post date:** [September 16, 2022, 1:24pm UTC](https://discourse.julialang.org/t/lightosm-agents-keyerror-way-not-found/87367/1 "2022-09-16T13:24:59Z")

</div>

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

```julia
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?

```julia
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

```

---

<div class="post-metadata">

**Author:** ![fbanning](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fbanning/32/14972_2.png) [@fbanning](https://discourse.julialang.org/u/fbanning)\
**Post date:** [September 16, 2022, 4:47pm UTC](https://discourse.julialang.org/t/lightosm-agents-keyerror-way-not-found/87367/2 "2022-09-16T16:47:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![imantha](https://avatars.discourse-cdn.com/v4/letter/i/6a8cbe/32.png) [@imantha](https://discourse.julialang.org/u/imantha)\
**Post date:** [September 16, 2022, 11:19pm UTC](https://discourse.julialang.org/t/lightosm-agents-keyerror-way-not-found/87367/3 "2022-09-16T23:19:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![imantha](https://avatars.discourse-cdn.com/v4/letter/i/6a8cbe/32.png) [@imantha](https://discourse.julialang.org/u/imantha)\
**Post date:** [September 17, 2022, 12:07am UTC](https://discourse.julialang.org/t/lightosm-agents-keyerror-way-not-found/87367/4 "2022-09-17T00:07:17Z")

</div>

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’

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

```

---

<div class="post-metadata">

**Author:** ![fbanning](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fbanning/32/14972_2.png) [@fbanning](https://discourse.julialang.org/u/fbanning)\
**Post date:** [September 26, 2022, 12:09pm UTC](https://discourse.julialang.org/t/lightosm-agents-keyerror-way-not-found/87367/5 "2022-09-26T12:09:35Z")

</div>

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