Skip to main content

ll2location

Project description

ll2location

Installation

pip install ll2location

Usage example: Find from all country

from latlong.gadm import Gadm
from latlong.latlong import LatLong

#init all gadm package in all country, it may take a long time, maybe a few hours
gadm = Gadm()  
gadm.get_shp_fully()

#init lat long
lat = 10.773213
long = 106.671818

#from lat long to location
latlng = LatLong()
code, country_info, detail_info = latlng.to_location(10.773213, 106.671818)
print(detail_info)

The output could be:

{'GID_3': 'VNM.25.10.4_1',
  'GID_0': 'VNM',
  'COUNTRY': 'Vietnam',
  'GID_1': 'VNM.25_1',
  'NAME_1': 'Hồ Chí Minh',
  'NL_NAME_1': 'NA',
  'GID_2': 'VNM.25.10_1',
  'NAME_2': 'Quận 10',
  'NL_NAME_2': 'NA',
  'NAME_3': 'Phường 12',
  'VARNAME_3': 'Ward 12',
  'NL_NAME_3': 'NA',
  'TYPE_3': 'Phường',
  'ENGTYPE_3': 'Ward',
  'CC_3': 'NA',
  'HASC_3': 'NA'}

Usage example: Find from specific country code

from latlong.latlong import LatLong
from latlong.gadm import Gadm, GetGadm

#show country code infomation
get_gadm = GetGadm()
codes_detail = get_gadm.get_codes_detail()
print(codes_detail)

#init gadm package in specific country
code = "VNM"
gadm = Gadm()
gadm.get_shp_by_code(code)

#init lat long
lat = 10.773213
long = 106.671818

#from lat long to location in specific country
latlng = LatLong()
detail_info = latlng.to_location_by_country_code(code, lat, long)

print(detail_info)

The output could be:

{'GID_3': 'VNM.25.10.4_1',
 'GID_0': 'VNM',
 'COUNTRY': 'Vietnam',
 'GID_1': 'VNM.25_1',
 'NAME_1': 'Hồ Chí Minh',
 'NL_NAME_1': 'NA',
 'GID_2': 'VNM.25.10_1',
 'NAME_2': 'Quận 10',
 'NL_NAME_2': 'NA',
 'NAME_3': 'Phường 12',
 'VARNAME_3': 'Ward 12',
 'NL_NAME_3': 'NA',
 'TYPE_3': 'Phường',
 'ENGTYPE_3': 'Ward',
 'CC_3': 'NA',
 'HASC_3': 'NA'}

LICENSE

From https://gadm.org/license.html.

GADM license The data are freely available for academic use and other non-commercial use. Redistribution or commercial use is not allowed without prior permission.

Using the data to create maps for publishing of academic research articles is allowed. Thus you can use the maps you made with GADM data for figures in articles published by PLoS, Springer Nature, Elsevier, MDPI, etc. You are allowed (but not required) to publish these articles (and the maps they contain) under an open license such as CC-BY as is the case with PLoS journals and may be the case with other open access articles. Data for the following countries is covered by a a different license Austria: Creative Commons Attribution-ShareAlike 2.0 (source: Government of Ausria)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ll2location-0.0.3.tar.gz (4.6 kB view details)

Uploaded Source

File details

Details for the file ll2location-0.0.3.tar.gz.

File metadata

  • Download URL: ll2location-0.0.3.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for ll2location-0.0.3.tar.gz
Algorithm Hash digest
SHA256 4c7c402b3ad3f12523ff63f318a78001dc0d967a4e175d1018c09de9b8378bf0
MD5 89c7a68dc3b3de130b6bef6025089e07
BLAKE2b-256 cca86ed7807a1bc6d307437679b96b690c331a3627a4751e7bd8e3308984b4d4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page