How to use proj4 - 10 common examples

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
// Tests Measurement
///////////////////////////////////////////
proj4(epsg['4269'], epsg['4326'], point1)
proj4(epsg['4269'], point1)
proj4(epsg['4269'], epsg['4326']).forward(point2)
proj4(epsg['4269'], epsg['4326']).inverse(point2)

///////////////////////////////////
// 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
github DefinitelyTyped / DefinitelyTyped / proj4 / proj4-tests.ts View on Github external
///////////////////////////////////
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 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 DefinitelyTyped / DefinitelyTyped / proj4 / proj4-tests.ts View on Github external
['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 DefinitelyTyped / DefinitelyTyped / proj4 / proj4-tests.ts View on Github external
// 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 johnfontaine / LasStreamReader / src / las.js View on Github external
function computeProjectionWithGeoTag(obj, projection_records) {
//    console.log("record is", record);
    let projection = {
      codes : {},
      got_projection : false,
      convert_to_wgs84 : null,
      target_proj : proj4.defs('EPSG:4326'),
      convert_elevation_to_meters : function(value) { return value; },
      convert_linear_to_meters : function(value) { return value; }
    };
    let geokey = new models.GeoKey(projection_records);
    projection.geokey = geokey;
    //get the EPSG code held in key 3072 or throw an error because this file lacks common decency.
    //See http://gis.stackexchange.com/questions/173111/converting-geotiff-projection-definition-to-proj4
    //todo: other projection options.
    //http://www.remotesensing.org/geotiff/spec/geotiff6.html#6.3.3.1
    let epsg_code;
    //check for Unit code
    if (geokey.has_epsg_projection) {
        epsg_code = String(epsg[String(geokey.epsg_projection_code)]);
        if (epsg_code && epsg_code !== "unknown") {
            projection.epsg_proj4 = epsg_code;
            projection.epsg_datum = geokey.epsg_projection_code;
github MinisterioPublicoRJ / inloco / src / components / LeafletMap / LeafletMap.js View on Github external
var   contour           = mapProperties && mapProperties.contour !== undefined ? mapProperties.contour : 'borda'
    var   color             = 'preto'
    let imageBounds         = mapProperties && mapProperties.currentCoordinates !== undefined ? mapProperties.currentCoordinates.bounds : null

    const regionStyle       = `plataforma:busca_regiao_${contour}_${color}`

    if (placeToCenter) {
        bounds = placeToCenter.geom.split(',')

        var west = parseInt(bounds[0])
        var east = parseInt(bounds[2])
        var south = parseInt(bounds[3])
        var north = parseInt(bounds[1])

        var prj1 = Proj4(firstProjection, secondProjection, [east, south])
        var prj2 = Proj4(firstProjection, secondProjection, [west, north])
        bounds = [[prj1[1], prj2[0]], [prj2[1], prj1[0]]]
    } else if (googleSearchCoord) {
        bounds = googleSearchCoord
    }

    var CQL_FILTER

    // This function gets the code to fill CQL filter
    const getCode = place => {
        var cd
        var operator = ' = '
        if (contour === 'opaco') {
            operator = ' <> '
        }
        switch (place.tipo) {
            case 'CRAAI':
github county-of-simcoe-gis / SimcoeCountyWebViewer / src / sidebar / components / tools / coordinates / Coordinates.jsx View on Github external
componentDidMount() {
    // LISTEN FOR MAP TO MOUNT
    window.emitter.addListener("mapLoaded", () => this.onMapLoad());

    // DISABLE PROPERTY CLICK
    window.disableParcelClick = true;

    // REGISTER MAP EVENTS
    this.onPointerMoveEvent = window.map.on("pointermove", this.onPointerMoveHandler);
    this.onMapClickEvent = window.map.on("click", this.onMapClick);
    this.onMapMoveEvent = window.map.on("moveend", this.onMapMoveEnd);

    // REGISTER CUSTOM PROJECTIONS
    proj4.defs([
      ["EPSG:26917", "+proj=utm +zone=17 +ellps=GRS80 +datum=NAD83 +units=m +no_defs "],
      ["EPSG:26717", "+proj=utm +zone=17 +ellps=clrk66 +datum=NAD27 +units=m +no_defs "]
    ]);
    register(proj4);

    // INITIAL EXTENT
    this.updateExtent();
  }
github county-of-simcoe-gis / SimcoeCountyWebViewer / src / helpers / helpers.js View on Github external
import Projection from "ol/proj/Projection.js";
import proj4 from "proj4";
import { register } from "ol/proj/proj4";
import { fromLonLat } from "ol/proj";
import { getVectorContext } from "ol/render";

//OTHER
import { parseString } from "xml2js";
import shortid from "shortid";
import ShowMessage from "./ShowMessage.jsx";
import URLWindow from "./URLWindow.jsx";
import mainConfig from "../config.json";
import { InfoRow } from "./InfoRow.jsx";

// REGISTER CUSTOM PROJECTIONS
proj4.defs([["EPSG:26917", "+proj=utm +zone=17 +ellps=GRS80 +datum=NAD83 +units=m +no_defs "]]);
register(proj4);

// UTM NAD 83
const _nad83Proj = new Projection({
  code: "EPSG:26917",
  extent: [194772.8107, 2657478.7094, 805227.1893, 9217519.4415]
});

// APP STAT
export function addAppStat(type, description) {
  if (mainConfig.includeAppStats === false) return;

  // IGNORE LOCAL HOST DEV
  if (window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1") return;

  const appStatsTemplate = (type, description) => `${mainConfig.appStatsUrl}opengis/${type}/${description}`;
github johnfontaine / LasStreamReader / src / las.js View on Github external
this.is_laz = false;
        this.check_laz = false;
        this.check_classification_lookup = false;
        this.has_classification_lookup_table = false;
        if (options) {
            this.point_record_options.transform_lnglat = options.transform_lnglat === false ? false : true; // raw | scaled | wgs
            this.point_record_options.parse_full_point_record = options.parse_full_point_record || false;
            if (options.filter) {
                //include a filter;;
            }
            if (options.projection && options.projection.epsg_datum) {
                let epsg_code = epsg[String(options.projection.epsg_datum)];
                this.projection = {
                    epsg_datum :  options.projection.epsg_datum,
                    epsg_code : epsg_code,
                    convert_to_wgs84 : new proj4(epsg_code, proj4.defs('EPSG:4326')),
                    convert_elevation_to_meters  : function(value) { return value }
                };
                //igore VLR projection data and use this one instead.
                this.got_projection = true;
            }
        }
    }
    _transform(data, encoding, callback) {

proj4

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

MIT
Latest version published 24 days ago

Package Health Score

86 / 100
Full package analysis

Similar packages