node.js - 如何解决 Geojson 到 shapefile 的转换错误?
问题描述
我正在尝试将 geojson 文件转换为 shapefile。我正在使用 geojson2shape 方法,但是当我运行下面的代码时,我收到了这个错误。我也通过 npm install ogr2ogr 安装了 ogr2ogr,但我有错误。我该如何解决这个错误?
var geojson2shape = require('geojson2shape')
// a shapefile is actually multiple files. geojson2shape will output a zipped version if specified.
var zip = true
geojson2shape(__dirname+'/polygon.geojson', __dirname+'/polygon.shp',zip, function(err){
if(err) throw err
console.log('success');
})
Command failed: ogr2ogr -f "ESRI Shapefile" C:\upload2/output/out.shp C:\upload2/Files/imgUploader_1577252750283_AC127138-5645-497D-AF51-3F4EA12E20C5.geojson -overwrite -lco ENCODING=UTF-8
'ogr2ogr' is not recognized as an internal or external command
解决方案
ogr2ogr 是一个“本机应用程序”。npm 中名为 ogr2ggr的包只是对本机工具的一种包装,如文档中所述:
ogr2ogr 需要命令行工具 ogr2ogr - gdal 安装页面。我们建议使用最新的稳定版本。
因此,要使用geojson2shape
甚至 npm ,请ogr2ogr
按照在系统中安装 gdal/ogr2ogr 的说明进行操作,并确保ogr2ogr
二进制文件位于PATH
推荐阅读
- c# - MT4 Manager API 如何获取开仓头寸
- python-3.x - 如果数据框中存在值,则将值设为索引并用 1 替换值
- html - Html-loader + file-loader 未绑定正确的图像源
- clang - clang/llvm 编译致命错误:找不到“cstdarg”文件
- c# - 从json的listview中显示listview
- c++ - 可能平凡可构造类型的聚合初始化。隐藏基类可能吗?
- android - 自动 BLE 断开连接 - Windows10、Android
- sql - 如果传递零,则参数化存储过程跳过
- java - @拆机后,睡眠 100 毫秒,测试全部通过
- forms - xamarin 形成选择器将选定的值绑定到 NgModel,如 angular