30

If I have a GEOJson file, for example a file named test.js with inside the following:

{ "type": "FeatureCollection",
"features": [
{ "type": "Feature",
  "geometry": {"type": "Point", "coordinates": [102.0, 0.5]},
  "properties": {"prop0": "value0"}
  },
{ "type": "Feature",
  "geometry": {
    "type": "LineString",
    "coordinates": [
      [102.0, 0.0], [103.0, 1.0], [104.0, 0.0], [105.0, 1.0]
      ]
    },
  "properties": {
    "prop0": "value0",
    "prop1": 0.0
    }
  },
{ "type": "Feature",
   "geometry": {
     "type": "Polygon",
     "coordinates": [
       [ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0],
         [100.0, 1.0], [100.0, 0.0] ]
       ]
   },
   "properties": {
     "prop0": "value0",
     "prop1": {"this": "that"}
     }
   }
 ]
}

how to open it with QGIS?

I open QGIS, press "add vector layer", choose "File" but I am not able to open it.

If I choose GEOJson format, my file is not showed in browser window.

If I do not specify input type, I get the error: "your file is not valid or recognized data source".

How have I to format this file?

It seems there is a lack of documentation about this topic.

1
  • 1
    To see the file in the file browser, it should have .geojson extension Commented Jul 4, 2014 at 17:42

3 Answers 3

30

Just Drag'n Drop the file in qgis, be aware that Qgis doesn't support mixed types in the same file (point, line, poly) and it will open only the first type found. In the example bellow with your geojson file, I imported each type at a time. enter image description here

0
19

As of QGIS 2.10.1 (early 2015) mixed-type geojson files are supported. When the file is opened, a dialog to select the desired geometry type will be displayed. This example loads three separate layers from the example file posted in the question:

enter image description here

3
  • 1
    please expand on this what version QGIS 2.8.1?
    – Mapperz
    Commented May 21, 2015 at 2:17
  • I just spent 15 minutes searching and can find no documentation for when it became supported. Based on the previous answer at 2012, one would think since then. I checked the changelogs for QGIS, OGR, and the json-c library and could find no reference to enabling of mixed type support. However I did find github.com/akvo/akvo-flow/issues/1070 which shows a QGIS screenshot of adding a mixed type and the resulting dialog to choose which type to import. While it would be nice to have documentation, I would not expect this answerer who might have simply made the observation to research it.
    – Chris W
    Commented May 21, 2015 at 7:57
  • However it's unclear if that's what this answer is supposed to mean, or if it is implying that the file can be opened as a mixed geometry type in a single layer in QGIS (which is unlikely). To improve the answer, please expand on what you mean by "are supported" and which version you have at least tested this.
    – Chris W
    Commented May 21, 2015 at 8:02
0

Minor Detail - but I've found the file extension has to be .geojson rather than .js

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.