> For the complete documentation index, see [llms.txt](https://docs.sdv.dev/rdt/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sdv.dev/rdt/transformers-glossary/deep-data-understanding/gps-coordinates/randomlocationgenerator.md).

# ＊ RandomLocationGenerator

{% hint style="info" %}
**＊SDV Enterprise Feature.** This feature is available to our licensed users and is not currently in our public library. For more information, visit our page to [Explore SDV](https://docs.sdv.dev/sdv/explore/sdv-enterprise/compare-features).
{% endhint %}

The `RandomLocationGenerator` creates realistic GPS coordinates from a list of countries. It transforms the real data by dropping all the GPS-related columns. Then when reverse transforming, it generates random, realistic coordinates from around the world. Use this transformer when you want to completely anonymize your coordinates.

<figure><img src="/files/pUrQkNn9gHxcjG4o7cdV" alt=""><figcaption></figcaption></figure>

```python
from rdt.transformers.gps import RandomLocationGenerator

transformer = RandomLocationGenerator(
    locales=['en_US', 'fr_CA'],
    missing_value_generation='random')
```

## Parameters

**`locales`**: An optional list of locales to use when generating GPS coordinates. All coordinates will be chosen from the list of available countries

<table data-header-hidden><thead><tr><th width="211.5"></th><th></th></tr></thead><tbody><tr><td>(default) <code>["en_US"]</code></td><td>Create locations from the US</td></tr><tr><td><code>&#x3C;list></code></td><td>Create data from the list of countries specified <br><br>For example <code>[</code><a href="https://faker.readthedocs.io/en/master/locales/en_US.html"><code>"en_US"</code></a><code>,</code> <a href="https://faker.readthedocs.io/en/master/locales/fr_CA.html"><code>"fr_CA"</code></a><code>]</code> creates a mix of locations from the US and from Canada.</td></tr></tbody></table>

**`missing_value_generation`**: Add this argument to determine how to recreate missing values during the reverse transform phase

<table data-header-hidden><thead><tr><th width="203"></th><th></th></tr></thead><tbody><tr><td>(default) <code>'random'</code></td><td>Randomly assign missing values in roughly the same proportion as the original data.</td></tr><tr><td><code>None</code></td><td>Do not recreate missing values.</td></tr></tbody></table>

## Examples

{% hint style="info" %}
**This transformer takes exactly 2 columns as input.** Make sure that you have 1 column with sdtype `latitude` and 1 column with sdtype `longitude`.
{% endhint %}

```python
from rdt.transformers.gps import RandomLocationGenerator

transformer = RandomLocationGenerator(
    locales=['en_US', 'fr_CA'],
    missing_value_generation='random'
)

# in the hypertransformer, ensure that each column has a supported sdtype
ht.update_sdtypes(column_name_to_sdtype={
    'user_lat': 'latitude',
    'user_lon': 'longitude',
})

# in the hypertransformer, assign set of columns to your transformer
ht.update_transformers(column_name_to_transformer={
    ('user_lat', 'user_lon'): transformer
})
```

## FAQs

<details>

<summary>Can I limit the regions to the ones in my original data?</summary>

This transformer is designed to create random coordinates from anywhere in the countries that you provide. For example, if you provide `'en_US'`, then the transformer will create GPS coordinates from anywhere in the US such as California, New York, Massachusetts, etc. -- even if your original data did not have all these locations.

If you'd like to limit the regions based on the original data, use the [GPSNoiser](/rdt/transformers-glossary/deep-data-understanding/gps-coordinates/gpsnoiser.md) or [MetroAreaAnonymizer](/rdt/transformers-glossary/deep-data-understanding/gps-coordinates/metroareaanonymizer.md).

</details>

*Worldwide, regional data is provided by* [*www.geonames.org*](https://docs.sdv.dev/rdt/transformers-glossary/deep-data-understanding/gps-coordinates/www.geonames.org)*.*


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.sdv.dev/rdt/transformers-glossary/deep-data-understanding/gps-coordinates/randomlocationgenerator.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
