Skip to main content

Chinese Province, City and Area Recognition Utilities. This is an extended version based on https://github.com/DQinYuan/chinese_province_city_area_mapper

Project description

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.

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

cpcax-0.6.1.tar.gz (79.8 kB view details)

Uploaded Source

Built Distribution

cpcax-0.6.1-py3-none-any.whl (76.2 kB view details)

Uploaded Python 3

File details

Details for the file cpcax-0.6.1.tar.gz.

File metadata

  • Download URL: cpcax-0.6.1.tar.gz
  • Upload date:
  • Size: 79.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.12

File hashes

Hashes for cpcax-0.6.1.tar.gz
Algorithm Hash digest
SHA256 5b834c13891ab9b989ff20fac11d4d18ec1db595194cf93c667c920f93f4dbcc
MD5 a86345e0be7776f61945dedd5deef4d6
BLAKE2b-256 f0bf10b1ad1d38ba41fbf918778b7b68efc1310f8a01d9c20ad95c8446feda6e

See more details on using hashes here.

File details

Details for the file cpcax-0.6.1-py3-none-any.whl.

File metadata

  • Download URL: cpcax-0.6.1-py3-none-any.whl
  • Upload date:
  • Size: 76.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.12

File hashes

Hashes for cpcax-0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a2340f98d0876dc448eb6019efa5c0c5e98eb2d8a7c55ed81c626d394b88a697
MD5 0d9cb8dca3599475b1f34289e7bd712c
BLAKE2b-256 b52a8a1b15adf9ecff31510dbbaddc540a4f9bbdfe3cfda8de5f7817f2fa475d

See more details on using hashes here.

Supported by

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