I'm getting the following warning reading a geojson with geopanda's read_file():
...geodataframe.py:422: RuntimeWarning: Sequential read of iterator was interrupted. Resetting iterator. This can negatively impact the performance.
for feature in features_lst:
Here's the code sample I used:
crime_gdf = gpd.read_file('datasets/crimes.geojson', bbox=bbox)
crimes.geojson
is a file containing a large number of points, each with a 'Crime type'
bbox
defines the boundaries
The code runs as expected, but I don't understand that warning.
EDIT
I converted the geojson to feather, and I get the same warning.
GeoPandas supports writing and reading the Apache Parquet and Feather file formats. Apache Parquet is an efficient, columnar storage format (originating from the Hadoop ecosystem). It is a widely used binary file format for tabular data.
The following are 30 code examples of geopandas.read_file () . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module geopandas , or try the search function .
Since geopandas is powered by Fiona, which is powered by GDAL, you can take advantage of pre-filtering when loading in larger datasets. This can be done geospatially with a geometry or bounding box.
This is possible because geopandas makes use of the great fiona library, which in turn makes use of a massive open-source program called GDAL/OGR designed to facilitate spatial data transformations. Any arguments passed to geopandas.read_file () after the file name will be passed directly to fiona.open (), which does the actual data importation.
While it could cause problems ignoring warnings in some contexts, I am finding this one particularly annoying repeated in my code output.
I found the warning can be ignored using
import warnings
# filter out RuntimeWarnings, due to geopandas/fiona read file spam
# https://stackoverflow.com/questions/64995369/geopandas-warning-on-read-file
warnings.filterwarnings("ignore",category=RuntimeWarning)
I added in the comments referencing this post to explain why I am filtering out these warnings. When this warning is suppressed in a future geopandas / fiona release then this code snippet should probably be removed, as it may also suppress meaningful warnings and could be problematic in some contexts.
See my comment in Fiona's issue tracker: https://github.com/Toblerity/Fiona/issues/986
GDAL (the library Fiona uses to access the geodata) maintains an iterator over the features that are currently read. There a some operations that, for some drivers, can influence this iterator. Thus, after such operations we have to ensure that the iterator is set to the correct position that a continuous read of the data is ensured. Such operations include counting all features in a dataset, respectively calculating its extent.
There are different types of drivers in GDAL. Some drivers support random access, while some do not. For the drivers that do not support random access, the resetting of the iterator involves reading all features again up to the iterator position. As this is a possible costly operation, this RuntimeWarning is emitted, so that users are aware of this behavior.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With