I'm simply trying to import this feature directly into QGIS 3.16.3-Hannover as a new vector layer:


When loading it into a web browser, it shows the GeoJSON object as follows:

geojson object

Well, it's not directly a GeoJSON as it's "encapsulated" as the first (and only) element of the JSON array called results.
Which is probably the source of the following problem...

Because when trying to load it in QGIS*, I first get this message:

Download with "Protocol" source type has failed, do you want to try the "File" source type?

and if I click "No", it then shows this error:

Invalid Data Source: /vsicurl/https://api3.geo.admin.ch/rest/services/api/MapServer/find?layer=ch.swisstopo.swissboundaries3d-land-flaeche.fill&searchText=ch&searchField=id&returnGeometry=true&geometryFormat=geojson is not a valid or recognized data source.

How could I tell QGIS to first unpack the first element of the results array so that it can (hopefully) read the GeoJSON feature?

Changing the protocol type from HTTP/HTTPS/FTP to GeoJSON does help, but then the feature is not properly loaded on the table of content (it has no geometry):

no geometry feature loaded

*I'm trying to load it through the Data Source Manager > Vector > Source Type: "Protocol: HTTP(S), cloud, etc..." and by simply pasting the URL into, well, the URI field.

This is the API doc: https://api3.geo.admin.ch/services/sdiservices.html#find


3 Answers 3


It may be convenient to use a VRT file if you often use the same remote layer in different QGIS projects instead of copying/pasting it in each of them.

Put in file myvrt_demo.vrt the following content and drag and drop the vrt file within QGIS

    <OGRVRTLayer name="swissboundaries3d_land_flaeche_fill">
  • Thanks for sharing this very nice hint which will for sure be helpful for saving complex requests. Commented Oct 5, 2021 at 16:35

Looks like GeoJSON is a little confusing for QGIS.

Using "geometryFormat" rather than Type


Is working for certain urls


enter image description here

  • Hmm, ok then, so it's the /find endpoint which seems to encapsulate the results in a so called results array here. Without that endpoint, it's indeed working well. I also fix my post, it was a typo from my side when writing geometryType as a parameter instead of geometryFormat. Commented Oct 4, 2021 at 22:01

QGIS may have some problem with connecting to services but in this case I fear that the result would be failure in any case. GDAL does not find geometry nor attributes from this JSON.

ogrinfo "https://api3.geo.admin.ch/rest/services/api/MapServer/find?layer=ch.swisstopo.swissboundaries3d-land-flaeche.fill&searchText=ch&searchField=id&returnGeometry=true&geometryType=geojson" -al
INFO: Open of `https://api3.geo.admin.ch/rest/services/api/MapServer/find?layer=ch.swisstopo.swissboundaries3d-land-flaeche.fill&searchText=ch&searchField=id&returnGeometry=true&geometryType=geojson'
      using driver `GeoJSONSeq' successful.

Layer name: GeoJSONSeq
Geometry: Unknown (any)
Feature Count: 1
Layer SRS WKT:
    DATUM["World Geodetic System 1984",
        ELLIPSOID["WGS 84",6378137,298.257223563,
        AXIS["geodetic latitude (Lat)",north,
        AXIS["geodetic longitude (Lon)",east,
Data axis to CRS axis mapping: 2,1

Test in geojsonlint.com returns result "Invalid GeoJSON Line 1: "type" member required".

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.