Giter Site home page Giter Site logo

liupeng23 / cnmaps Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cnmetlab/cnmaps

0.0 0.0 0.0 66.75 MB

这是一个可以让**地图画起来更丝滑的python扩展包

Home Page: https://cnmaps-doc.readthedocs.io/zh_CN/latest/index.html

License: BSD 3-Clause "New" or "Revised" License

Python 100.00%

cnmaps's Introduction

Build Status PyPI version Downloads Documentation Status tokei contributions welcome

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

安装

cnmaps依赖于cartopy>=0.19.0,因此在安装cnmaps之前请确保cartopy已安装,cartopy的安装方法

在完成cartopy的安装以后,你可以使用pip来安装cnmaps:$ pip install -U 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='国')) 
plt.show()

country-level

绘制省界

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()

province-level

绘制市界

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()

city-level

绘制区县界

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()

district-level

Logo

本项目的Logo地图是如何绘制的?请执行下面的代码。

import cartopy.crs as ccrs
import matplotlib.pyplot as plt
from cnmaps import get_adm_maps

fig = plt.figure(figsize=(5,5))
proj = ccrs.Orthographic(central_longitude=100.0, central_latitude=30)
ax = fig.add_subplot(111, projection=proj)

ax.stock_img()
china, sourth_sea = get_adm_maps(level='国', only_polygon=True)

ax.set_global()
ax.add_geometries(china, crs=ccrs.PlateCarree(), edgecolor='r', facecolor='r')
ax.add_geometries(sourth_sea, crs=ccrs.PlateCarree(), edgecolor='r')
ax.outline_patch.set_edgecolor('white')

plt.savefig('../static/images/logo-base.png', bbox_inches='tight')

logo-base

使用指南

针对本项目更多的使用方法,我们还有一份更详细的文档:cnmaps使用指南

引用

本项目适用的地图边界的数据源包括:

  1. GaryBikini/ChinaAdminDivisonSHP: v2.0, 2021, DOI: 10.5281/zenodo.4167299

海拔高度地形数据来自ASTER数字高程模型,并对原始数据进行了稀释。

cnmaps's People

Contributors

clarmy avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.