# Geodata Converter (KML, GPX, Shapefile, WKT) API

> Convert KML, KMZ, GPX, zipped Shapefiles, WKT / WKB and CSV to GeoJSON and back, with simplification and reprojection (UTM, Web Mercator, VN-2000).

- Endpoint: `POST https://apibox.io.vn/v1/geo-convert`
- Category: Files
- HTML docs: https://apibox.io.vn/docs/geo-convert/ (Vietnamese: https://apibox.io.vn/vi/docs/geo-convert/)
- Online tool: https://apibox.io.vn/tools/geo-convert/
- Authentication: `Authorization: Bearer <API key>` or `X-API-Key: <API key>` (free key: https://apibox.io.vn/dashboard/#signup)

Send the data as a `file` (KML, KMZ, GPX, Shapefile .zip with .shp / .dbf / .prj / .cpg, CSV, WKT, WKB, GeoJSON) or as `data` text; the format is detected or set with `from`. KML / KMZ placemarks keep their name, description and ExtendedData; GPX waypoints, routes and tracks (elevation and times) are read; Shapefiles are reprojected from their .prj to WGS84 and decoded with the .cpg code page; CSV needs lat / lon columns (also “vĩ độ” / “kinh độ”, or set `lat_column` / `lon_column`) or a WKT column; WKT and hex / base64 WKB (EWKB with SRID, Z) are one geometry per line.

`to` chooses the output: `geojson` (default, as an object), `kml`, `gpx` (polygons become tracks of their outer ring), `csv` (lat / lon for points, otherwise a WKT column), `wkt` or `wkb` (hex). `simplify` applies Douglas–Peucker with a tolerance in metres, `precision` rounds coordinates. Reproject with `from_crs` / `to_crs`: EPSG:4326, EPSG:3857, UTM (EPSG:326xx / 327xx), VN-2000 UTM (EPSG:3405 / 3406) and VN-2000 TM-3 as `vn2000:<central meridian>` (e.g. `vn2000:105.5` for Hà Nội) with the national 7-parameter transformation (same as /v1/vn-vn2000), or any proj4 string / WKT.

The response gives the feature count, geometry types, coordinate count before / after simplification and the bbox; `download=true` returns the file itself.

## Parameters

| Name | In | Type | Required | Default | Description |
|---|---|---|---|---|---|
| `file` | body | file | no |  | Input file (KML, KMZ, GPX, Shapefile .zip, CSV, WKT, WKB, GeoJSON). |
| `data` | body | string | no |  | Input as text (KML, GPX, GeoJSON, WKT, hex WKB, CSV). |
| `from` | body|query | string | no |  | Input format: `geojson`, `kml`, `kmz`, `gpx`, `shp`, `wkt`, `wkb`, `csv` (auto-detected). |
| `to` | body|query | string | no | `geojson` | Output: `geojson`, `kml`, `gpx`, `csv`, `wkt`, `wkb`. |
| `from_crs` | body|query | string | no |  | Source CRS when the data is not WGS84 lon/lat (EPSG code, `vn2000:105.5`, proj4 or WKT). |
| `to_crs` | body|query | string | no |  | Target CRS (default EPSG:4326). |
| `simplify` | body|query | number | no |  | Douglas–Peucker tolerance in metres (lon/lat output). |
| `precision` | body|query | number | no |  | Decimals kept (default 7 for degrees, 3 for metres). |
| `download` | body|query | boolean | no | `false` | Return the converted file instead of JSON. |

## Example request

```bash
curl -X POST "https://apibox.io.vn/v1/geo-convert" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"data":"<kml xmlns=\"http://www.opengis.net/kml/2.2\"><Document><Placemark><name>Hồ Gươm</name><Point><coordinates>105.8523,21.0288</coordinates></Point></Placemark></Document></kml>","to_crs":"vn2000:105.5"}'
```

## Example response

```json
{
  "from": "kml",
  "to": "geojson",
  "crs": "vn2000:105.5",
  "features": 1,
  "geometry_types": {
    "Point": 1
  },
  "coordinates": {
    "before": 1,
    "after": 1
  },
  "bbox": [
    536422.326,
    2326182.02,
    536422.326,
    2326182.02
  ],
  "warnings": [],
  "geojson": {
    "type": "FeatureCollection",
    "features": [
      {
        "type": "Feature",
        "geometry": {
          "type": "Point",
          "coordinates": [
            536422.326,
            2326182.02
          ]
        },
        "properties": {
          "name": "Hồ Gươm"
        }
      }
    ]
  }
}
```

## Use cases

- Load Google My Maps / Google Earth KML or KMZ into a web map as GeoJSON
- Convert cadastral or planning Shapefiles (VN-2000) to WGS84 for web apps
- Turn a Strava / GPS track (GPX) into GeoJSON or KML
- Import spreadsheet points (lat / lon columns) into a GIS or map

## FAQ

### Which coordinate system is the output?

WGS84 longitude / latitude by default. Set to_crs (for example EPSG:3857 or vn2000:105.5) for projected output.

### My Shapefile has no .prj, what now?

Coordinates are returned as stored; set from_crs (for example vn2000:105.5 or EPSG:32648) to reproject them.

### Are TCVN3 (ABC) encoded attributes supported?

Code pages declared in the .cpg (UTF-8, Windows-1258, …) are decoded; legacy TCVN3 font encodings are not converted.
