Giter VIP home page Giter VIP logo

swiss-projection's Introduction

swiss-projection

Convert from LV03(EPSG:21781) and LV95(EPSG:2056) to WGS84(EPSG:4326)

Uses the algorithm from Approximate formulas for the transformation between Swiss projection coordinates and WGS84 (PDF).

Usage

import {
  LV03toWGS,
  LV95toWGS,
  WGStoLV03,
  WGStoLV95,
} from 'swiss-projection'

Takes any GeoJSON FeatureCollection, Feature or Geometry as well as coordinates

Examples

  • Feature
const bs_lv95 = {"type":"Feature","properties":{"KTNR":12,"KTNAME":"Basel-Stadt"},"geometry":{"type":"Polygon","coordinates":[[[2618243,1270052],[2616262,1267990],[2614711,1267840],[2614602,1267872],[2613766,1265748],[2613671,1265408],[2611744,1263231],[2611346,1263338],[2610925,1264472],[2608775,1265954],[2608770,1268212],[2611314,1271031],[2613986,1269877],[2615583,1271829],[2618243,1270052]]]}}

const bs_wgs = LV95toWGS(bs_lv95)
// {"type":"Feature","properties":{"KTNR":12,"KTNAME":"Basel-Stadt"},"geometry":{"type":"Polygon","coordinates":[[[7.68112,47.580912],[7.654713,47.562419],[7.6341,47.561106],[7.632653,47.561397],[7.621479,47.542312],[7.620207,47.539256],[7.594557,47.519714],[7.589275,47.520683],[7.583714,47.530889],[7.555192,47.54425],[7.55517,47.564558],[7.589046,47.589872],[7.624531,47.579442],[7.645826,47.596962],[7.68112,47.580912]]]}}
  • Geometry
const polygon_lv95 = {"type":"Polygon","coordinates":[[[2618243,1270052],[2616262,1267990],[2614711,1267840],[2614602,1267872],[2613766,1265748],[2613671,1265408],[2611744,1263231],[2611346,1263338],[2610925,1264472],[2608775,1265954],[2608770,1268212],[2611314,1271031],[2613986,1269877],[2615583,1271829],[2618243,1270052]]]}

const polygon_wgs = LV95toWGS(polygon_lv95)
// {"type":"Polygon","coordinates":[[[7.68112,47.580912],[7.654713,47.562419],[7.6341,47.561106],[7.632653,47.561397],[7.621479,47.542312],[7.620207,47.539256],[7.594557,47.519714],[7.589275,47.520683],[7.583714,47.530889],[7.555192,47.54425],[7.55517,47.564558],[7.589046,47.589872],[7.624531,47.579442],[7.645826,47.596962],[7.68112,47.580912]]]}
  • coordinates
const coordinates_lv95 = [[[2618243,1270052],[2616262,1267990],[2614711,1267840],[2614602,1267872],[2613766,1265748],[2613671,1265408],[2611744,1263231],[2611346,1263338],[2610925,1264472],[2608775,1265954],[2608770,1268212],[2611314,1271031],[2613986,1269877],[2615583,1271829],[2618243,1270052]]]

const coordinates_wgs = LV95toWGS(coordinates_lv95)
// [[[7.68112,47.580912],[7.654713,47.562419],[7.6341,47.561106],[7.632653,47.561397],[7.621479,47.542312],[7.620207,47.539256],[7.594557,47.519714],[7.589275,47.520683],[7.583714,47.530889],[7.555192,47.54425],[7.55517,47.564558],[7.589046,47.589872],[7.624531,47.579442],[7.645826,47.596962],[7.68112,47.580912]]]

CLI usage

To be used with ndjson-cli

npm install swiss-projection -g

scripts:

  • lv03ToWgs
  • lv95ToWgs
  • wgsToLv03
  • wgsToLv95

Example

curl https://raw.githubusercontent.com/idris-maps/swiss-geodata-2018/master/data/cantons.json \
  | ndjson-split 'd.features' \
  | lv95ToWgs

swiss-projection's People

Contributors

dependabot[bot] avatar idris-maps avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.