reverse_geocode¶
reverse_geocode(latitude, longitude)
Description¶
Get address details at latitude
, longitude
using Google Maps
Usage¶
Call or Deploy reverse_geocode
?
Call reverse_geocode
directly
The easiest way to use bigfunctions
reverse_geocode
function is deployed in 39 public datasets for all of the 39 BigQuery regions.- It can be called by anyone. Just copy / paste examples below in your BigQuery console. It just works!
- (You need to use the dataset in the same region as your datasets otherwise you may have a function not found error)
Public BigFunctions Datasets
Region | Dataset |
---|---|
eu |
bigfunctions.eu |
us |
bigfunctions.us |
europe-west1 |
bigfunctions.europe_west1 |
asia-east1 |
bigfunctions.asia_east1 |
... | ... |
Deploy reverse_geocode
in your project
Why deploy?
- You may prefer to deploy
reverse_geocode
in your own project to build and manage your own catalog of functions. - This is particularly useful if you want to create private functions (for example calling your internal APIs).
- Get started by reading the framework page
Deployment
reverse_geocode
function can be deployed with:
pip install bigfunctions
bigfun get reverse_geocode
bigfun deploy reverse_geocode
Requirements
reverse_geocode
uses the following secrets. Get them by reading the documentation link and store them in Google Secret Manager in the project where you deploy the function (and give Accessor role to the service account of the function):
name | description | documentation to get the secret |
---|---|---|
gmaps_api_key |
Google Maps Api Key | doc |
Examples¶
select bigfunctions.eu.reverse_geocode(48.86988770000001, 2.3079341)
select bigfunctions.us.reverse_geocode(48.86988770000001, 2.3079341)
select bigfunctions.europe_west1.reverse_geocode(48.86988770000001, 2.3079341)
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| address_details |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| {
"address_components": [...],
"formatted_address": "1 Av. des Champs-Élysées, 75008 Paris, France",
"geometry": {
"location": {
"lat": 48.86988770000001,
"lng": 2.3079341
},
...
},
"place_id": "ChIJ6499V8Rv5kcR5f9dbz3OeBI",
"plus_code": {...},
"types": ["street_address"]
}
|
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Use cases¶
A delivery company has a database of orders with latitude and longitude coordinates of delivery locations. They want to enrich this data with more detailed address information for reporting, analysis, and customer service purposes.
They can use the reverse_geocode
function to get the full address details for each delivery location. For example, if they have a delivery location with latitude 48.86988770000001 and longitude 2.3079341, they can use the following query in BigQuery:
SELECT order_id, bigfunctions.eu.reverse_geocode(latitude, longitude) AS address_details
FROM `orders_table`
This will add a new column address_details
to the orders_table
containing the full address information for each order, including the formatted address, address components, place ID, and more. This information can then be used to:
- Improve reporting: Generate reports on deliveries by city, postal code, or other administrative area.
- Enhance analysis: Analyze delivery patterns and optimize routes based on address details.
- Improve customer service: Provide customer service representatives with accurate address information to resolve delivery issues.
- Data validation: Verify the accuracy of the provided latitude and longitude coordinates.
- Geocoding database cleanup: Identify and correct inaccurate or incomplete address information in their database.
Another use case could be for a real estate company that wants to analyze property values based on location details derived from latitude/longitude data. Or, a ride-sharing service might use this function to provide drivers with more detailed pickup/dropoff location information.
Need help or Found a bug?
Get help using reverse_geocode
The community can help! Engage the conversation on Slack
We also provide professional suppport.
Report a bug about reverse_geocode
If the function does not work as expected, please
- report a bug so that it can be improved.
- or open the discussion with the community on Slack.
We also provide professional suppport.