Skip to content

adanzweig/Python-GoogleGeoCoding

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Python Google Maps Geocoding API Connection

This Python project demonstrates how to connect to the Google Maps Geocoding API to retrieve geographical coordinates (latitude and longitude) for a specific address using the requests library. In this project, we provide a simple index.py file that fetches and displays the geocoding data for a predefined address.

Prerequisites

Before running this project, ensure you have the following:

  • Python installed on your system (at least Python 3.x).
  • A Google Cloud Platform (GCP) project with the Google Maps Geocoding API enabled.
  • An API key for the Google Maps Geocoding API. You can obtain one by following the Google Maps JavaScript API documentation.

Installation

  1. Clone or download this repository to your local machine.
git clone https://github.com/adanzweig/Python-GoogleGeoCoding.git
  1. Navigate to the project directory.
cd Python-GoogleGeoCoding
  1. Open the index.py file in your code editor.

  2. Replace APIKEY with your Google Maps Geocoding API key and "1600 Amphitheatre Parkway, Mountain View, CA" with the address you want to geocode.

api_key = "your_api_key_here"
address = "your_address_here"
  1. Save your changes.

Usage

To retrieve geographical coordinates for a specific address, follow these steps:

  1. Make sure you have set your API key and address in the index.py file as mentioned above.

  2. Run the project using Python:

python index.py
  1. The geocoding data for the specified address will be displayed in the console.

Example

Here's an example of what the output might look like in the console:

[
    {
        "address_components": [...],
        "formatted_address": "1600 Amphitheatre Parkway, Mountain View, CA 94043, USA",
        "geometry": {
            "location": {
                "lat": 37.423021,
                "lng": -122.083739
            },
            "location_type": "ROOFTOP",
            "viewport": {...}
        },
        "place_id": "ChIJ2eUgeAK6j4ARbn5u_wAGqWA",
        "plus_code": {...},
        "types": ["street_address"]
    }
]

License

This project is licensed under the MIT License. Feel free to use, modify, and distribute it as needed. See the LICENSE file for more details.

Acknowledgments

  • Geocoding data is provided by the Google Maps Geocoding API.
  • This project uses the requests library to make HTTP requests.

If you have any questions or encounter issues, please don't hesitate to reach out.

Happy coding!

About

Google Geocoding integration using Python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages