Skip to main content

DataV

PyPI PyPI - Python Version PyPI - Wheel PyPI - Downloads License

This is an unofficial solution to draw map using Aliyun's DataV.GeoAtlas.

这是一个非官方的使用阿里云 DataV.GeoAtlas 绘制地图的解决方案。

Examples

See examples for more.

import cartopy.crs as ccrs
import cartopy.feature as cfeature
import matplotlib.pyplot as plt
import numpy as np
from cartopy.mpl.gridliner import LATITUDE_FORMATTER, LONGITUDE_FORMATTER
from matplotlib.transforms import offset_copy
from matplotlib.font_manager import FontProperties

from datav import DataVGeoAtlasFeature

# Windows 下字体可以不用这么麻烦,直接 rc 设置 SimSun 即可
simsun = FontProperties(fname="/mnt/c/Windows/Fonts/simsun.ttc")

proj = ccrs.PlateCarree()
fig = plt.figure(figsize=(14, 7))
main_box = (80.5, 82, 40.25, 41)
ax_main = plt.subplot(1, 1, 1, projection=proj)
ax_main.set_extent(main_box, crs=ccrs.PlateCarree())
ax_main.add_feature(DataVGeoAtlasFeature(659002, facecolor="darkgreen", alpha=0.2))  # 阿拉尔
ax_main.add_feature(cfeature.LAKES)
ax_main.add_feature(cfeature.RIVERS)
site = (81.196, 40.624)
ax_main.plot(
    *site,
    marker="o",
    color="green",
    markersize=10,
    transform=ccrs.Geodetic(),
)
geodetic_transform = ccrs.Geodetic()._as_mpl_transform(ax_main)
text_transform = offset_copy(geodetic_transform, units="dots", x=-25)
ax_main.text(
    site[0],
    site[1] + 0.03,
    "试验站",
    transform=text_transform,
    fontproperties=simsun,
)
xmain = np.linspace(*main_box[:2], 4)
ymain = np.linspace(*main_box[2:], 4)
ax_main.gridlines(xlocs=xmain, ylocs=ymain, linestyle=":")
# set custom formatting for the tick labels
ax_main.xaxis.set_major_formatter(LONGITUDE_FORMATTER)
ax_main.yaxis.set_major_formatter(LATITUDE_FORMATTER)
ax_main.yaxis.tick_right()
ax_main.set_xticks(xmain, crs=ccrs.PlateCarree())
ax_main.set_yticks(ymain, crs=ccrs.PlateCarree())

ax_inset = fig.add_axes([0, 0.6, 0.3, 0.35], projection=proj)
ax_inset.set_extent((73, 136, 2, 51))
ax_inset.add_feature(
    DataVGeoAtlasFeature(100000, full=True, facecolor="lightgreen", edgecolor="gray")
)
ax_inset.add_feature(DataVGeoAtlasFeature(650000, facecolor="limegreen"))
ax_inset.add_feature(DataVGeoAtlasFeature(652900, facecolor="green", edgecolor="none"))
ax_inset.add_feature(
    DataVGeoAtlasFeature(659002, facecolor="darkgreen", edgecolor="black")
)
xinset = np.linspace(73, 136, 5)
yinset = np.linspace(2, 51, 5)
ax_inset.gridlines(xlocs=xinset, ylocs=yinset, linestyle=":")
ax_inset.xaxis.set_major_formatter(LONGITUDE_FORMATTER)
ax_inset.yaxis.set_major_formatter(LATITUDE_FORMATTER)
ax_inset.xaxis.tick_top()
# set inset tick labels
ax_inset.set_xticks(xinset, crs=ccrs.PlateCarree())
ax_inset.set_yticks(yinset, crs=ccrs.PlateCarree())

plt.savefig("research_site.png", dpi=800)

Research site

Requirements

  1. Cartopy (for ploting)
  2. Geopandas (for parsing geojson)

NOTE

Free For Educational Use. Respect Aliyun's license.

仅供学习使用。遵守阿里云的协议。请合理使用地图数据。数据内容和本人无关。数据具体用途也和本人无关。请遵守相关法律规定。

TODO

  1. respect the HTTP header last-modified

    尊重 HTTP 请求头 last-modified

  2. Chinese name alias for adcode

    使用中文名替代 adcode 查询

  3. More features such as line

    从 GeoJSON 中提取更多可定制的 feature。

Metadata

Release files for datav 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for datav 0.2.1
File Size Uploaded Provenance
datav-0.2.1.tar.gz 1.1 MB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for datav 0.2.1
File Interpreter ABI Platform
datav-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 1.1 MB

Release files / datav-0.2.1.tar.gz

Download URL datav-0.2.1.tar.gz
Size 1.1 MB
Tags Source
SHA-256 checksum
How to use checksums
272eeec2a4e35e063ec15b70d2003859b4f3995bac8c6187583566219ef540d4
BLAKE2b-256 checksum
How to use checksums
61c0f715ff5c61d0e21101cfd040dff3949bc86ca20587a7084fe486295531ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.6

Release files / datav-0.2.1-py3-none-any.whl

Download URL datav-0.2.1-py3-none-any.whl
Size 12.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0bc035cf382ffdffaaff6fcadab9df51c004bcbecb13047c1cca18e77c395def
BLAKE2b-256 checksum
How to use checksums
be57f598b2722f67486986fd1f823d42f50c825228b7645e75dabf337a3a3148
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.6

Security for datav 0.2.1

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page