# Getting a list of IP addresses from a certain location radius

**URL:** <https://community.ipinfo.io/t/getting-a-list-of-ip-addresses-from-a-certain-location-radius/1581>\
**Category:** Integrations & Platforms\
**Tags:** ip-geolocation, snowflake, udtf, reverse-ip-lookup\
**Created:** [July 14, 2023, 10:51am UTC](https://community.ipinfo.io/t/getting-a-list-of-ip-addresses-from-a-certain-location-radius/1581 "2023-07-14T10:51:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abdullah](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.ipinfo.io/abdullah/32/4973_2.png) [@Abdullah](https://community.ipinfo.io/u/Abdullah)\
**Post date:** [July 14, 2023, 10:51am UTC](https://community.ipinfo.io/t/getting-a-list-of-ip-addresses-from-a-certain-location-radius/1581/1 "2023-07-14T10:51:14Z")

</div>

# Top 10 nearest IP addresses from a location → Haversine function and geo coordinate

 ![Location to IP lookup](https://canada1.discourse-cdn.com/flex035/uploads/ipinfo/original/2X/2/25c4d2ee431eeb83c45033fb4a35296d324ae85f.jpeg)

Using our [IP geolocation listing in Snowflake](https://app.snowflake.com/marketplace/listing/GZSTZ3VDMFI/) or our [IP geolocation database](https://ipinfo.io/products/ip-geolocation-database) in your preferred database solution, you can get a list of IP addresses that is around a specific a location.

This operation utilizes the [Haversine Formula](https://en.wikipedia.org/wiki/Haversine_formula) that measures the distance between the input geographic coordinate provided with our IP geolocation’s IP address ranges’ geographic coordinates. You can even provide a parameter that limits the maximum location delta.

Snowflake platform has a native `haversine` formula ([doc](https://docs.snowflake.com/en/sql-reference/functions/haversine)) that can be used with our [IP address to geolocation data](https://ipinfo.io/products/ip-geolocation-api) available on the [Snowflake marketplace](https://app.snowflake.com/marketplace/listing/GZSTZ3VDMFI/)

Random geographic coordinate input ⇒ `40.990, -100.713`

```sql
// 40.990 → Input latitude
// -100.713 → Input longitude

SELECT
  HAVERSINE(40.990, -100.713, loc.lat, loc.lng) as distance,
  loc.start_ip,
  loc.end_ip,
  loc.city,
  loc.region,
  loc.country,
  loc.postal,
  loc.timezone
FROM public.ip_geolocation loc
ORDER BY distance
LIMIT 10;

-----------------
-- Explanation --
-----------------

-- The haversine is a snowflake native function
-- You can pass in the geographic coordinate to generate the closest IPs to that point

```

Result:

 ![Top 10 nearest IP addresses from a location](https://canada1.discourse-cdn.com/flex035/uploads/ipinfo/original/2X/b/b152d82fc851f0ae2476a61acc5ec73055e1337b.png)

* * *

### Service referenced

- **IP to Geolocation data**
  - [Data downloads](https://ipinfo.io/products/ip-geolocation-database)
  - [Snowflake listing](https://app.snowflake.com/marketplace/listing/GZSTZ3VDMFI/)
  - API
