cnmaps 是一个以中国领土主张为标准开发的地图类 Python 扩展包
安装
安装 cnmaps 需要满足 Python 的解释器在 3.9 版本及以上。
使用pip安装
cnmaps 最简单也最快的安装方法是使用 pip 来安装 cnmaps: $ pip install -U cnmaps
从 2.0.0 开始,官方边界与样例数据已经拆分到独立包 cnmaps-data;安装 cnmaps 时会默认一并安装 cnmaps-data,无需再手动准备内置数据目录。
使用conda安装
你也可以使用 conda 安装: $ conda install -c conda-forge cnmaps
补充说明:conda-forge 当前只维护到 1.1.7 版本;2.x 及后续版本仅发布到 PyPI,conda 发行将停止后续维护。
快速开始
绘制国界
用最简单直接的方式,来绘制你的第一张中国地图。
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
from cnmaps import get_adm_maps, draw_maps
fig = plt.figure(figsize=(10,10))
ax = fig.add_subplot(111, projection=ccrs.PlateCarree())
draw_maps(get_adm_maps(country='中国', level='国'))
plt.show()
绘制省界
cnmaps还可以绘制各省(特区/直辖市)的地图
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
from cnmaps import get_adm_maps, draw_maps
fig = plt.figure(figsize=(10,10))
ax = fig.add_subplot(111, projection=ccrs.PlateCarree())
draw_maps(get_adm_maps(level='省'), linewidth=0.8, color='r')
plt.show()
绘制市界
cnmaps可以绘制市级的行政区地图。
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
from cnmaps import get_adm_maps, draw_maps
fig = plt.figure(figsize=(15,15))
ax = fig.add_subplot(111, projection=ccrs.PlateCarree())
draw_maps(get_adm_maps(level='市'), linewidth=0.5, color='g')
plt.show()
绘制区县界
cnmaps可以绘制区县级的行政区地图。
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
from cnmaps import get_adm_maps, draw_maps
fig = plt.figure(figsize=(20,20))
ax = fig.add_subplot(111, projection=ccrs.PlateCarree())
draw_maps(get_adm_maps(level='区县'), linewidth=0.8, color='r')
plt.show()
使用指南
针对本项目更多的使用方法,我们还有一份更详细的文档:cnmaps使用指南
Metadata
Release files for cnmaps 2.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cnmaps-2.1.0.tar.gz | 46.2 kB | Without provenance | Details for cnmaps-2.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cnmaps-2.1.0-py3-none-any.whl | Python 3 | none | any | Details for cnmaps-2.1.0-py3-none-any.whl |
Total release size: 106.7 kB
Release files / cnmaps-2.1.0.tar.gz
| Download URL | cnmaps-2.1.0.tar.gz |
|---|---|
| Size | 46.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e2d86179a871002429b15a76951f8624ab97995fd99907f4bf7879d1ee3d3b74
|
|
BLAKE2b-256 checksum How to use checksums |
4a34d9267fcd7a31da75b44a23ef0f8463e02a53ca471ca072f93faadec1fd40
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / cnmaps-2.1.0-py3-none-any.whl
| Download URL | cnmaps-2.1.0-py3-none-any.whl |
|---|---|
| Size | 60.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4cb5e5046228ea1ef5d03338c68db14035a17f0efb4cbabed2ee92f2192161ae
|
|
BLAKE2b-256 checksum How to use checksums |
3f38b655396645c69d52970541dd9ebd368c73cf168a1a9578904abad0e27523
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Security for cnmaps 2.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.