OpenStreetMap logo OpenStreetMap

Identifying Wrong-Size Sports Pitches (Overpass/MapRoulette)

Posted by bmaczero on 22 December 2025 in English. Last updated on 23 December 2025.

One OSM-related activity I spend lots of time on is micromapping recreational areas, such as parks. Manually detailing out areas is satisfying, but I’ve also been on the lookout for ways to put my programming skills to use.

A common pattern I noticed in these areas is representing a block of pitches or courts (such as tennis courts) as a single, abnormally large “tennis court”.

A tennis area with a single rectangle around the whole thing.

It’s a start, but obviously could use some refining. Each individual court could be represented by a separate area. While this probably needs no justifications, I’ll provide a few since I’d like to convince myself I’m working on improvements that might mean something to someone, rather than just creating data because it gives me dopamine:

  • Independent courts allow for better querying: we can ask questions like “how many tennis courts are in my city?” and get an accurate answer.
  • Some renderers (like openstreetmap.fr) render various courts with appropriate marking lines, allowing quick identification.

I used overpass turbo, some custom code, and Map Roulette to set up a pipeline to fix these “multi-pitch areas”. Here’s my workflow:

1. Query overpass for a raw list of pitches

Using a query like this, collect all the pitches (large or not) in the target area:

{{geocodeArea:Colorado}}->.searchArea;
way["leisure"="pitch"]["sport"="tennis"](area.searchArea);
foreach (way._(if:count_members() == 5); out geom;);

There are a lot of tennis courts in the United States[citation needed]. To do the whole country, I had to break it up into regions and query each region separately. This is an area for future improvement; there’s probably a way to automate making a string of overpass queries.

You’ll probably notice this only collects areas that are quadrilaterals. It’s easiest to calculate the dimensions of those, so I’m starting there. More complicated areas can come later.

2. Filter down to unusually large areas

I can download all the areas from overpass as GeoJSON and write code on my computer to do whatever I want to it. In this case, that is calculating the dimensions of each area, and saving the ones that are some factor bigger than we’d expect to another GeoJSON file. You can peruse the relevant code here and here.

3. Upload filtered list to Map Roulette

Getting the actual courts drawn in requires human intervention, and Map Roulette is a great tool for that. I loaded the output file as a Map Roulette task. We’re currently 20% of the way through over 14,000 multi-pitch tennis courts in the US - click the link to help!

4. Make fixes on Map Roulette

Much better!

A tennis area with three courts individually marked.

I’ll be looking for other applications of this pipeline as time permits. The obvious one is to do this for other types of sports. We also completed another task to review “tennis courts” that, based on their sized, looked a lot more likely to be pickleball courts instead. Let me know if you have any other suggestions!

Discussion

Comment from mmd on 22 December 2025 at 19:49

Checking the way length (or rather the circumference) could be another option to avoid any post processing. Actual cut off value might need some tweaking: https://overpass-turbo.eu/s/2hGE

There’s some issue with the Overpass QL rendering in the post. Reported here: https://github.com/openstreetmap/openstreetmap-website/issues/6643

Comment from bmaczero on 23 December 2025 at 22:18

That’s a good idea, I had wondered if there was a way to filter on size in overpass but I didn’t think it would be so easy. Thanks!

I worked around the linking issue by adding some more whitespace.

Comment from mmd on 23 December 2025 at 22:37

I worked around the linking issue by adding some more whitespace.

Hmm, that’s not really ideal to get this bug fixed. The issue is still visible here now: https://master.apis.dev.openstreetmap.org/user/mmd2mod/diary/44

Comment from mmd on 23 December 2025 at 22:42

Overpass does not have a filter for area size. Using the way length is a kind of workaround, but it should be a good starting point for this particular use case.

Comment from bmaczero on 23 December 2025 at 22:48

Makes sense to have the repro case be a separate diary; thanks. I didn’t want users who looked at or tried to run the query to get confused.

Comment from Lejun on 24 December 2025 at 05:15

Any statistics about the common tennis pitches you encountered?

Related: * @SK53/diary/401423 * @SK53/diary/401423#comment54715 * @SK53/diary/401423#comment54779

Log in to leave a comment