ogr2ogr wrapper w/ multiple format support
ogr2ogr enables spatial file conversion and reprojection of spatial data through the use of ogr2ogr (gdal) tool
ogr2ogr requires the command line tool ogr2ogr - gdal install page. It is recommended to use the latest version.
npm install ogr2ogr
ogr2ogr takes either a path, a stream, or a GeoJSON object. The result of the transformation can be consumed via callback or stream:
var ogr2ogr = require'ogr2ogr'var ogr = ogr2ogr'/path/to/spatial/file'ogrexecif er console.errorerconsole.logdatavar ogr2 = ogr2ogr'/path/to/another/spatial/file'ogr2streampipewriteStream
/examples for usage examples and
The goal is for ogr2ogr to support most (if not all) formats your underlying ogr2ogr supports. You can see the progress of that in
It also will:
ogr2ogr takes chainable modifier functions:
var shapefile = ogr2ogr'/path/to/spatial/file.geojson'format'ESRI Shapefile'skipfailuresstreamshapefilepipefscreateWriteStream'/shapefile.zip'
Available options include:
.project(dest, src)- reproject data (defaults to: "ESPG:4326")
.format(fmt)- set output format (defaults to: "GeoJSON")
.timeout(ms)- milliseconds before ogr2ogr is killed (defaults to: 15000)
.skipfailures()- skip failures (continue after failure, skipping failed feature -- by default failures are not skipped)
.options(arr)- array of custom org2ogr arguments (e.g.
.destination(str)- ogr2ogr destination (directly tell ogr2ogr where the output should go, useful for writing to databases)
(The MIT License)
Copyright (c) 2014 Marc Harter <email@example.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.