1

I have a geojson file in UTM coordinates (WGS_1984_UTM_Zone_39N) and I'm trying to load it via openlayers.

I have the below code and it's working with long/lat coordinates but not with UTM:

proj4.defs('ESRI:53009', '+proj=moll +lon_0=0 +x_0=0 +y_0=0 +a=6371000 ' +
    '+b=6371000 +units=m +no_defs');

// Configure the Sphere Mollweide projection object with an extent,
// and a world extent. These are required for the Graticule.
var sphereMollweideProjection = new ol.proj.Projection({
    code: 'ESRI:53009',
    extent: [-9009954.605703328, -9009954.605703328,
        9009954.605703328, 9009954.605703328],
    worldExtent: [-179, -89.99, 179, 89.99]
});

var map = new ol.Map({
    keyboardEventTarget: document,
    layers: [
        new ol.layer.Vector({
            source: new ol.source.Vector({
                url: 'countries.json',
                format: new ol.format.GeoJSON()
            })
        })
    ],
    target: 'map',
    view: new ol.View({
        center: [0, 0],
        projection: sphereMollweideProjection,
        resolutions: [65536, 32768, 16384, 8192, 4096, 2048],
        zoom: 1
    })
});

new ol.Graticule({map: map});

My geojson file:

{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[241247.75229999982,3356026.0593],[241247.52570000011,3356022.5901999995],[241266.4857999999,3356003.4778000005],[241253.77740000002,3355990.8706],[241240.8663999997,3356005.2499],[241228.51240000036,3355995.1236000005],[241214.33559999987,3356010.1105000004],[241241.2714999998,3356034.1602999996],[241247.75229999982,3356026.0593]]]},"properties":{"RefName":"15"}},

I did a search and found that I have to use 'ESRI:32639', but it's still not working.

I'm totally new on web GIS and openlayers and I don't understand what is wrong in my code.

2 Answers 2

2

You need to re-project your data to WGS-84 (4326) as that is the GeoJSON standard. All software using GeoJSON expects the data in that projection. Since the GeoJSON is in Lat/ Long decimal degrees, your UTM Meters coordinates won't show up where you expect them.

" The coordinate reference system for all GeoJSON coordinates is a geographic coordinate reference system, using the World Geodetic System 1984 (WGS 84) [WGS84] datum, with longitude and latitude units of decimal degrees." https://www.rfc-editor.org/rfc/rfc7946#page-12

1

Valid GeoJSON only has one CRS

  1. Coordinate Reference System

The coordinate reference system for all GeoJSON coordinates is a geographic coordinate reference system, using the World Geodetic System 1984 (WGS 84) [WGS84] datum, with longitude and latitude units of decimal degrees. This is equivalent to the coordinate reference system identified by the Open Geospatial Consortium (OGC) URN urn:ogc:def:crs:OGC::CRS84. An OPTIONAL third-position element SHALL be the height in meters above or below the WGS 84 reference ellipsoid. In the absence of elevation values, applications sensitive to height or depth SHOULD interpret positions as being at local ground or sea level.

Note: the use of alternative coordinate reference systems was specified in [GJ2008], but it has been removed from this version of the specification because the use of different coordinate reference systems -- especially in the manner specified in [GJ2008] -- has proven to have interoperability issues. In general, GeoJSON processing software is not expected to have access to coordinate reference system databases or to have network access to coordinate reference system transformation parameters. However, where all involved parties have a prior arrangement, alternative coordinate reference systems can be used without risk of data being misinterpreted.

Ref The GeoJSON Format

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.