3

I am trying to transform a GeoJSON object of a certain transformation (EPSG:28992) into my current map coordinate system (EPSG:4326). I have been trying to do a couple of things but none seem to work. I am currently trying to use proj4.js. A minimal example of my script can be found here:

http://jsfiddle.net/TimLucas/k69ujyev/5/

I am trying to find a method how I can transform my GeoJSON (Layer2) layer into the projection used in my map, as defined per the styles it should show up as green points. It somehow seems to have worked for the other layer (Layer1, red points). I tried to follow the various examples on openlayers.org (which suggest to use proj4.js), but this does not work for some reason. Can you please help me with what I am doing wrong?

Edit: I forgot to mention, the other projection is one that OL supports by default, so the problem here is using external projection systems...

Edit2: Found out that ArcMAP does not export this coord system very well. Changed it to the correct coords by hand but still does not show up, any suggestions? And does anyone have any suggestions on the easiest way to convert ESRI JSON to GeoJSON?

1 Answer 1

5

There is nothing wrong with your GeoJSON. You just have to define the default projection and the destination projection in the source for on-the-fly projection. Also, there is no need to save the projection objects in variables, like ProjectionNL, you can use the EPSG code of any projection, after it has been defined by Proj4JS. Of course, you can change up 'EPSG:28992' with ProjectionNL, whichever makes more sense to you.

var Layer2 = new ol.layer.Vector({
    source: new ol.source.GeoJSON({
        object: '{"type":"FeatureCollection",[...]}',
        defaultProjection: 'EPSG:28992',
        projection: 'EPSG:3857'
    }),
    style: styleFunction2
});

The projection property always has to be the destination projection (map projection), while you need to define the source projection in the defaultProjection parameter.

2
  • So that works, thanks a lot! Do you maybe have some suggestions on how to export the ESRI ArcMap layers in the correct way?
    – Tim.Lucas
    Jan 12, 2015 at 15:57
  • For me, the easiest way to convert between formats/projections is by QGIS. I think ArcMap is not that good in converting/exporting. Simply drag and drop your layer into it - right click and select export/save as - select GeoJson, your CRS, etc.
    – dkocich
    Jan 29, 2015 at 15:56

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.