geojson-flip

Flip lon/lat in geojson documents

Usage no npm install needed!

<script type="module">
  import geojsonFlip from 'https://cdn.skypack.dev/geojson-flip';
</script>

README

Build Status Coverage Status

GeoJson-flip

I had to make this little util out of necessity. It only flips 2d geojson.

Geojson-spec says that `The order of elements must follow x, y, z order (easting, northing, altitude for coordinates in a projected coordinate reference system, or longitude, latitude, altitude for coordinates in a geographic coordinate reference system). Map websites like geojson.io and github gist (*.geojson) uses this order of coordinates. MongoDB also uses lon lat.

But applications differ as this web page show and should you encounter an issue with coordinates on the wrong, then flip em.

Usage

var flip = require("geojson-flip").flip;

console.log(
    flip({
        "type": "FeatureCollection",
        "features": [
            {
                "type": "Feature",
                "geometry": {
                    "type": "Point",
                    "coordinates": [125.6, 10.1]
                },
                "properties": {}
            }
        ]
    }))
    
/**
{
        "type": "FeatureCollection",
        "features": [
            {
                "type": "Feature",
                "geometry": {
                    "type": "Point",
                    "coordinates": [10.1, 125.6]
                },
                "properties": {}
            }
        ]
    }

**/