I am trying to export a gml layer to geojson with lat/lng as the preferred coordinate system. So what I did was a 'save as' on the layer with selected CRS: 'IGNF: WGS84G'.

Now I was hoping it converted the coordinates of the GML but it did not.

Part of GML data:

<gml:PolygonPatch>
    <gml:exterior>
        <gml:LinearRing>
            <gml:posList>264124.695 566223.95</gml:posList>
        </gml:LinearRing>
    </gml:exterior>
</gml:PolygonPatch>

Part of converted JSON data:

"geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 264124.695, 566223.95 ] ] ] ] }

As you can see the coordinates remain the same. I tried other formats in order to test if something is converted but not. I am not an expert on GIS transformations so probably I did something wrong.

Environment: Windows 2012 Standard running inside VMWare Fusion QGIS version: 2.0.1 - Dafour 64 Bit

A screenshot of my actions:

enter image description here

The GML data you provided is not WGS84, but in a projected CRS using metres as units. It is usually specified inside the gml document with

srsName="http://www.opengis.net/def/crs/EPSG/0/...."

Rightclick -> Set CRS for layer should be set to the correct CRS. It might be set currently to EPSG:4326 which is obviously wrong. WGS84 data must always be inside +/- 180/90°.


EDIT 1

Until you have fixed the broken installation, try a custom CRS with

+proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000 +ellps=bessel +towgs84=565.417,50.3319,465.552,-0.398957,0.343988,-1.8774,4.0725 +units=m +no_defs

for your layer.

And +proj=longlat +datum=WGS84 +no_defs for the output if that fails too.


EDIT 2

Testing the data from the download link you gave on 32-bit QGIS Dufour, the gml layer is correctly loaded as EPSG:28992. Saving as Geojson with EPSG:4326 works as expected. The extent of the geojson is xMin,yMin 3.30794;50.7504 : xMax,yMax 7.2275;53.5764

  • Thank you for you suggestion. I checked it and it is: <gml:Envelope srsName="EPSG:28992" srsDimension="2"> I saved the project and changed the project settings to WGS84. Then the coordinate system changes to lat/lng. The visible layer becomes somehow 'invisible' because I guess the layer self remains in meters. I quickly did a conversion (layer save as) but it remains meters. I will keep on investigating. – Stackbever Dec 12 '13 at 12:13
  • Have you set the layer CRS to EPSG:28992 too? Otherwise it will not work. – AndreJ Dec 12 '13 at 13:40
  • Unfortunately this newbie QGIS-gisser cannot find a layer setting having this identity. See my screenshot for CRS-ses on my system when filtering on EP. Luckily my ogr2ogr conversion (see my other comment) seems to work and gives identical coordinates when using an GML to KML online converter. If I reload my converted GeoJSON layer into QGIS it shows some stretching horizontally when compared to the original GML, but it seems to work. – Stackbever Dec 12 '13 at 14:09
  • I guess you will not get lucky with that broken installation. Have a look into the postinstall.log file to see why the CRS are not updated. But that should be another question. – AndreJ Dec 12 '13 at 15:59
  • Thanks for the update. No the installation failed on my host (which is a mac) but its my own fault because I have incompatible prerequisites (Python mismatch regarding matplotlib for example). The reason was I wanted to re-test it on another environment. On my Windows 2012 server it is running (I run 'as administrator'). I tested it with your configuration but the coordinates remain unchanged (many thanks again for your help). I noticed the GUI is not working flawless: sometimes dropdown selections are missed and need to be reselect. Maybe it is a Windows 2012 64 bit thing. – Stackbever Dec 12 '13 at 19:46

Use EPSG:4326 to export the data if you want lat/lng. Not everything called "something WGS84 something" is in lat/lng.

  • The strange thing is I can not find this CRS. If I filter on EPSG or 4326 it only shows 2065, 4818, 4156, 5221, 5513, 5514 CRS'ses. I tried installing it on my Host Mac OsX to (quickly) check if it is an installation issue but failed due to wrong Python dependencies. Thanks for your suggestion by the way. – Stackbever Dec 12 '13 at 12:04
  • Could you provide a screenshot of your CRS picker dialog? – underdark Dec 12 '13 at 12:09
  • I have attached a screenshot to my original posting which is better viewable when downloaded. – Stackbever Dec 12 '13 at 13:02
  • Due to my failed installation of QGIS on my Mac I found the excellent utility called 'ogr2ogr'(part of GDAL which is a prerequisite on a Mac installation). See mapbox.com/tilemill/docs/guides/gdal for initialising this utility. The following command nicely converted my gml file into a Geo JSON format with lat/lng coordinates: 'ogr2ogr -t_srs EPSG:4326 -f "GeoJSON" {YOUR OUTPUT FILENAME}.json {YOUR INPUT FILENAME}.gml'. – Stackbever Dec 12 '13 at 13:29

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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