# geocoding

## Description

<mark style="color:purple;">`geocoding`</mark> *adaptor converts location names in a datatable column to latitude and longitude in* [*decimal degrees*](https://en.wikipedia.org/wiki/Decimal_degrees)*.*

## Inputs

**`data`**\
Type: `datatable`\
Required: Yes\
The datatable containing the column to be converted.

**`location column`**\
Type: `text`\
Required: Yes\
The name of the column containing location names.

**`latitude column`**\
Type: `text`\
Required: No\
The column name for the latitude result. If unspecified, defaults to "latitude".

**`longitude column`**\
Type: `text`\
Required: No\
The column name for the longitude result. If unspecified, defaults to "longitude".

**`search area`**\
Type: `text`\
Required: No\
Restricts the search to the user-specified country/countries provided as comma-separated [ISO 3166-1 alpha-3](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3) country codes. For example: `CAN,MEX,USA`.

**`decimal places`**\
Type: `number`\
Required: No\
The number of digits to appear after the decimal point; should be a value between 0 and 6, inclusive. If unspecified, defaults to 6.

**`place type column`**\
Type: `text`\
Required: No\
The column name for the place type result (either `building`, `road`, `hamlet`, `village`, `neighbourhood`, `city`, `county`, `postcode`, `partial_postcode`, `terminated_postcode`, `postal_city`, `state_district`, `state`, `region`, `island`, `body_of_water`, `country`, `continent`, `fictitious`, or `unknown`). If unspecified, the type column will not be added.

## Outputs

**`data`**\
Type: `datatable`\
A datatable with the latitude & longitude values added.

## Examples

### Example 1: Default behaviour.

#### Inputs:

`data:`

| id | location                                                           |
| -- | ------------------------------------------------------------------ |
| 1  | Babraham Road, Sawston, CB22 3DQ, United Kingdom                   |
| 2  | 1330 Middle Avenue, Menlo Park, CA 94025, United States of America |
| 3  | United Kingdom                                                     |
| 4  | CB22 3DQ                                                           |
| 5  | Big Ben                                                            |

`location column:` location

`latitude column:` *null (empty)*

`longitude column:` *null (empty)*

`search area:` *null (empty)*

`decimal places:` 4

`place type column:` *null (empty)*

#### Outputs:

`data`:

| id | location                                                           | latitude | longitude |
| -- | ------------------------------------------------------------------ | -------- | --------- |
| 1  | Babraham Road, Sawston, CB22 3DQ, United Kingdom                   | 52.1270  | 0.1716    |
| 2  | 1330 Middle Avenue, Menlo Park, CA 94025, United States of America | 37.4397  | -122.1865 |
| 3  | United Kingdom                                                     | 54.7024  | -3.2766   |
| 4  | CB22 3DQ                                                           | 52.1270  | 0.1716    |
| 5  | Big Ben                                                            | 51.5007  | -0.1246   |

-> Converted location into latitude and longitude.

### Example 2: Geocoding with type column.

#### Inputs:

`data:`

| id | location                                                           |
| -- | ------------------------------------------------------------------ |
| 1  | Babraham Road, Sawston, CB22 3DQ, United Kingdom                   |
| 2  | 1330 Middle Avenue, Menlo Park, CA 94025, United States of America |
| 3  | United Kingdom                                                     |
| 4  | CB22 3DQ                                                           |
| 5  | Big Ben                                                            |

`location column:` location

`latitude column:` *null (empty)*

`longitude column:` *null (empty)*

`search area:` *null (empty)*

`decimal places:` 4

`place type column:` type

#### Outputs:

`data`:

| id | location                                                           | latitude | longitude | type       |
| -- | ------------------------------------------------------------------ | -------- | --------- | ---------- |
| 1  | Babraham Road, Sawston, CB22 3DQ, United Kingdom                   | 52.1270  | 0.1716    | postcode   |
| 2  | 1330 Middle Avenue, Menlo Park, CA 94025, United States of America | 37.4397  | -122.1865 | building   |
| 3  | United Kingdom                                                     | 54.7024  | -3.2766   | country    |
| 4  | CB22 3DQ                                                           | 52.1270  | 0.1716    | postcode   |
| 5  | Big Ben                                                            | 51.5007  | -0.1246   | attraction |

-> Converted location into latitude and longitude and provided the type for the geographical feature.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cgps.gitbook.io/data-flo/reference-guide/geocoding.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
