国家边界框(及其相关数据)库
项目描述
包含从
http://www.naturalearthdata.com/
中提取的国家边界框和其他相关附加信息
此库的早期版本为每个国家代码返回一个(通常是大的)单个边界框;在许多情况下,这些跨越了大部分地球,因此在地理上不太有用。
安装
$ pip install country-bounding-boxes
使用
>>> from country_bounding_boxes import ( country_subunits_containing_point, country_subunits_by_iso_code )
通过2或3字母的ISO代码获取国家
>>> [c.name for c in country_subunits_by_iso_code('ZW')] ['Zimbabwe'] >>> [c.name for c in country_subunits_by_iso_code('ZWE')] ['Zimbabwe'] >>> [c.name for c in country_subunits_by_iso_code('TM')] ['Turkmenistan'] >>> [c.name for c in country_subunits_by_iso_code('GB')] ['Wales', 'England', 'N. Ireland', 'Scotland']
以(lon1, lat1, lon2, lat2)元组的格式检查边界框
>>> [c.bbox for c in country_subunits_by_iso_code('TM')] [(52.5024597512, 35.2706639674, 66.5461503437, 42.7515510117)] >>> [c.bbox for c in country_subunits_by_iso_code('GB')] [(-5.2623046875, 51.3904296875, -2.6623046875, 53.4192871094), (-5.65625, 50.0213867188, 1.74658203125, 55.8079589844), (-8.14482421875, 54.0512695312, -5.47041015625, 55.241796875), (-7.54296875, 54.689453125, -0.774267578125, 60.8318847656)]
通过与一个点相交获取一组国家
>>> [c.name for c in country_subunits_containing_point(lon=-79.888252, lat=32.819747)] ['U.S.A.'] >>> [c.name for c in country_subunits_containing_point(lon=5.983333, lat=50.883333)] ['Germany', 'France', 'Netherlands']
开发
如果您想对此库进行开发,请按照以下步骤操作
创建虚拟环境
bin/pip install -r requirements/tests.txt
bin/nosetests -s country_bounding_boxes
项目详情
下载文件
下载适用于您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。
源代码分布
country-bounding-boxes-0.2.3.tar.gz (61.3 kB 查看哈希值)
关闭
country-bounding-boxes-0.2.3.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | bbd1f4b029a0c2aa33a69eb4922e908f5af561221d08eeb7b7de4677705e5426 |
|
MD5 | 571e9a4827397444f3b816f2c7c601bd |
|
BLAKE2b-256 | 984622750bd08b3296d0fceb01a1c73ff20c9f565626cb6bceb9d8829d641519 |