# ＊ 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="https://2225246359-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVGX92M819eIp0rMg5elc%2Fuploads%2FWozHTGnWKGFntiV45WxO%2Frdt_transformers-glossary-deep-data-understanding-gps-coordinates-random-location-generator_June%2002%202025.png?alt=media&#x26;token=58c5a7a2-171c-4161-94ae-eae1828ca4ba" 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](https://docs.sdv.dev/rdt/transformers-glossary/deep-data-understanding/gps-coordinates/gpsnoiser) or [MetroAreaAnonymizer](https://docs.sdv.dev/rdt/transformers-glossary/deep-data-understanding/gps-coordinates/metroareaanonymizer).

</details>

*Worldwide, regional data is provided by* [*www.geonames.org*](https://www.geonames.org)*.*
