* RandomLocationGenerator

*SDV Enterprise Feature. This feature is available to our licensed users and is not currently in our public library. To learn more about the SDV Enterprise and its extra features, visit our website.

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.

from rdt.transformers.gps import RandomLocationGenerator

transformer = RandomLocationGenerator(
    locales=['en_US', 'fr_CA'],


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

(default) ["en_US"]

Create locations from the US


Create data from the list of countries specified For example ["en_US", "fr_CA"] creates a mix of locations from the US and from Canada.

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

(default) 'random'

Randomly assign missing values in roughly the same proportion as the original data.


Do not recreate missing values.


This transformer takes exactly 2 columns as input. Make sure that you have 1 column with sdtype latitude and 1 column with sdtype longitude.

from rdt.transformers.gps import RandomLocationGenerator

transformer = RandomLocationGenerator(
    locales=['en_US', 'fr_CA'],

# in the hypertransformer, ensure that each column has a supported sdtype
    'user_lat': 'latitude',
    'user_lon': 'longitude',

# in the hypertransformer, assign set of columns to your transformer
    ('user_lat', 'user_lon'): transformer


Can I limit the regions to the ones in my original data?

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 or MetroAreaAnonymizer.

Worldwide, regional data is provided by www.geonames.org.

Last updated