Total miles in a city idea

As noted in other posts, you just have to add up the aggregate distance between nodes. Obviously, keeping the segments separate where streets are disjoint (extreme example: Cape Coral, Florida, USA). If you’ve run both endpoints of a line segment, the distance “counts” towards the distance run on that street. The fact that OSM may not be accurate in some cases is not a good argument against doing this. Eventually OSM will get updated and this “update city data” code that you’re writing someday in theory will update the street distances.

1 Like

So it looks like the Overpass API introduced a “length()” operator in v0.7.55: Overpass API/Overpass QL - OpenStreetMap Wiki

I tried this in Overpass Turbo:

way(id:231833288);
make stat length=sum(length());
out;

Which results in:

  <stat id="1">
    <tag k="length" v="639.163"/>
  </stat>

The way on OSM: Way: ‪Muinkkaai‬ (‪231833288‬) | OpenStreetMap
The street on CS: Muinkkaai in Gent, Vlaanderen - CityStrides

Measuring this street in Google Maps: Total distance: 696.53 m (2,285.19 ft)

3 Likes

I wonder if that can be included in the Street Query I’m using… Otherwise, I’d have to run that length query against each individual street :flushed:

1 Like

Would that also help in identifying duplicate streets? If you had two streets with the same name and same non-zero distance…just a random thought. Would definitely be exciting to incorporate distance measurements in various aspects of the site.

1 Like

If I understand what you’re referring to…
That issue isn’t that the streets are duplicate, it’s that there are encompassing cities that exist. So the streets in smaller-city-A also exist in larger-city-B.
If I de-duplicated those streets by removing the streets from smaller-city-A then that city would have no streets & if I de-duplicated them by removing them from larger-city-B then that city wouldn’t have a complete list of all the streets it contains.

I’m not saying they shouldn’t exist in any capacity, but they seem to count double (or triple or quadruple) in challenges, leaderboards and I assume my total road count. It sort of makes those numbers largely meaningless if in some places you run a road and it counts 4 times.
I assume as it stands you have multiple “Street A”'s that are really the same street but with different street_ids instead of just one “Street A” that you associate to multiple towns with some sort of completed flag. Anyways I have no idea how your database is setup (just a guess) and I’m sure you’re better at it than me, but basically contrasting the two setups below. Both setups allow for “Street A” to belong to more than one city but one setup doesn’t duplicate roads.

Do you actually know what smaller cities exist in larger cities? Is that relationship stored or easily figured out? I would assume that would let you dedupe, but if not then something like street length might assist

streets
street_name, street_id, completed
“Street A”, 1, false

cities
city_name, city_id
“City A”, 1
“City B”, 2
“City B”, 3

city_streets
city_id, street_id
1, 1
2, 1
3, 1


streets
street_name, street_id, completed
“Street A”, 1, false
“Street A”, 2, false
“Street A”, 3, false

cities
city_name, city_id
“City A”, 1
“City B”, 2
“City B”, 3

city_streets
city_id, street_id
1, 1
2, 2
3, 3

Yeah, that seems to be possible, adapted from your Street Query: overpass turbo
In this small town: Cadix, Occitanie - CityStrides

"number": "3",
"length": "2903.196"

Which seems correct, 2 roads and a bridge with a total length of 2.9 km.

To get each street length, you could use something like this: overpass turbo

I think the problem of duplicate streets comes from having “cities” that overlap geographically, so that one real street is present in both City A and City B. If you run the street it will count as +1 in City A and in City B. For example, Albany St. in Manhattan will count in Manhattan and in Manhattan Community Board 1.

1 Like

I think in that case maybe it makes sense to duplicate the road in some fashion. That would definitely be a tricky situation. I’m not sure about other places but at least here this is a smaller percentage of cases. Those border roads are usually not more than a half dozen or so per town and sometimes it makes me run the whole road past the town to get it and sometimes not.

One possible solution (Guessing at db table design) but you could put the “complete” flag on city_streets relationship table which would denote the road being done for a specific city and then another flag on the streets table to denote complete for all cities. I’m sure James data and design is much more complex than my simplistic thoughts here but having a solution to duplicates would certainly bolster several of the existing features which are really muddied by it. Also apologies for muddying this thread, I’m sure there is a duplicates thread somewhere.

1 Like

As I’m getting closer to the “edges” of my city, I have been wondering what I’m going to do about this very thing.

Johnson Road is not too bad… It should end at Pearson to the east, but doesn’t.

But I’m dreading North Tarrant Parkway. It should “end” at S. Main / Denton Hwy. My city, Keller, is east of S. Main / Denton Hwy.

Should these situations be fixed in OSM, for posterity and future Striders?

Thanks, Eric

That the nodes of the street extends beyond the city border in CS is a bug that was identified after the global update which will be fixed when the OSM data is updated in the future.

As to how this affects the overlapping cities issue, I don’t know.

1 Like

Personally, my running routes are (generally) staying within the city boundaries until I run out of streets to run. Then I’ll extend past them.

So I’m in a race with City Strides. Will I complete all the streets in the city before City Strides updates the database? The nice thing is that there is no loser. I’m still running, and I’m staying healthy.

5 Likes

Voted!

If this idea happens, then maybe this one could too: Display length of streets on city page

1 Like

As an aside, many cities and counties have their planning / surveying department measure the total distance of streets, roads, etc within their city/county boundary. That wouldn’t help CS but wanted to get that information out their in case folks want to know that number right away. It may take some digging through your city/county government website to find. You may also find your city/county have some really cool maps and other resources.

The information that the cities have is questionable. We’ve been looking at that data at my job in order to come up with a more equitable revenue sharing formula. It turns out there’s little data checking done by the cities.

This only was noticed when we noticed that roads are claimed by multiple jurisdictions, when the total lane miles was substantially less than twice the total length of the roads, etc.

The theory is good. But in practice?

Is it possible via the Openstreetmap API to get the total distance of all the streets in a given city? I think this would be a useful thing to see but don’t currently see it. I am currently working on three cities, and they have similar numbers of streets but I suspect the distances involved are very different.

Believe so. See How many kms does my city have? thread.

Also some discussion in Total miles in a city idea

So in case anyone (in this thread) missed it, this information is now on each city page. Don’t know when it showed up, but I bet it’s in the Announcements - CityStrides Community forum.

Now it would be cool to see how many actual miles it took to complete a city.

2 Likes

A post was split to a new topic: Efficiency Score based on miles in a city & miles run