geojson2shaper
v1.0.3
Published
Convert GeoJSON to Shapefile format
Maintainers
Readme
geojson2shaper
一个将 GeoJSON 转换为 Shapefile 的 npm 包。
功能特点
- 支持将 GeoJSON 转换为 Shapefile 格式
- 支持多种几何类型(Point、LineString、Polygon、MultiPoint、MultiLineString、MultiPolygon)
- 支持 TypeScript
- 自动打包为 zip 文件
安装
npm install geojson2shaper使用方法
import { GeoJson2Shaper, GeoJSONFeatureCollection, CRSManager, WKID } from "geojson2shaper";
// 方法 1: 转换并获取 Blob
const blob = await GeoJson2Shaper.transformAndDownload(geoJsonObject);
// 可以自行处理 blob,例如下载或上传
// 方法 2: 转换并下载(使用辅助方法)
const blob = await GeoJson2Shaper.transformAndDownload(geoJsonObject);
GeoJson2Shaper.downloadBlob(blob, "output.zip");
// 方法 3: 使用坐标系统
const geoJsonWithCRS = {
type: "FeatureCollection",
features: [...],
crs: CRSManager.getCRSByWKID(4326) // 使用 WGS84 坐标系统
};
const blob = await GeoJson2Shaper.transformAndDownload(geoJsonWithCRS);