Skip to main content

A python package to draw china maps more easily

Project description

cnmaps 是一个可以让中国地图画起来更丝滑的地图类python扩展包

Pytest Pypi publish Anaconda Conda downloads PyPI version Pypi Downloads Documentation Status contributions welcome style

安装

安装 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使用指南

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

cnmaps-2.0.1.tar.gz (19.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cnmaps-2.0.1-py3-none-any.whl (20.1 kB view details)

Uploaded Python 3

File details

Details for the file cnmaps-2.0.1.tar.gz.

File metadata

  • Download URL: cnmaps-2.0.1.tar.gz
  • Upload date:
  • Size: 19.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for cnmaps-2.0.1.tar.gz
Algorithm Hash digest
SHA256 cd6d354d1ab28b76007cfac3e52ac84d2865cbba4e0520c2620ae65880fce721
MD5 3da42ae8d61f140a2655e0d8ea5f837d
BLAKE2b-256 13d9308f6e09de9b9e41d5b921efa01f58e2871bd50366976bcb621315df716b

See more details on using hashes here.

File details

Details for the file cnmaps-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: cnmaps-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 20.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for cnmaps-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 062187b18c6664cf21c995496630a088cee39ffaa07795e15412344a8a2fa05a
MD5 e3094e04a6f907164cbc725dc2d9b2ae
BLAKE2b-256 6f52fdcaa9b4c1a9b902e472b248f6aec1cf9f8ba225c17dd8c92cc31abd9b91

See more details on using hashes here.

Supported by

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