3

This open data portal offers download as CSV file. For larger datasets, that's the only way to download the whole dataset in one go. The CSV format is pretty creative: the polygon geometry is in GeoJSON in the "geometry" column.

If I drag and drop this file to my QGIS 2.18.1, it does not render as something geometrical. If however, I change the name of the "geometry" column to "WKT", QGIS does in fact render it. It only works with the WKT header, which is ironical. If I try to add the same info with the "Add CSV layer", it does not recognize the geometry column, as you can only feed that dialog window with WKT format, not GeoJSON.

Is this somehow normal behavior or is it a QGIS bug? Is it a valid option to offer this kind of format to the world on an open data website, or should I raise an issue to change the geometry data to WKT format?

Direct link to example data. Data structure:

"id";"objectid";"geometry";"gisid";"naam";"shape";"shape_length";"shape_area"

"1";"800";"{""type"":""Polygon"",""coordinates"":[[[4.4322857553331,51.236057528816],...[4.4322857553331,51.236057528816]]]}";"LEZ_01";"Lage-emissiezone (LEZ)";"";"1015.8237876604";"29420.558095414"

  • Which version are you using? – George of all trades Feb 1 '17 at 9:39
  • Sorry! Edited my question to add that essential info. – joost schouppe Feb 1 '17 at 9:51
  • Non-geometry attributes should be part of the geojson. That does sound odd. I would argue that QGIS is being pretty valiant in trying to do something from an incorrectly formed file. – George of all trades Feb 1 '17 at 9:53
  • That said there is no schema as such for how data should be stored in CSV. In GIS the convention is to use WKT for geometry because if you were to use a format that can store attributes, you wouldn't need to have it in a CSV in the first place. – George of all trades Feb 1 '17 at 9:55
  • Right, so I understand the CSV should either have WKT geometry, or not be a CSV at all. Correct? – joost schouppe Feb 1 '17 at 9:59
2
  1. The "geometry" column as shown contains a list of complete and valid GeoJSON objects consistent with examples shown here: http://geojson.org/geojson-spec.html#appendix-a-geometry-examples.
  2. CSV as such has no specification, so it is not technically invalid to have GeoJSON objects stored in a column. There is a GeoCSV specification, with which the supplied data does not comply (non-point geometry should be in WKT format). In general, CSVs containing geometry use WKT.
  3. QGIS not recognising a column called "geometry"containing GeoJSON objects is not a bug, although possibly it could be considered a limitation.
  4. QGIS recognising a column called "WKT" containing GeoJSON objects could be considered a bug as this is counter-intuitive.

I would recommend filing a request to QGIS to support GeoJSON objects within a column called "geometry" and an option for recognising GeoJSON in the add delimited layer dialog. Support for GeoJSON in a column named "WKT" should be removed.

I would also recommend that the data supplier create CSVs that are usable by the majority of GIS software i.e. storing data in WKT format. Alternatively, they could provide the data as standalone .geojson files containing both attributes and geometries.

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.