您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
GeoSHPer is a JavaScript library for converting shapefile data into GeoJSON. It reads ZIP archives containing .shp, .dbf, and .prj files, parses geographic features and attributes, and supports coordinate transformation using Proj4js. The result is a GeoJSON FeatureCollection, enabling easy integration with web mapping libraries.
此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.greasyfork.icu/scripts/526996/1537647/GeoSHPer.js
GeoSHPer is a JavaScript library designed to convert shapefile data into GeoJSON format effortlessly. It reads ZIP archives containing various components of shapefiles (.shp, .dbf, and .prj files), parses geographic features and attributes, and supports coordinate transformations using Proj4js. The final result is a GeoJSON FeatureCollection, which can be easily integrated with web mapping libraries.
To use GeoSHPer, you need to include the Proj4js library as a dependency:
<script src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.15.0/proj4-src.js"></script>
or via Tamplermonkey / GreasyFork
// @require https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.15.0/proj4-src.js
Here is a simple example of how to use GeoSHPer to convert shapefile data to GeoJSON:
(async () => {
const response = await fetch('path/to/your/shapefile.zip');
const buffer = await response.arrayBuffer();
const geoSHPer = new GeoSHPer();
await geoSHPer.read(buffer);
const geoJSON = geoSHPer.toGeoJSON();
console.log(geoJSON);
})();
GeoSHPer supports different string encoding formats specified in .cpg files for .dbf attributes.
// Assuming a `.cpg` file exists in your .zip providing character encoding details.
GeoSHPer provides error messages for common issues:
Ensure you handle these errors appropriately in your application.
This project is licensed under the MIT License - see the LICENSE file for details.
GeoSHPer builds upon foundational work from:
Each library is subject to its own license and must be used in accordance with their respective terms. This code adapts and extends functionalities from shpjs to convert shapefile data into GeoJSON.
Created by JS55CT - GitHub