These don't seem to be partial_matches
so I'm wondering why it's not bringing back all the data, specifically the postal_code
.
From double checking on google maps, this is the exact address I want. In other words it's a direct hit.
Python code:
address = '34 new street, Green road, Carlow'
geocode_url = "https://maps.googleapis.com/maps/api/geocode/json?address={}&key={}".format(address,api_key)
# Ping google for the reuslts:
results = requests.get(geocode_url)
# Results will be in JSON format - convert to dict using requests functionality
results = results.json()
And the results. There should be a postal_code
data here, right? There's nothing to say that it was only a partial match.
{'results': [{'address_components': [{'long_name': '34',
'short_name': '34',
'types': ['street_number']},
{'long_name': 'New Street', 'short_name': 'New St', 'types': ['route']},
{'long_name': 'Moanacurragh',
'short_name': 'Moanacurragh',
'types': ['neighborhood', 'political']},
{'long_name': 'Carlow',
'short_name': 'Carlow',
'types': ['locality', 'political']},
{'long_name': 'County Carlow',
'short_name': 'County Carlow',
'types': ['administrative_area_level_1', 'political']},
{'long_name': 'Ireland',
'short_name': 'IE',
'types': ['country', 'political']}],
'formatted_address': '34 New St, Moanacurragh, Carlow, Ireland',
'geometry': {'location': {'lat': 52.8296466, 'lng': -6.9331115},
'location_type': 'RANGE_INTERPOLATED',
'viewport': {'northeast': {'lat': 52.83099558029149,
'lng': -6.931762519708498},
'southwest': {'lat': 52.82829761970849, 'lng': -6.934460480291502}}},
'place_id': 'EhozNCBOZXcgU3QsIENhcmxvdywgSXJlbGFuZCIaEhgKFAoSCZ93HqizQl1IEZZMDB0YIkdXECI',
'types': ['street_address']}],
'status': 'OK'}
Now if I enter the exact same string into the official zipcode database (Ireland) it returns the zipcode.
Official database is here by the way, you can try the address string '34 new street, Green road, Carlow'
There are two points you should be aware regarding the sample request for '34 new street, Green road, Carlow'.
As you can see, the result has a RANGE_INTERPOLATED
location type, not the ROOFTOP
. That means Google doesn't have an exact address in their database and they tried to guess (interpolate) the position of the address based on other existing features.
If you execute the reverse geocoding request for the interpolated point (52.8296466,-6.9331115) and location type postal code https://maps.googleapis.com/maps/api/geocode/json?latlng=52.8296466%2C-6.9331115&result_type=postal_code&key=YOUR_API_KEY
you will get the following response
{ "plus_code":{ "compound_code":"R3H8+VQ Carlow, County Carlow, Ireland", "global_code":"9C4MR3H8+VQ" }, "results":[ ], "status":"ZERO_RESULTS" }
So, in Google database there is no postal code polygon that contains point (52.8296466,-6.9331115). You are facing a data issue on Google side.
I would suggest reaching out to the Google data team and report the data issue as described in their help center:
https://support.google.com/maps/answer/6320846
Hopefully Google can fix it soon.