Google Geocoding #7078

Closed
opened 2025-12-29 20:18:58 +01:00 by adam · 3 comments
Owner

Originally created by @wirestar on GitHub (Oct 5, 2022).

NetBox version

v3.2.3

Feature type

New functionality

Proposed functionality

It would be nice if Netbox could integrate with Google' Geocoding service to grab the GPS coordinates for an address that was inputted into the add new site page. Alternative Geocoding engines could be used, but Google seems the most popular.

Use case

We adding multiple sites, its time consuming to manually lookup the GPS location for each of them. Google's Geocoding API can automate this, and return the Latitude and Longitude for an address.

Database changes

You might have to change the latitude and longitude fields to allow more than 6 decimal places depending on what Google returns.

External dependencies

https://developers.google.com/maps/documentation/geocoding/overview There would have to be a place for the admin to enter the Google API credentials.

Originally created by @wirestar on GitHub (Oct 5, 2022). ### NetBox version v3.2.3 ### Feature type New functionality ### Proposed functionality It would be nice if Netbox could integrate with Google' Geocoding service to grab the GPS coordinates for an address that was inputted into the add new site page. Alternative Geocoding engines could be used, but Google seems the most popular. ### Use case We adding multiple sites, its time consuming to manually lookup the GPS location for each of them. Google's Geocoding API can automate this, and return the Latitude and Longitude for an address. ### Database changes You might have to change the latitude and longitude fields to allow more than 6 decimal places depending on what Google returns. ### External dependencies https://developers.google.com/maps/documentation/geocoding/overview There would have to be a place for the admin to enter the Google API credentials.
adam added the type: feature label 2025-12-29 20:18:58 +01:00
adam closed this issue 2025-12-29 20:18:58 +01:00
Author
Owner

@shatt79 commented on GitHub (Oct 6, 2022):

https://github.com/netbox-community/reports/blob/master/scripts/geolocate_site.py

There's a script that does exactly what you're wanting. OSM seems to be the most reliable geocoder. There is a small issue with the script....

Lines 17 and 32 need to be changed to:

  1. region = ObjectVar(model=Region)
  2. location = ObjectVar(model=Site)

And line 51 needs to be moved (inserted) after line 48. The full_clean() validator doesn't seem to work when it's in the 51 position.

I actually did this yesterday in our environment and it worked flawlessly after changing the above. You can run the script on a single site or against all sites.

image

I tried messing around with it by changing the geocoder from OSM to other providers (like Google) and I had issues. I ran the script against 4600+ sites and Google failed on more than 80%. OSM was perfect.

@shatt79 commented on GitHub (Oct 6, 2022): https://github.com/netbox-community/reports/blob/master/scripts/geolocate_site.py There's a script that does exactly what you're wanting. OSM seems to be the most reliable geocoder. There is a small issue with the script.... Lines 17 and 32 need to be changed to: 17. region = ObjectVar(model=Region) 32. location = ObjectVar(model=Site) And line 51 needs to be moved (inserted) after line 48. The full_clean() validator doesn't seem to work when it's in the 51 position. I actually did this yesterday in our environment and it worked flawlessly after changing the above. You can run the script on a single site or against all sites. ![image](https://user-images.githubusercontent.com/103387334/194171878-c8bcac75-4504-4210-b85e-199338ba846d.png) I tried messing around with it by changing the geocoder from OSM to other providers (like Google) and I had issues. I ran the script against 4600+ sites and Google failed on more than 80%. OSM was perfect.
Author
Owner

@wirestar commented on GitHub (Oct 6, 2022):

Thanks for letting me know. Is it possible to update the script with these changes in github?

@wirestar commented on GitHub (Oct 6, 2022): Thanks for letting me know. Is it possible to update the script with these changes in github?
Author
Owner

@ryanmerolle commented on GitHub (Oct 22, 2022):

Thanks for letting me know. Is it possible to update the script with these changes in github?

@wirestar & @shatt79

I merged the updated script / PR from @shatt79 . I also updated the script to include "All sites for a site group"

As such, I am closing this issue.

@ryanmerolle commented on GitHub (Oct 22, 2022): > Thanks for letting me know. Is it possible to update the script with these changes in github? @wirestar & @shatt79 I merged the updated script / PR from @shatt79 . I also updated the script to include "All sites for a site group" As such, I am closing this issue.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#7078