You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The filters work by having a key on the left (e.g. "railway") followed by how you want it to filter (exactly equal = or using regular expressions with ~) and then the value(s) you want to match for. In this case | is "or" for regex, so you need to use ~.
So the custom filter matches anything where the key "railway" matches rail or light_rail or subway etc.
To get this information you can go to OSM and zoom close to the area you are wanting to look at and either right click on the area and "Query features" or open "layers" on the side bar and tick "Map Data" (this approach can be laggy, especially if you are zoomed out), so you can then click on what you are interested in.
Also, just in case you run into the same issue as I did, when using custom_filter sometimes not all the results are shown if they aren't all connected #33 , so you can also add 'retain_all': True to your layer configuration. Some people #8 have also had to use large 'dilate' or 'buffer' values to get all the train lines to show up (I have used a 'buffer' value of about 3000 normally with no dilate, but you'll get very similar results no matter what you use (I think) when it comes to railways).
If you want to only have trains that are above ground you can also cascade multiple filters, the second filter here removes anything where tunnel==yes:
Hi I faced a similar situation, where railways were not plotted and tried the custom_filter by @G21-Goose.
Unfortunately this now just throws an error: KeyError: 'railway'
Any idea what’s going wrong there? To me it sounds like it can't find any railway objects for the specified radius? But there is a railway in the location I'm trying to plot.
@G21-Goose
I tried for 48.32826, 11.45587 and 'radius': 2000
Thanks to your code I found the issue: I specified different widths for the railway types and I assume some of them were not present in the area of interest and therefore I got the KeyError 'width': { 'rail': 7, 'light_rail': 5, 'subway': 5, 'tram': 4, 'disused': 4, 'construction': 3, 'abandoned': 3, 'monorail': 3, 'narrow_gauge': 3, },
Might be a good idea to either return a better error message or to simply ignore (and maybe return a warning instead) missing keys with a specified width?
Activity
G21-Goose commentedon Sep 17, 2021
Hi,
Try changing
custom_filterto:Some more infomration that may be useful:
The filters work by having a key on the left (e.g.

"railway") followed by how you want it to filter (exactly equal=or using regular expressions with~) and then the value(s) you want to match for. In this case|is "or" for regex, so you need to use~.So the custom filter matches anything where the key
"railway"matchesrailorlight_railorsubwayetc.To get this information you can go to OSM and zoom close to the area you are wanting to look at and either right click on the area and "Query features" or open "layers" on the side bar and tick "Map Data" (this approach can be laggy, especially if you are zoomed out), so you can then click on what you are interested in.
Also, just in case you run into the same issue as I did, when using
custom_filtersometimes not all the results are shown if they aren't all connected #33 , so you can also add'retain_all': Trueto your layer configuration. Some people #8 have also had to use large'dilate'or'buffer'values to get all the train lines to show up (I have used a'buffer'value of about 3000 normally with nodilate, but you'll get very similar results no matter what you use (I think) when it comes to railways).If you want to only have trains that are above ground you can also cascade multiple filters, the second filter here removes anything where
tunnel==yes:Hopefully this is useful to you and anyone else who is trying to plot railways.
quickcoffee commentedon Sep 18, 2021
Hi I faced a similar situation, where railways were not plotted and tried the
custom_filterby @G21-Goose.Unfortunately this now just throws an error:
KeyError: 'railway'Any idea what’s going wrong there? To me it sounds like it can't find any railway objects for the specified radius? But there is a railway in the location I'm trying to plot.
G21-Goose commentedon Sep 18, 2021
Hi @quickcoffee, can you give me the location you are trying?
This shows the railways around the area @Stelorio was trying.
quickcoffee commentedon Sep 19, 2021
@G21-Goose
I tried for
48.32826, 11.45587and'radius': 2000Thanks to your code I found the issue: I specified different widths for the railway types and I assume some of them were not present in the area of interest and therefore I got the KeyError
'width': { 'rail': 7, 'light_rail': 5, 'subway': 5, 'tram': 4, 'disused': 4, 'construction': 3, 'abandoned': 3, 'monorail': 3, 'narrow_gauge': 3, },Might be a good idea to either return a better error message or to simply ignore (and maybe return a warning instead) missing keys with a specified width?