How to use the proj4.WGS84 function in proj4

To help you get started, we’ve selected a few proj4 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / proj4 / proj4-tests.ts View on Github external
///////////////////////////////////
// Named Projections
///////////////////////////////////
proj4.defs('WGS84', epsg['4326'])
proj4.defs([
  ['EPSG:4326', epsg['4326']],
  ['EPSG:4269', epsg['4269']]
])
proj4.defs('urn:x-ogc:def:crs:EPSG:4326', proj4.defs('EPSG:4326'))

///////////////////////////////////
// Utils
///////////////////////////////////
// WGS84
proj4.WGS84

// Proj
proj4.Proj('WGS84')

// toPoint
proj4.toPoint([1, 2])
proj4.toPoint([1, 2, 3])
proj4.toPoint([1, 2, 3, 4])

// Point
// WARNING: Deprecated in v3
proj4.Point([1, 2, 3, 4])
github OpenGeoscience / geojs / src / transform.js View on Github external
transform.vincentyDistance = function (pt1, pt2, gcs, baseGcs, ellipsoid, maxIterations) {
  baseGcs = baseGcs || 'EPSG:4326';
  ellipsoid = ellipsoid || proj4.WGS84;
  maxIterations = maxIterations || 100;
  gcs = gcs || baseGcs;
  if (gcs !== baseGcs) {
    var pts = transform.transformCoordinates(gcs, baseGcs, [pt1, pt2]);
    pt1 = pts[0];
    pt2 = pts[1];
  }
  var a = ellipsoid.a,
      b = ellipsoid.b || ellipsoid.a * (1.0 - (ellipsoid.f || 1.0 / ellipsoid.rf)),
      f = ellipsoid.f || (ellipsoid.rf ? 1.0 / ellipsoid.rf : 1.0 - b / a),
      // baseGcs must be in degrees or this will be wrong
      phi1 = pt1.y * Math.PI / 180,
      phi2 = pt2.y * Math.PI / 180,
      L = (((pt2.x - pt1.x) % 360 + 360) % 360) * Math.PI / 180,
      U1 = Math.atan((1 - f) * Math.tan(phi1)),  // reduced latitude
      U2 = Math.atan((1 - f) * Math.tan(phi2)),
github anthill / open-moulinette / insee-iris / index.js View on Github external
// for Guadeloupe, Saint-Barthélemy, Saint-Martin, Martinique 
proj4.defs["EPSG:32620"] = "+proj=utm +zone=20 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ";
var UTM20 = proj4.defs["EPSG:32620"];
var projectorUTM20 = proj4(UTM20, proj4.WGS84);

// for Guyane
proj4.defs["EPSG:2972"] = "+proj=utm +zone=22 +ellps=GRS80 +towgs84=2,2,-2,0,0,0,0 +units=m +no_defs ";
var UTM22 = proj4.defs["EPSG:2972"];
var projectorUTM22 = proj4(UTM22, proj4.WGS84);

// for Réunion
proj4.defs["EPSG:2975"] = "+proj=utm +zone=40 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ";
var UTM40 = proj4.defs["EPSG:2975"];
var projectorUTM40 = proj4(UTM40, proj4.WGS84);


var output = fs.createWriteStream("data/iris.json");
output.write('{"type": "FeatureCollection", "features": [\n');
 

var shapefiles = [];

(new Promise(function (resolve, reject) {
   glob("data/**/*.shp", {}, function (err, files) {
      if (err) {
         reject(err);
      } else {
         resolve(files);
      }
   });
github anthill / open-moulinette / insee-iris / index.js View on Github external
"use strict";

require("es6-shim");

var fs =  require("fs");
var glob = require("glob");
var shapefile = require('shapefile');
var Map = require('es6-map');
var proj4 = require('proj4');


// Metropolitan France
proj4.defs["EPSG:2154"] = "+proj=lcc +lat_1=49 +lat_2=44 +lat_0=46.5 +lon_0=3 +x_0=700000 +y_0=6600000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs";
var epsg2154 = proj4.defs['EPSG:2154'];
var projector = proj4(epsg2154, proj4.WGS84);


// for Guadeloupe, Saint-Barthélemy, Saint-Martin, Martinique 
proj4.defs["EPSG:32620"] = "+proj=utm +zone=20 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ";
var UTM20 = proj4.defs["EPSG:32620"];
var projectorUTM20 = proj4(UTM20, proj4.WGS84);

// for Guyane
proj4.defs["EPSG:2972"] = "+proj=utm +zone=22 +ellps=GRS80 +towgs84=2,2,-2,0,0,0,0 +units=m +no_defs ";
var UTM22 = proj4.defs["EPSG:2972"];
var projectorUTM22 = proj4(UTM22, proj4.WGS84);

// for Réunion
proj4.defs["EPSG:2975"] = "+proj=utm +zone=40 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ";
var UTM40 = proj4.defs["EPSG:2975"];
var projectorUTM40 = proj4(UTM40, proj4.WGS84);
github perliedman / gis-nerd-tools / src / projections.js View on Github external
initialize: function() {
    this.projections = {
      'EPSG:4326': proj4.WGS84
    };
  },
github iTowns / itowns / src / Core / Math / Ellipsoid.js View on Github external
import * as THREE from 'three';
import proj4 from 'proj4';
import Coordinates from 'Core/Geographic/Coordinates';

export const ellipsoidSizes = new THREE.Vector3(
    proj4.WGS84.a,
    proj4.WGS84.a,
    proj4.WGS84.b);

const normal = new THREE.Vector3();

class Ellipsoid {
    constructor(size = ellipsoidSizes) {
        this.size = new THREE.Vector3();
        this._radiiSquared = new THREE.Vector3();
        this._invRadiiSquared = new THREE.Vector3();

        this.setSize(size);
    }

    geodeticSurfaceNormal(cartesian, target = new THREE.Vector3()) {
        return cartesian.toVector3(target).multiply(this._invRadiiSquared).normalize();
    }
github perliedman / gis-nerd-tools / src / coordinates.js View on Github external
show: function(latlng) {
    var el = L.DomUtil.get(this._el),
        lnglat = [latlng.lng, latlng.lat],
        pname,
        proj,
        transform,
        c,
        li;

    el.innerHTML = '';
    for (pname in this._projs.projections) {
      proj = this._projs.projections[pname];
      transform = proj4(proj4.WGS84, proj);
      c = transform.forward(lnglat);
      c = c.map(this._formatCoordinateValue);
      li = L.DomUtil.create('li');
      li.innerHTML = '<strong>' + pname + '</strong>: ' + c[0] + ' ' + c[1];
      el.appendChild(li)
    }
  },
github iTowns / itowns / src / Core / Math / Ellipsoid.js View on Github external
import * as THREE from 'three';
import proj4 from 'proj4';
import Coordinates from 'Core/Geographic/Coordinates';

export const ellipsoidSizes = new THREE.Vector3(
    proj4.WGS84.a,
    proj4.WGS84.a,
    proj4.WGS84.b);

const normal = new THREE.Vector3();

class Ellipsoid {
    constructor(size = ellipsoidSizes) {
        this.size = new THREE.Vector3();
        this._radiiSquared = new THREE.Vector3();
        this._invRadiiSquared = new THREE.Vector3();

        this.setSize(size);
    }

    geodeticSurfaceNormal(cartesian, target = new THREE.Vector3()) {
        return cartesian.toVector3(target).multiply(this._invRadiiSquared).normalize();
github OpenGeoscience / geojs / src / util / common.js View on Github external
isObject: function (value) {
    var type = typeof value;
    return value !== null && value !== undefined && (type === 'object' || type === 'function');
  },

  ///////////////////////////////////////////////////////////////////////////
  /*
   * Utility member properties.
   */
  ///////////////////////////////////////////////////////////////////////////

  /**
   * Radius of the earth in meters, from the equatorial radius of SRID 4326.
   * @memberof geo.util
   */
  radiusEarth: proj4.WGS84.a
};

module.exports = util;

proj4

Proj4js is a JavaScript library to transform point coordinates from one coordinate system to another, including datum transformations.

MIT
Latest version published 1 month ago

Package Health Score

86 / 100
Full package analysis

Similar packages