All posts

What Is Geocoding? Converting Addresses to Coordinates in Vietnam

What geocoding is, how forward and reverse geocoding differ, real-world uses in Vietnam, and how to call an API to turn addresses into latitude/longitude — with code examples.

If you've ever worked with maps, delivery, or address forms, you've run into the term geocoding. This post explains what geocoding is, the difference between forward and reverse geocoding, real-world uses in Vietnam, the specific challenges of Vietnamese addresses, and how to call an API with code examples.

What is geocoding?

Geocoding is the process of turning a text address into geographic coordinates — a pair of latitude and longitude numbers. For example:

"226 Vạn Phúc, Liễu Giai, Ba Đình, Hà Nội" → lat: 21.0345, lng: 105.8125

Coordinates are the language computers, maps, and routing algorithms understand. A text address is human-readable, but to plot a point on a map, compute distances, or find the nearest store, you need coordinates.

Forward vs reverse geocoding

There are two directions:

  • Forward geocoding: address → coordinates. (A user types an address; you need a point on the map.)
  • Reverse geocoding: coordinates → address. (You have a driver's/customer's GPS point and need to know which address/ward/district it is.)
InputOutputExample use
ForwardText addresslat/lng, placeIdCheckout form, address search
Reverselat/lng coordinatesAddress, ward/district/provinceDriver location, attaching orders to zones

An important variant of forward geocoding is autocomplete (suggest): suggesting addresses as the user types, helping them pick a normalized address instead of free-typing.

How does geocoding work?

A geocoding service typically:

  1. Normalizes & parses the input address string (house number, street, ward/commune, district, province/city).
  2. Matches it against an indexed address/map database (e.g. OpenStreetMap data).
  3. Ranks candidate results by match quality and context.
  4. Returns the best result with coordinates and an identifier (placeId).

The quality of steps (1) and (2) determines accuracy — and this is exactly where Vietnamese addresses create challenges.

Geocoding use cases in Vietnam

  • Delivery & logistics: turn order addresses into coordinates for routing, ETA estimation, and zone batching.
  • E-commerce: address autocomplete at checkout to reduce failed/incorrect deliveries.
  • CRM & data cleanup: attach coordinates + normalized ward/district to legacy customer lists.
  • Real estate: search by address and filter by administrative boundary.
  • Nearby search: "stores nearest me" needs coordinates for both the user and the stores.

The specific challenges of Vietnamese addresses

A "naive" geocoder built for international standards often stumbles in Vietnam:

  • Vietnamese diacritics: users type both accented and unaccented — "Hà Nội" and "Ha Noi" must both match.
  • Alleys (ngõ/hẻm): alley/lane numbering is highly specific; many global datasets miss it.
  • Name collisions: "Đường số 7" (Street No. 7) exists in dozens of HCMC wards → you need ward/district context to pick the right one.
  • Administrative renames: after the 2025 merger (down to 34 provinces), many wards/communes were renamed; old addresses still circulate.

This is why a geocoder tuned for Vietnam gives much better results than a generic global model.

Example: calling a geocoding API with GoGoDuk

GoGoDuk is a free, Vietnam-focused geocoding API. Forward geocoding via the suggest endpoint:

curl -H "X-API-Key: gdk_live_..." \
  "https://api.gogoduk.com/v1/suggest?input=Ho+Chi+Minh"
{
  "predictions": [
    {
      "placeId": "ChIJ0T2NLikpdTERKxE8d61aX_E",
      "text": "Ho Chi Minh City, Vietnam",
      "mainText": "Ho Chi Minh City",
      "secondaryText": "Vietnam",
      "types": ["locality", "political"]
    }
  ]
}

Reverse geocoding — from coordinates back to an address/area:

curl -H "X-API-Key: gdk_live_..." \
  "https://api.gogoduk.com/v1/reverse?lat=10.7769&lng=106.7009"

Need to know which province/district a point belongs to (by current boundaries)? Use:

curl -H "X-API-Key: gdk_live_..." \
  "https://api.gogoduk.com/v1/reverse-geocode?lat=21.03&lng=105.85"
{ "lat": 21.03, "lng": 105.85, "city": "Hà Nội", "district": "Đống Đa" }

Quick comparison of geocoding options in Vietnam

  • Google Maps Geocoding: globally accurate but costly and billing-restricted in Vietnam.
  • OpenStreetMap (Nominatim): free if self-hosted, but Vietnam coverage is community-dependent.
  • Goong/Vietmap: paid domestic services with good Vietnamese support.
  • GoGoDuk: free forever, tuned specifically for Vietnamese addresses, simple REST.

See the full comparison in Best Vietnam Map APIs in 2026. Want a deep dive into the hard cases of Vietnamese addresses? Read Geocoding Vietnamese addresses: edge cases.

Frequently asked questions

What's the difference between geocoding and reverse geocoding? Forward geocoding turns address → coordinates. Reverse geocoding does the opposite: coordinates → address/area.

What is a placeId? A stable identifier for a place. Use placeId to look up place details later without depending on an address string that may change.

Is geocoding free? It depends on the provider. GoGoDuk is free with 100 requests/day per account, no card. OpenStreetMap is free if you self-host.

Why are geocoding results sometimes wrong in Vietnam? Usually due to name collisions, alleys, Vietnamese diacritics, or datasets that haven't caught up with administrative renames. A Vietnam-tuned geocoder handles these cases better.

Get started

curl -H "X-API-Key: gdk_live_..." \
  "https://api.gogoduk.com/v1/suggest?input=Ben+Thanh"

Sign up for a free API key and read the docs for the full endpoint list. Questions? Email [email protected].

Want to use GoGoDuk?

Free forever — 100 requests/day per account, no credit card. Higher limits on request.

Sign up →