Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

reproject

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reproject

Reproject GeoJSON from one projection/CRS to another

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8.2K
decreased by-5.98%
Maintainers
1
Weekly downloads
 
Created
Source

reproject Build status NPM version

Transforms GeoJSON from one projection / CRS to another.

cli

install:

$ npm install -g reproject

use:

$ echo '{"type":"Point","coordinates":[319180, 6399862]}' | reproject --use-spatialreference --from=EPSG:3006 --to=EPSG:4326

Options:

  • --from=crs-name is the CRS to convert the GeoJSON from
  • --to=crs-name is the CRS to convert the GeoJSON to
  • --use-spatialreference or --sr to use spatialreference.org to look up any CRS definitions that aren't already known
  • --crs-defs=file to provide a JSON dictionary of known CRS definitions. A sample file of CRS definitions, crs-defs.json, is supplied.
  • --reverse to reverse the axis (swap x and y) before performing the reprojection

reproject can be used together with for example wellknown and geojsonio-cli:

$ echo "POINT(319180 6399862)" | wellknown | reproject --crs-defs=crs-defs.json --from=EPSG:3006 --to=EPSG:4326 | geojsonio

usage

Installation is easy with npm:

npm install reproject

It works well in the browser with for example browserify.

api

reproject(geojson, from, to, crss)

Reprojects the given GeoJSON from the CRS given in from to the CRS given in to.

The from and to arguments can either be a proj4 projection object, or a string containing a CRS name. In the case of a CRS name, the proj4 projection instance is looked up using the crss argument. crss is assumed to be a dictionary of projection names to proj4 objects.

If from is left undefined or null, the CRS will be detected from the GeoJSON's crs property and looked up in the crss dictionary.

toWgs84(geojson, from, crss)

Shortcut equivalent to

reproject(geojson, from, proj4.WGS84, crss)

detectCrs(geojson, crss)

Detects the CRS defined in the given GeoJSON and returns the corresponding proj4 projection instance from crss. If no CRS is defined in the GeoJSON, or the defined CRS isn't present in crss, an error is thrown.

reverse(geojson)

Reverses the axis order of the coordinates in the given GeoJSON, such that x becomes y and y becomes x.

Keywords

FAQs

Package last updated on 31 Oct 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc