[gdal-dev] Handle geojson bigger than 200MB

Even Rouault even.rouault at spatialys.com
Fri Feb 28 08:29:54 PST 2020


On vendredi 28 février 2020 17:22:28 CET Francesco Bartoli wrote:
> However, we are using both modules so how can we handle exceptions properly
> for both of them?

You can use both gdal.UseExceptions() and ogr.UseExceptions()

> 
> Using ogr.UseExceptions() the
> call https://github.com/geopython/pygeoapi/pull/372/files#diff-b105ae3f7a36
> 059b16bdc16a08071016R361 gives the same result silently without any message
> to system output this time.

On a quick test, ogr.UseExceptions() does the job for me:

$ OGR_GEOJSON_MAX_OBJ_SIZE=0 python
>>> from osgeo import ogr
>>> ogr.UseExceptions()
>>> ds = ogr.Open('poly.geojson')
>>> lyr = ds.GetLayer(0)
>>> lyr.GetNextFeature()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/even/gdal/git/gdal/gdal/swig/python/build/lib.linux-x86_64-2.7/
osgeo/ogr.py", line 1339, in GetNextFeature
    return _ogr.Layer_GetNextFeature(self, *args)
RuntimeError: GeoJSON object too complex, please see the 
OGR_GEOJSON_MAX_OBJ_SIZE environment option
>>> 

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list