I am writing a simple python code to perform sjoin on two geodataframe.
gdf1 = gpd.read_file(polygon1.geojson)
gdf2 = gpd.read_file(polygon2.geojson)
gdf = gpd.sjoin(gdf1, gdf2, how="left", op='intersects')
gdf.to_file(filename= 'myfile.geojson', driver='GeoJSON')
However, I encounter this error when writing the result to geojson.
I can avoid this error by writing to a shapefile then convert the shapefile to geojson. But this sounds too odd.
Is there anyone know the root cause of such an error?
C:\ProgramData\Anaconda3\lib\site-packages\geopandas\geodataframe.py in to_file(self, filename, driver, schema, index, **kwargs) 531 from geopandas.io.file import to_file 532 --> 533 to_file(self, filename, driver, schema, index, **kwargs) 534 535 def to_crs(self, crs=None, epsg=None, inplace=False):
C:\ProgramData\Anaconda3\lib\site-packages\geopandas\io\file.py in to_file(df, filename, driver, schema, index, **kwargs) 191 filename, "w", driver=driver, crs_wkt=crs_wkt, schema=schema, **kwargs 192 ) as colxn: --> 193 colxn.writerecords(df.iterfeatures()) 194 195
C:\ProgramData\Anaconda3\lib\site-packages\fiona\collection.py in writerecords(self, records) 347 if self.mode not in ('a', 'w'): 348 raise IOError("collection not open for writing") --> 349 self.session.writerecs(records, self) 350 self._len = self.session.get_length() 351 self._bounds = self.session.get_extent()
fiona/ogrext.pyx in fiona.ogrext.WritingSession.writerecs()
fiona/ogrext.pyx in fiona.ogrext.OGRFeatureBuilder.build()