- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How to specify the range of longitude and latitude
Use iplocation or geostats to display within a range of 100 kilometers (with longitude of 0.89 degrees and latitude of 0.91 degrees) which regions' people have logged in, the login time, IP address, and the login method.
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you all for your timely reply. Sorry, it might be difficult to understand because the scope was not specified specifically
May I ask how to write SPL within the following range?
Latitude: From 35.5 degrees north latitude to 36.0 degrees north latitude
Longitude: From 139.5 degrees east longitude to 140.0 degrees
I wrote some content but an error occurred
index=xxxxx
| table FROM_IP
| iplocation FROM_IP
| where latitude >= 35.5 AND latitude <= 36.0
| where longitude >= 139.5 AND longitude <= 140
Thanks
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi @Zhangyy
This should give you approx 25km in each direction as you've explaine:
| where lat>=35.5 AND lat<=36.0 AND lon>=139.5 AND lon<=140.0
🌟 Did this answer help you? If so, please consider:
- Adding karma to show it was useful
- Marking it as the solution if it resolved your issue
- Commenting if you need any clarification
Your feedback encourages the volunteers in this community to continue contributing
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content


- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi @Zhangyy
You could try the following:
| iplocation yourIPField
| where abs(lon - 0.89) <= (100/111) AND abs(lat - 0.91) <= (100/111)
This checks if a point with coordinates (lon, lat) is within a rectangular area centered at (0.89, 0.91) with a "radius" of approximately 0.9009 degrees in both the longitude and latitude directions. This rectangle is approximately 100 kilometers wide and 100 kilometers tall, assuming a rough conversion of 1 degree of latitude to 111 kilometers.
🌟 Did this answer help you? If so, please consider:
- Adding karma to show it was useful
- Marking it as the solution if it resolved your issue
- Commenting if you need any clarification
Your feedback encourages the volunteers in this community to continue contributing
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Not entirely sure what you're trying to do, but this is a macro for the haversine formula
eval hv_rlat1 = pi()*$dest_lat$/180, hv_rlat2=pi()*$source_lat$/180, hv_rlat = pi()*($source_lat$-$dest_lat$)/180, hv_rlon= pi()*($source_lon$-$dest_lon$)/180
| eval hv_a = sin(hv_rlat/2) * sin(hv_rlat/2) + cos(hv_rlat1) * cos(hv_rlat2) * sin(hv_rlon/2) * sin(hv_rlon/2)
| eval hv_c = 2 * atan2(sqrt(hv_a), sqrt(1-hv_a))
| eval distance = round(6371 * hv_c * 1000,0)
| fields - hv_rlat, hv_rlat1, hv_rlon, hv_rlon1, hv_a, hv_c
Set it up to take 4 parameters and these are the named params
source_lat, source_lon, dest_lat, dest_lon
Then you can just use
`haversine(a_lat, a_lon, b_lat, b_lon)`
to get the distance between two points
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content


Hi @Zhangyy ,
latitude and longitude are numbers, so you can use the greater than (>) and less than (<) operators in your searches.
Ciao.
Giuseppe
