npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-red-contrib-proj4-geojson

v1.0.1

Published

A Node-Red node for performing geographic coordinate conversions

Downloads

132

Readme

node-red-contrib-proj4

A Node-Red node for performing conversions between different geographic coordinate reference systems (CRS) based on the Proj4js JavaScript library.

Purpose

This node is primarily intended for converting between coordinates provided in global coordinate reference systems such as World Geodetic System (WGS84) which is used by GPS, or WGS84 Psuedo-Mercator which is commonly used by web mapping platforms, and the local coordinate systems maintained by national mapping agencies to ensure optimal accuracy for applications in civil engineering and construction.

Usage

The user specifies a coordinate reference system to 'Convert from', and a second to 'Convert to'. When the node receives a payload with coordinates in an accepted format it will transform the values from the first CRS to the second.

The user first chooses a method for specifiying the two CRSs to use in the conversion. Selecting 'EPSG Codes' provides prepopulated dropdown lists.

EPSG Code

Alternatively users can select 'Proj / WKT string' in order to input the relevant proj-strings or well-known text (WKT) representations as found on epsg.io or spatialreference.org.

These strings can also be overridden by setting msg.firstCRS and/or msg.secondCRS to your preferred CRS strings in the message.

Proj WKT String

As with proj4.js library, coordinates can be provided as an object of the form {x:x,y:y} or an array of the form [x,y]. Additionally the node will parse the incoming message payload for coordinates identified by one of the following combinations of payload properties:

  • x,y: msg.payload.x and msg.payload.y
  • lat,lon: msg.payload.lon and msg.payload.lat
  • latitude,longitude: msg.payload.longitude and msg.payload.latitude
  • eastings,northings: msg.payload.eastings and msg.payload.northings
  • GeoJSON: msg.payload as a GeoJSON FeatureCollection, optionally set msg.payload.features as an array of GeoJSON Features.

When inputting GeoJSON, the node will transform all the coordinates found in the features array, keeping any other feature properties intact.

NOTE 1: GeoJSON only officially supports WGS84 / GPS (ESPG:4326), so if you want to be fully GeoJSON compliant you should use that as your target CRS.

NOTE 2: As an effect of only transforming point coordinates, very big features (e.g. lines spanning a significant part of the globe) may be distorted by the transformation. While all coordinate points will be transformed correctly, any lines connected between them may not be exactly preserved. A "straight line" in one coordinate system might not be straight in another - But GeoJSON lines will be expressed as straight lines in the new coordinate system as well.

Results will be returned on the msg.proj4_coords in the same format as they were received, either an object of the form {x:x,y:y}, as an array of the form [x,y], or (in the case of GeoJSON) as a GeoJSON object on msg.payload.

Example File

An example file has been provided which demonstrates common usage of the node. Access the example by navigating to the Node-Red editor's menu and selecting Export > Examples > node-red-contrib-proj4 > Coordinate Transformation.

Example Flow

Supported Coordinate Reference Systems

Currently the Proj4 node has presets for the following coordinate systems:

  • OSGB (EPSG:27700)
  • ITM (EPSG:2157)
  • Irish Grid (EPSG:29903)
  • NAD83 (EPSG:4269)
  • WGS84 / GPS (EPSG:4326)
  • WGS84 / Psuedo-Mercator (EPSG:3857)

Further details of different coordinate reference systems can be found on epsg.io.

Further Development

If you are interested in suggesting enhancements please raise an issue for review via GitHub.