Read MapGIS vector files (.wt, .wl, .wp) into GeoPandas GeoDataFrames
Project description
pymapgis
Read MapGIS 6.x/67 vector files (.wt, .wl, .wp) into GeoPandas GeoDataFrames.
MapGIS is a widely used closed-source GIS platform in China, especially in geological surveying, engineering, and scientific research. pymapgis provides a lightweight, open-source reader for its native point, line, and polygon vector formats.
Features
- Read point (
.wt), line (.wl), and polygon (.wp) files - Decode GBK-encoded attribute fields and field names
- Reconstruct polygon topology from arc records
- Preserve or repair invalid polygon geometries with
shapely.make_valid - Export to any format supported by GeoPandas / Fiona (Shapefile, GeoJSON, GeoPackage, etc.)
- Simple command-line interface for quick conversions
Installation
pip install mapgis2shp
The Python package is imported as pymapgis:
from pymapgis import Reader
Quick start
from pymapgis import Reader
with Reader("example.wp") as r:
print(r)
# Write to Shapefile
r.geodataframe.to_file("example.shp")
# Or access the GeoDataFrame directly
print(r.geodataframe.head())
Command-line usage
# Convert a polygon file to Shapefile
pymapgis input.wp output.shp
# Convert to GeoJSON
pymapgis input.wl output.geojson --driver GeoJSON
# Keep raw (possibly invalid) polygon geometries
pymapgis input.wp output.shp --no-make-valid
API
Reader(filepath, make_valid=True)
Main entry point for reading a MapGIS file.
Attributes
| Attribute | Type | Description |
|---|---|---|
shapeType |
str |
"POINT", "LINE", or "POLYGON" |
crs |
pyproj.CRS or None |
Detected coordinate reference system |
bbox |
numpy.ndarray |
Bounding box [minx, miny, maxx, maxy] |
fields |
list[tuple] |
Field metadata: (name, type_name, length) |
data |
pandas.DataFrame |
Attribute table |
geom |
list[shapely.geometry] |
Geometry objects |
geodataframe |
geopandas.GeoDataFrame |
Combined attributes and geometry |
Methods
to_file(filepath, **kwargs)— forward toGeoDataFrame.to_file
Exceptions
MapGISError— base exceptionInvalidFileError— unsupported or unrecognized fileTopoError— polygon topology reconstruction errorInvalidDirectoryError— reserved for project/directory errors
Supported formats
| Extension | Geometry type | Notes |
|---|---|---|
.wt |
Point | 93-byte fixed record size |
.wl |
LineString | 57-byte arc index + coordinate block |
.wp |
Polygon/MultiPolygon | Arc index + topology table + coordinate block |
CRS detection supports the most common projections found in MapGIS 6.x files, including longitude/latitude, Gauss-Krüger (Transverse Mercator), Lambert Conformal Conic, and Albers Equal-Area. Because MapGIS stores only projection and ellipsoid index numbers, the complete CRS depends on external MapGIS index files (ellip.dat, etc.).
Development
Clone the repository and install in editable mode with dev dependencies:
git clone https://github.com/pymapgis/pymapgis.git
cd pymapgis
pip install -e ".[dev]"
Run the test suite:
pytest
Run the smoke-test regression against all local MapGIS files:
python verify_pymapgis.py
License
This project is licensed under the Apache License 2.0.
Acknowledgments
The original reverse-engineering of the MapGIS binary format was done by the author of the legacy pymapgis.py script. This package refactors and extends that work into an installable, tested library.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mapgis2shp-2.0.0.tar.gz.
File metadata
- Download URL: mapgis2shp-2.0.0.tar.gz
- Upload date:
- Size: 25.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
886cb3a62786559a6497c59c69cba3c0af3d9d7eea8dc3e1d7e4181f2638d1a6
|
|
| MD5 |
e128dd016cb52577d0c823339023857d
|
|
| BLAKE2b-256 |
ac899a1953180de7061b917382efbba4ce768e4df3d34e11f5461d3cb762c9cd
|
File details
Details for the file mapgis2shp-2.0.0-py3-none-any.whl.
File metadata
- Download URL: mapgis2shp-2.0.0-py3-none-any.whl
- Upload date:
- Size: 20.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f26869f5de2e8f92513505706da1bc92e9cb223209f0510cb621b043b0fd4b4e
|
|
| MD5 |
a9e41951ddc4bb1eed9d35b2c0555219
|
|
| BLAKE2b-256 |
6fc3526e627f0372fde8eecada87084c6739cffcfa8bda7966ce7c6046db793f
|