geolocationgeocodinggoogle-geocodergoogle-geocoding-apigeocode

What are the solutions when geocoding a wrong or incomplete address?


My company gets the addresses the loading hubs for our freights every week. We need to geocode them into coordinates. But often the addresses either are incomplete or contain minor grammar mistakes, so it's impossible to input them for geocoding.

My question : when dealing with a list of wrong or incomplete addresses when geocoding, is there any general solution to solve the issue ?

If there are useful articles or resources about this topic, please let me know.

Thank you.


Solution

  • Geocoding / Autocomplete

    According to the Geocoding Addresses Best Practices documentation:

    "Geocoding is the process of converting addresses (like a street address) into geographic coordinates (latitude and longitude), which you can use to place markers on a map, or position the map."

    "In general, use the Geocoding API when geocoding complete addresses (for example, “48 Pirrama Rd, Pyrmont, NSW, Australia”). Use the Places API Place Autocomplete service when geocoding ambiguous (incomplete) addresses."

    The Place Autocomplete service returns place predictions according to your inputs. This would solve your problem of having wrongly spelled addresses.

    How to get the coordinates after using Place Autocomplete?

    example request for Place Autocomplete would look like this:

    https://maps.googleapis.com/maps/api/place/autocomplete/json?input=Paris&types=geocode&key=YOUR_API_KEY
    

    The Place Autocomplete is able to return the address description together with its place_id. In this sample request, you are able to get "description": "Paris, France" with a "place_id": "ChIJD7fiBh9u5kcRYJSMaMOCCwQ".

    Then you can use the Place ID of the predicted location to obtain the coordinates of that place by using Place Details request

    You can request it like this:

    https://maps.googleapis.com/maps/api/place/details/json?fields=geometry&place_id=ChIJD7fiBh9u5kcRYJSMaMOCCwQ&key=YOUR_API_KEY
    

    We used here the fields=geometry to only return the coordinates of the location and as previously mentioned the Place ID we used is the one we had from the Autocomplete query.

    The returned data will be the expected result according to your question. But feel free to comment if you need anything.

    To read more about the fields parameter, refer to the Place Details documentation.

    I hope this helps!