From 0338f7237bc38db7ab9eced500dcc0685b26cb95 Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Thu, 6 Dec 2018 00:27:30 +1100 Subject: [PATCH] Update README.md Describe how to achieve reprojection. --- README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/README.md b/README.md index 5203a3d..40fc881 100644 --- a/README.md +++ b/README.md @@ -224,3 +224,29 @@ Output [newline-delimited JSON](http://ndjson.org/), with one object per line. # dbf2json --encoding encoding Specify the input character encoding. Defaults to “windows-1252”. + +### Handling other coordinate reference systems + +This library does not directly support reprojection. If you require the output GeoJSON in WGS84, you can use the `reproject` library as follows. + +If there is a `.prj` file present: + +``` +const shapefile = require('shapefile'); +const reproject = require('reproject'); +shapefile.read(basename + '.shp').then(result => { + const prj = fs.readFileSync(basename + '.prj', 'utf-8'); + const projected = reproject.toWgs84(result, prj); +}); +``` + +If you know the EPSG code for the source projection: + +``` +const shapefile = require('shapefile'); +const reproject = require('reproject'); +const epsg = require('epsg'); +shapefile.read(basename + '.shp').then(result => { + const projected = reproject.toWgs84(result, 'EPSG:3857', epsg); +}); +```