Error importing the data to QGIS

Avatar
  • updated
  • Not a bug

I have tried to download several country boundaries and the resulting geojson.gz file, once imported to QGIS, throws the "is not a valid or recognized data source" error. I have also tried unzipping the file and importing, but the same error occurs.

Here is the permalink for reference: https://osm-boundaries.com/l/93a4c736bd086e136029f5ec4b218130feb55ae0

I'm downloading land only, in EPSG:3857, in case that helps. If I download with water boundaries, however, it works perfectly fine. Weird.

Pinned replies
Avatar
Magnus
  • Answer
  • Not a bug

This was new to me, but I found a solution for you. I am not sure if this is only an issue with newer QGIS since I haven't seen it before, it if it's due to some library it's depending on. But I could reproduce it, and I could also find a good workaround.

Assuming you are using Linux you can do any of these:

export OGR_GEOJSON_MAX_OBJ_SIZE=0
qgis

or

OGR_GEOJSON_MAX_OBJ_SIZE=0 qgis

Note that `=0` is unrestricted memory usage. You might want to try with an actual value if you are afraid of going OOM. I went with zero.

If you are running Windows I am sorry to say that we don't know how to help with that. But at least you have a hint then.

Avatar
Magnus
  • Answer
  • Not a bug

This was new to me, but I found a solution for you. I am not sure if this is only an issue with newer QGIS since I haven't seen it before, it if it's due to some library it's depending on. But I could reproduce it, and I could also find a good workaround.

Assuming you are using Linux you can do any of these:

export OGR_GEOJSON_MAX_OBJ_SIZE=0
qgis

or

OGR_GEOJSON_MAX_OBJ_SIZE=0 qgis

Note that `=0` is unrestricted memory usage. You might want to try with an actual value if you are afraid of going OOM. I went with zero.

If you are running Windows I am sorry to say that we don't know how to help with that. But at least you have a hint then.

Avatar
Serranowski

Hi and thanks for the quick reply.

If it is marked as not a bug then what is it? Where does the error come from? I am still using the latest Long Term Release, 3.40, in case that helps.

And sadly, I am using Windows, so I have no clue how to fix that.

Avatar
Magnus

It's not a bug because the file works. You are having an issue with QGIS - not with our data. With the settings you have you can't load such complex file. Since we don't develop QGIS we can't answer for their product.


If anything it would be a bug in QGIS, but it's not. It's a feature that keeps the resource usage down.

In Windows you should be able to do this (according to AI):

Start a cmd.exe.

set OGR_GEOJSON_MAX_OBJ_SIZE=0
qgis


Similar can be done in Powershell.

$env:OGR_GEOJSON_MAX_OBJ_SIZE=0
qgis

You should also be able to do something like this:

  1. Right click "This PC", Proporties.
  2. Click "Advanced system settings".
  3. Click "Environment variables"
  4. Under "User Variables" click "New".
  5. Variable name OGR_GEOJSON_MAX_OBJ_SIZE ; variable value 0.
  6. OK, restart qgis.
Avatar
Serranowski
Quote from Magnus

It's not a bug because the file works. You are having an issue with QGIS - not with our data. With the settings you have you can't load such complex file. Since we don't develop QGIS we can't answer for their product.


If anything it would be a bug in QGIS, but it's not. It's a feature that keeps the resource usage down.

In Windows you should be able to do this (according to AI):

Start a cmd.exe.

set OGR_GEOJSON_MAX_OBJ_SIZE=0
qgis


Similar can be done in Powershell.

$env:OGR_GEOJSON_MAX_OBJ_SIZE=0
qgis

You should also be able to do something like this:

  1. Right click "This PC", Proporties.
  2. Click "Advanced system settings".
  3. Click "Environment variables"
  4. Under "User Variables" click "New".
  5. Variable name OGR_GEOJSON_MAX_OBJ_SIZE ; variable value 0.
  6. OK, restart qgis.

Tried the last solution and the file loaded perfectly.

Thanks!