faker.providers.geo
¶
- class faker.providers.geo.Provider(generator: Any)¶
Bases:
BaseProvider
land_coords data extracted from geonames.org, under the Creative Commons Attribution 3.0 License. Coordinates are in decimal format for mapping purposes. Country code is in Alpha 2 format (https://www.nationsonline.org/oneworld/country_code_list.htm). Timezones are canonical (https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
- coordinate(center: float | None = None, radius: float | int = 0.001) Decimal ¶
Optionally center the coord and pick a point within radius.
- Examples:
>>> Faker.seed(0) >>> for _ in range(5): ... fake.coordinate() ... Decimal('26.826999') Decimal('45.792650') Decimal('-158.265114') Decimal('-40.995129') Decimal('94.488524')
- latitude() Decimal ¶
- Examples:
>>> Faker.seed(0) >>> for _ in range(5): ... fake.latitude() ... Decimal('13.4134995') Decimal('22.896325') Decimal('-79.132557') Decimal('-20.4975645') Decimal('47.244262')
- latlng() Tuple[Decimal, Decimal] ¶
- Examples:
>>> Faker.seed(0) >>> for _ in range(5): ... fake.latlng() ... (Decimal('13.4134995'), Decimal('45.792650')) (Decimal('-79.132557'), Decimal('-40.995129')) (Decimal('47.244262'), Decimal('80.880444')) (Decimal('18.6986795'), Decimal('-17.160223')) (Decimal('37.935520'), Decimal('12.226293'))
- local_latlng(country_code: str = 'US', coords_only: bool = False) Tuple[str, ...] | None ¶
Returns a location known to exist on land in a country specified by country_code. Defaults to ‘en_US’. See the land_coords list for available locations/countries.
- Examples:
>>> Faker.seed(0) >>> for _ in range(5): ... fake.local_latlng() ... ('40.72371', '-73.95097', 'Greenpoint', 'US', 'America/New_York') ('41.48199', '-81.79819', 'Lakewood', 'US', 'America/New_York') ('30.17746', '-81.38758', 'Palm Valley', 'US', 'America/New_York') ('41.72059', '-87.70172', 'Evergreen Park', 'US', 'America/Chicago') ('33.93113', '-117.54866', 'Norco', 'US', 'America/Los_Angeles')
- location_on_land(coords_only: bool = False) Tuple[str, ...] ¶
Returns a random tuple specifying a coordinate set guaranteed to exist on land. Format is (latitude, longitude, place name, two-letter country code, timezone) Pass coords_only to return coordinates without metadata.
- Examples:
>>> Faker.seed(0) >>> for _ in range(5): ... fake.location_on_land() ... ('40.56754', '-89.64066', 'Pekin', 'US', 'America/Chicago') ('25.13915', '73.06784', 'Sheoganj', 'IN', 'Asia/Kolkata') ('-7.60361', '37.00438', 'Kidodi', 'TZ', 'Africa/Dar_es_Salaam') ('33.35283', '-111.78903', 'Gilbert', 'US', 'America/Phoenix') ('17.54907', '82.85749', 'Elamanchili', 'IN', 'Asia/Kolkata')