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

gbify-geojson

v0.2.1

Published

Reproject GeoJSON between OSGB36 GB National Grid and WGS84

Downloads

57

Readme

gbify-geojson

Build Status npm version

Reproject GeoJSON between OSGB36 GB National Grid and WGS84 CRSs.

Description

The default reference system used by GeoJSON to describe the geospatial data contained is usually ESPG:4326, cartesian coordinates are referenced using the WGS84 datum.

With this project we can reproject to or from the coordinate reference system WGS84 and the projected local coordinate system OSGB36, EPSG:27700, British National Grid. The library will reproject all coordinate data in a GeoJSON object to / from these reference systems.

This library uses proj4js to do the tranformation.

An example GeoJSON reprojected;

// WGS84
{
  "type": "Feature",
  "properties": {
    "popupContent": "Golden Square, Soho, London."
  },
  "geometry": {
    "type": "Point",
    "coordinates": [
      -0.1371467113494873,
      51.511566985991124
    ]
  }
}

// OSGB36
{
  "type": "Feature",
  "properties": {
    "popupContent": "Golden Square, Soho, London."
  },
  "geometry": {
    "type": "Point",
    "coordinates": [
      529368.34,
      180826.93
    ]
  }
}

Caveats

In using this project, please note the following points - these may be fixed in future versions.

  • We ignore the CRS property specified by GeoJSON spec. This has no impact on tranformation and is removed if present.
  • A bounding box member is reprojected, this probably is not correct.

Web example

This library is used by gb-geojson project that allows you to view, create, edit, transform GeoJSON map data in British National Grid reference system and WGS84. The app reprojects between each CRS when updated, you can try it out http://rob-murray.github.io/gb-geojson/.

Getting started

You can get hold of the code with npm and it should work fine with browserify. Or you can just manually import the source.

Dependency management

With npm:

$ npm install gbify-geojson

Interface

Given the library is loaded

> gbify = require('gbify-geojson')

toOSGB36(geoJson)

Reproject the geoJson object to EPSG:27700.

> var point = {"type":"Feature","properties":{"popupContent":"Golden Square, Soho, London."},"geometry":{"type":"Point","coordinates":[-0.1371467113494873, 51.511566985991124]}}
> gbify.toOSGB36(point)
{ type: 'Feature',
  properties: { popupContent: 'Golden Square, Soho, London.' },
  geometry:
   { type: 'Point',
     coordinates: [ 529368.34, 180826.93 ] } }

toWGS84(geoJson)

Reproject the geoJson object to EPSG:4326.

> var poly = {"type":"Feature","properties":{"popupContent":"I am SU43."},"geometry":{"type":"Polygon","coordinates":[[[440000,130000],[450000,130000],[450000,140000],[440000,140000],[440000,130000]]]}}
> gbify.toWGS84(poly) // JSON.stringify(gbify.toWGS84(poly))
'{"type":"Feature","properties":{"popupContent":"I am SU43."},"geometry":{"type":"Polygon","coordinates":[[[-1.43051,51.067945],[-1.287804,51.067163],[-1.286421,51.157077],[-1.429404,51.157861],[-1.43051,51.067945]]]}}'

Development

Run tests

Run the tests with mocha and expect.js.

$ npm test

Alternatives

The excellent reproject library was a basis for building this specific OS GB flavour.

GDAL can do this also with something like this to reproject OSGB36 > WGS84.

$ ogr2ogr -s_srs EPSG:27700 -f "GeoJSON" output.json input.json -t_srs EPSG:4326

Contributions

Please use the GitHub pull-request mechanism to submit contributions.

License

This project is available for use under the MIT software license. See LICENSE