Giter Club home page Giter Club logo

Comments (4)

Clarmy avatar Clarmy commented on June 1, 2024

收到,我测试一下

from cnmaps.

Clarmy avatar Clarmy commented on June 1, 2024

@huddao 你试一下这个样例:

import matplotlib.pyplot as plt
import cartopy.crs as ccrs

from cnmaps import get_adm_maps, clip_contours_by_map, draw_maps, MapPolygon
from cnmaps.sample import load_temp
from shapely.geometry import Polygon

fig = plt.figure(figsize=(6, 5), dpi=300)
ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], projection=ccrs.PlateCarree())
lons, lats, data = load_temp()
cs = ax.contourf(lons, lats, data)

boundary = MapPolygon(
    [Polygon([[70, 55], [140, 55], [140, 40], [70, 40], [70, 55]])]
) & get_adm_maps(country="中华人民共和国", only_polygon=True, record="first")

draw_maps(get_adm_maps(country="中华人民共和国"), ax)
clip_contours_by_map(cs, boundary, ax)
ax.set_extent([70, 140, 40, 55], crs=ccrs.PlateCarree())
fig.savefig("./test.png", bbox_inches="tight")

test

from cnmaps.

huddao avatar huddao commented on June 1, 2024

感谢,完美解决

from cnmaps.

huddao avatar huddao commented on June 1, 2024

记录:可以通过ax的get_extent方法获取到边界,再通过boundary = MapPolygon( [Polygon([[70, 55], [140, 55], [140, 40], [70, 40], [70, 55]])] ) & get_adm_maps(country="中华人民共和国", only_polygon=True, record="first")的方法构建新的boundary用于裁切

from cnmaps.

Related Issues (20)

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.