symerio / pgeocode

Postal code geocoding and distance calculation
https://pgeocode.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
238 stars 58 forks source link

Find cities at a specific distance #57

Closed datapolitical closed 6 months ago

datapolitical commented 2 years ago

Given a location and a distance, what's the right way to find populated places that are exactly that distance from the location?

I don't want to search for everything inside a circle, just what is on its perimeter.

Thanks!

rth commented 6 months ago

You could query cities within radius R, those within radius R-epsilon and do the difference between the two sets. Not that with float comparison exact equality doesn't really make sense, so you would need to pick some reasonable value for eplison, of a a few km at least probably.

Don't hestiate to comment futher, if this doesn't work.