python - how to map latitude/longitude to a specific US county? -
i have dataframe containing u.s. latitude
, longitude
coordinates.
i create variable shows respective u.s. county includes these coordinates.
how can in r/python?
thanks!
you use geopy.
example documentation using nominatim (open street map):
>>> geopy.geocoders import nominatim >>> geolocator = nominatim() >>> location = geolocator.reverse("52.509669, 13.376294") >>> print(location.address) potsdamer platz, mitte, berlin, 10117, deutschland, european union >>> print((location.latitude, location.longitude)) (52.5094982, 13.3765983) >>> print(location.raw) {'place_id': '654513', 'osm_type': 'node', ...}
the raw output has dict key country
, if 1 can found.
Comments
Post a Comment