Convert OVOBJ to SHP
Use the bundled deterministic parser for supported OviO zlib-compressed point labels and XML OVKML point exports. Do not parse either format ad hoc when the script supports the file.
中文说明
将奥维互动地图的点数据转换为 WGS84(EPSG:4326)Shapefile,并保留点名称、原始经纬度和转换后的经纬度。支持两种输入:
.ovobj:在已验证的 OviO 点标签布局中,二进制坐标默认视为 WGS84,不要因为界面显示 GCJ-02 而再次偏移转换。.ovkml:读取每个点的OvCoordType。CGCS2000与WGS84直接写入;只有GCJ-02才转换为 WGS84。
优先使用点数完整的 .ovkml。转换报告中的 point_count、parse 和 validation.ok 是核查是否漏点、是否发生坐标偏移的依据。
Workflow
- Locate
.ovobjand.ovkmlinputs and identify the most complete source file before conversion. - Leave
--source-crsatautounless the user has authoritative coordinate information. In the supported OVOBJ layout, numeric coordinates are stored as WGS84. For OVKML,OvCoordTypecontrols automatic detection:CGCS2000andWGS84remain WGS84;GCJ-02is converted to WGS84. - Find a Python environment containing
geopandas,shapely, and a Shapefile writer. Prefer an environment explicitly requested by the user. - Run
scripts/convert_ovobj_to_shp.pywith an absolute input path. - Read the emitted JSON summary and verify the generated
.shp,.shx,.dbf,.prj, and.cpgfiles. - Report the point count, source-coordinate assumption, output CRS, bounds, skipped records, and output path.
Commands
Convert one OVOBJ with automatic coordinate handling:
python scripts/convert_ovobj_to_shp.py "C:\data\samples.ovobj"
Convert every OVOBJ and OVKML directly inside a directory:
python scripts/convert_ovobj_to_shp.py "C:\data\ovital" --output-dir "C:\data\shp"
Add --recursive to include subdirectories. Add --overwrite only when replacing existing outputs is intended.
Coordinate Rules
- Write output geometry as WGS84 longitude/latitude with
EPSG:4326. - Preserve source values in
src_lonandsrc_lat, and write converted values inwgs_lonandwgs_lat. - Treat GCJ-02 as a coordinate encoding without an EPSG identifier. Do not assign EPSG:4326 directly to unconverted GCJ-02 geometry.
- OVOBJ's user-interface coordinate display may be GCJ-02 while its binary numeric fields are WGS84. Do not convert those fields merely because the source is in mainland China.
- If the source CRS is uncertain and a wrong choice would affect fieldwork, compare against a known point or an OVKML export before using
--source-crs gcj02.
Supported Scope
The OVOBJ parser supports point-label files with the OviO header, zlib payload beginning at byte 24, point records marked by AB 00 00 00, little-endian latitude/longitude at record offsets 136/144, and length-prefixed UTF-8 names. The OVKML parser supports Placemark > Point > coordinates records and OvCoordType. Stop with a clear error for unsupported headers, compression layouts, coordinate types, tracks, polygons, attachments, encrypted files, ODB databases, or arbitrary future OVOBJ versions.
Output Contract
Each Shapefile contains id, name, source_crs, src_lon, src_lat, wgs_lon, wgs_lat, and point geometry. The script writes UTF-8 .cpg, WGS84 .prj, and a sibling *_conversion_report.json. Treat conversion as successful only when the report shows validation.ok: true, including input/output point-count equality and zero geometry-versus-attribute discrepancy.
评论
加载中…