1

i am relative new to the whole gis world. To display some statistics in Leaflet on my website i choosed to use some district zones provided by the regional government (Berlin / Germany) as Shapefile (ETRS89 / UTM zone 33N) and converted them into GeoJson.

My Workflow was Qgis [Version 3.25] -> load Shapefile (ETRS89 / UTM zone 33N) -> reproject layer into Target: EPSG:4326 - WGS84 -> save as new file -> conversion to GeoJson -> save as new file

Problem


Leaflet is running and consumes the GeoJson data and displays the Districts as Polygons. The only Problem is - the districts are now not in Berlin / central europe but the middle east. I recognized that the coordinates values of the GeoJson polygons (lat,lon) are switched (lon,lat).

So i looked into Qgis once again and loaded the original shape file.

  • Project Properties are
    • Coordinates:ETRS89 / UTM zone 33N
    • Authority ID: EPSG:25833

When i right click into the the districts or more specific the Center of Berlin then Qgis provides Coordinates with copy coordinate... enter image description here

  • MAP CRS - EPSG:25833 (392365,5820314)
  • WGS84 CRS - EPSG:25833 (13.39865,52.51694) <- Default?

Her recognized that the WGS84 conversion for that single coordinate is also wrong. Example Coordinate for Center of Berlin in the shape file:

  • wrong: WGS84 CRS - EPSG:25833 (13.39865,52.51694) <- currently displayed in Qgis (somewhere in the middle east).
  • should be: WGS84 CRS - EPSG:25833 (52.51694, 13.39865) <- This looks more like the Center of Berlin!

Question


So my Question is how to correct that projection? I tried the Qgis processor swap X and Y coordinates but it only turned my districts upside down and to another area in the world. I could write a python script to change every polygon point in the GeoJson File but that seems unnecessary.

Do i missed to change the right Projection in Qgis for the [ETRS89 / UTM zone 33N] -> [Target: EPSG:4326 - WGS84] reprojection layer ? Moreover the Re-projection processor determines sometimes my input file (layer) also as EPSG:32633 automatically. And is it possible to reproject and export as GeoJson at once?

2

2 Answers 2

4

The context menu to copy coordinates shown is offering to let you copy the coordinates of the point you clicked on the QGIS map. That will always show longitude / latitude (in that order) for geographic coordinates and does not indicate a problem with your data layers. That does show that the original shapefile seems correct - longitude 13 / latitude 52.5 is Berlin. If those coordinates were reversed, you would have points somewhere around the Gulf of Aden, south of Yemen. If that is the result you are seeing, then your coordinates are probably reversed.

As @Babel suggested, you can transform (reproject) the coordinates of the original shapefile when you save it out as a GeoJSON layer (all in one step).

enter image description here

2

Alright first of all thanks to all answers. Without these Answers i would not be able not understand the Issue. Its seems i have done "mostly" everything right.


Quick Answer: I had to format the geoJson Data once again with L.geoJSON(data).addTo(map), because simply consuming the geoJson Polygon Array via L.polygon(array) will reverse the lat/lon.

The Problem

While i followed the Example in the Leaflet Docs and simply let LeafLet consume L.polygon(array) Array. It seems there was a Problem that these Array will be reversed (see Issue at Git).


Old Code:

function set_lor_plr(data){
var map = set_base_map();

// set type
var lor_locations:GeoJSON.FeatureCollection<GeoJSON.Geometry> = data[0];

lor_locations.features.forEach(shape => {
    // get Geometry
    var geom:GeometryObject = shape.geometry;
    // get the array of polygons
    var poly_arr = Object.values(geom)[1];
    //console.log(poly_arr)
    L.polygon(poly_arr,{color: "#ff7800", weight: 1}).addTo(map)
});

};

The Districts appear in the Gulf of Aden: enter image description here


New Code:

function set_lor_plr(data){
    var map = set_base_map();
    L.geoJSON(data).addTo(map)
};

Thats it !! enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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