Skip to main content

简体中文

async-map-mongo

Asynchronously calls Amap's API to obtain corresponding latitude and longitude coordinates, with API call results stored in a MongoDB database. Provides functionality to query latitude and longitude from MongoDB and export to Excel.

Open Source Code Address: https://github.com/JieShenAI/async-map-mongo

Introduction

This package enables asynchronous calls to geocoding APIs (default: Amap API; extensible to Baidu Maps and more) to fetch latitude and longitude for addresses. It automates persists geocoding results (e.g., formatted address, country, province, city, coordinates) in MongoDB for efficient data retrieval.

Amap API call interface: https://restapi.amap.com/v3/geocode/geo?address=北京市朝阳区阜通东大街6号&output=XML&key=<user's key>

install

pip install async-map-mongo

Usage

The Amap API key can be stored in a .env file:

api_key=Amap API Key

Call the Amap API and save latitude and longitude information to MongoDB:

amap_insert \
--db_name map \
--collection_name amap \
--limiter_ratio 2.8 \
--address_min_length 5 \
--filename data/excel_name.xlsx \
--address_col_name address \
--max_addresses_num 1000 \

Collects all addresses from the "address" column, filters out addresses that do not exist in the database, and then calls Amap for the remaining addresses to obtain latitude and longitude.

  • filename: Excel or CSV file;
  • address_col_name: the attribute name corresponding to the address;
  • limiter_ratio: API call rate limit per second;
  • max_addresses_num: maximum of 1000 Amap API calls;
  • address_min_length: minimum length of a valid address; addresses with a string length less than address_min_length will not call the API;

Data format stored in the database:

Query latitude and longitude from MongoDB based on the provided table and export to Excel:

amap_export \
--db_name map \
--collection_name amap \
--address_min_length 5 \
--filename data/excel_name.xlsx \
--address_col_name address \
--output_type csv \
--output_dir output
  • address_clean: whether to remove text enclosed in Chinese parentheses in the address; true means remove, false means do not remove;
  • output_type: The format of the exported file, which defaults to csv. Only file extensions of csv and xlsx are supported.

API Call Extensibility

Although it supports Amap API for latitude and longitude calls by default, Baidu Maps can be used by changing the base_url parameter. For calls to other API interfaces and corresponding processing, please modify the code of AsyncMapCall.__call_api.

Metadata

Release files for async-map-mongo 0.0.5

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

Source distribution (sdist)

Source distribution for async-map-mongo 0.0.5
File Size Uploaded Provenance
async_map_mongo-0.0.5.tar.gz 12.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for async-map-mongo 0.0.5
File Interpreter ABI Platform
async_map_mongo-0.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 25.5 kB

Release files / async_map_mongo-0.0.5.tar.gz

Download URL async_map_mongo-0.0.5.tar.gz
Size 12.2 kB
Tags Source
SHA-256 checksum
How to use checksums
849708f2ea0580006c86f11036823ee29a97af16d83edcdc931f4efbfb028dcf
BLAKE2b-256 checksum
How to use checksums
5cb6c5c10611bac3b61d1490acab4a91649570c2226965c0cd7fc70be3c1d93a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.7

Release files / async_map_mongo-0.0.5-py3-none-any.whl

Download URL async_map_mongo-0.0.5-py3-none-any.whl
Size 13.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1d1616453fd38b6f4bd77e7c5bebb4e4d2b8844bec4403a1618a8d997781d80c
BLAKE2b-256 checksum
How to use checksums
8fbe5dbef631cfa89cce1107b330fdfa1655c829a6f026a64738294a01b41a6c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.7

Security for async-map-mongo 0.0.5

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.

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