Aug 02, 2022 06:56 AM
Hey all -
My client has a list of city addresses. When the public completes certain applications, their neighbors within 400 feet need to be notified. Is there a way to use Google maps to queue the addresses (in our dataset) within 400 feet? We’d like these addresses to then be linked in a postcard table.
Data we have available to us:
Full address
Lat/Longitude
Thanks
Jake
Aug 02, 2022 09:53 AM
Hi @Jake_Lara1
There is a Map extension that will let you see all of your address’ on a map: https://support.airtable.com/hc/en-us/articles/115013405108-Map-app
I am sure there is an API that you can call to get this too, but this does sound like a fun math problem if you want to try, might need some scripting.
Aug 02, 2022 04:16 PM
Ahhhhh, location science. It’s the new thing. Welcome to the CyberLandr community, Jake!
Yes. Since measurements between points are required, you need to use a haversine algorithm. These can be easily coded in javascript (see below).
Here’s what you need…
Here’s what you do…
function distance(lat1, lon1, lat2, lon2, unit) {
if ((lat1 == lat2) && (lon1 == lon2)) {
return 0;
} else {
var radlat1 = Math.PI * lat1/180;
var radlat2 = Math.PI * lat2/180;
var theta = lon1-lon2;
var radtheta = Math.PI * theta/180;
var dist = Math.sin(radlat1) * Math.sin(radlat2) + Math.cos(radlat1) * Math.cos(radlat2) * Math.cos(radtheta);
if (dist > 1) {
dist = 1;
}
dist = Math.acos(dist);
dist = dist * 180/Math.PI;
dist = dist * 60 * 1.1515;
if (unit=="K") { dist = dist * 1.609344 }
if (unit=="N") { dist = dist * 0.8684 }
return dist;
}
}
Aug 02, 2022 04:25 PM
@Bill.French I had a feeling this was in your wheelhouse, which is why I stopped at calling it “a fun math problem” :slightly_smiling_face:
Aug 02, 2022 04:37 PM
Indeed - has some fun elements to it. When you see the first map showing the desired outcome, that’s pretty exciting. And I suspect there are other ways to get this done using Make or Zapier, but I tend to go straight for the solution that has no dependencies or possible added costs.
GeoEncoding addresses can get pricey, but I have found that a slow cache trickle is how to get millions of address locations without paying a dime. In this project, you could avoid encoding the entire data set of addresses and instead use the zip code of the source location to identify all locations with the same zip, then encode only those, and you’re ready to perform the geometry computations. This would make it possible to limit the encoding calls perhaps enough to stay in Google’s free encoding tier on a daily basis.
In fact, the distance test itself has no business running across the entire data set because homes that are 400 ft from the source location are almost never likely to have neighbours in a different zip code.
Aug 02, 2022 04:42 PM
Yep, this is exactly what I was thinking. How many address’ can there be within 400ft (then I remembered Condos and Apartments exist) but even in that scenario, ZIP should be plenty.
Aug 04, 2022 09:28 AM
Wow @Bill.French thank you I will test this next week!