faker.providers.geo
¶
-
class
faker.providers.geo.
Provider
(generator: Any)¶ Bases:
faker.providers.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: Optional[float] = None, radius: Union[float, int] = 0.001) → decimal.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.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, 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) → Optional[Tuple[str, ...]]¶ 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() ... ('46.09273', '-88.64235', 'Iron River', 'US', 'America/Menominee') ('31.28092', '74.85849', 'Patti', 'IN', 'Asia/Kolkata') ('46.65581', '32.6178', 'Kherson', 'UA', 'Europe/Kiev') ('32.9156', '-117.14392', 'Mira Mesa', 'US', 'America/Los_Angeles') ('15.45144', '78.14797', 'Betamcherla', 'IN', 'Asia/Kolkata')
-
longitude
() → decimal.Decimal¶ Examples: >>> Faker.seed(0) >>> for _ in range(5): ... fake.longitude() ... Decimal('26.826999') Decimal('45.792650') Decimal('-158.265114') Decimal('-40.995129') Decimal('94.488524')
-