Skip to main content

About

This is a forked version of the cpca project (https://github.com/DQinYuan/chinese_province_city_area_mapper).

Purpose

From Github actitivy, it seems cpca has stopped maintenance since 2021.
During usage, we encountered several problems with cpca.
Some of the problems are:

  1. Inaccessible map data.
    cpca uses the map patches from openstreetmap.org, which can not be accessed now.
  1. Incompatible issues due to dependency versions.

e.g., jinja2 and pyecharts have import problems for newer versions.

In this repo, we try to revise and fix the above issues.

Main Revisions

  1. Use map tiles from AMap
def heatmap_folium(adcodes, file_path, 
                   tiles= 'https://wprd01.is.autonavi.com/appmaptile?x={x}&y={y}&z={z}&lang=zh_cn&size=1&scl=1&style=7', 
                   attr = 'amap'):
    ...
    map_osm = folium.Map(location=[35, 110], zoom_start=5, 
                         tiles = tiles, attr=attr)
  1. Fix some issue due to incompatible versions.

Issue: ImportError: cannot import name 'environmentfunction' from 'jinja2'
Fix: jinja2==3.0.0

Issue: cannot import name 'Geo' from 'pyecharts'
Fix: support the latest pyecharts version (We tested for 2.0.x. The old version is 0.5.x).

  1. Change map styles.

Use white background maps in echarts_heatmap() and heatmap_folium().

Install

pip install cpcax

Use

Prepare a list of address codes. The frequency of each code is used the value. e.g., ['110000','110000','310018']

folium heatmap

from cpca import drawer
drawer.folium_heatmap(邮编列表, "geos.html")

from IPython.display import IFrame
IFrame(src='geos.html', width=1600, height=900)

echarts heatmap

from cpca import drawer
drawer.echarts_heatmap(邮编列表, "echarts_geos.html")

from IPython.display import IFrame
IFrame(src='echarts_geos.html', width=800, height=600)



TODO

Expose more style parameters for map visualization.

Metadata

Release files for cpcax 0.6.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 cpcax 0.6.1
File Size Uploaded Provenance
cpcax-0.6.1.tar.gz 79.8 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 156.1 kB

Release files / cpcax-0.6.1.tar.gz

Download URL cpcax-0.6.1.tar.gz
Size 79.8 kB
Tags Source
SHA-256 checksum
How to use checksums
5b834c13891ab9b989ff20fac11d4d18ec1db595194cf93c667c920f93f4dbcc
BLAKE2b-256 checksum
How to use checksums
f0bf10b1ad1d38ba41fbf918778b7b68efc1310f8a01d9c20ad95c8446feda6e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.12

Release files / cpcax-0.6.1-py3-none-any.whl

Download URL cpcax-0.6.1-py3-none-any.whl
Size 76.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a2340f98d0876dc448eb6019efa5c0c5e98eb2d8a7c55ed81c626d394b88a697
BLAKE2b-256 checksum
How to use checksums
b52a8a1b15adf9ecff31510dbbaddc540a4f9bbdfe3cfda8de5f7817f2fa475d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.12

Security for cpcax 0.6.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.

Release history Release notifications | RSS feed

This release

0.6.1 This release

2 release files No provenance

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