Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clean.to_file Error - strange 0/NaN column in cleaned output #106

Closed
LiamTrees opened this issue Jun 13, 2023 · 1 comment · Fixed by #107
Closed

clean.to_file Error - strange 0/NaN column in cleaned output #106

LiamTrees opened this issue Jun 13, 2023 · 1 comment · Fixed by #107

Comments

@LiamTrees
Copy link

Experiencing this error with clean.to_file after using the clean_crowns function:

AttributeError Traceback (most recent call last)
in <cell line: 1>()
----> 1 clean.to_file(site_path + "/crowns_out.gpkg")

5 frames
/usr/local/lib/python3.10/dist-packages/geopandas/geodataframe.py in to_file(self, filename, driver, schema, index, **kwargs)
1261 from geopandas.io.file import _to_file
1262
-> 1263 _to_file(self, filename, driver, schema, index, **kwargs)
1264
1265 def set_crs(self, crs=None, epsg=None, inplace=False, allow_override=False):

/usr/local/lib/python3.10/dist-packages/geopandas/io/file.py in _to_file(df, filename, driver, schema, index, mode, crs, engine, **kwargs)
570
571 if engine == "fiona":
--> 572 _to_file_fiona(df, filename, driver, schema, crs, mode, **kwargs)
573 elif engine == "pyogrio":
574 _to_file_pyogrio(df, filename, driver, schema, crs, mode, **kwargs)

/usr/local/lib/python3.10/dist-packages/geopandas/io/file.py in _to_file_fiona(df, filename, driver, schema, crs, mode, **kwargs)
596 elif crs:
597 crs_wkt = crs.to_wkt("WKT1_GDAL")
--> 598 with fiona.open(
599 filename, mode=mode, driver=driver, crs_wkt=crs_wkt, schema=schema, **kwargs
600 ) as colxn:

/usr/local/lib/python3.10/dist-packages/fiona/env.py in wrapper(*args, **kwds)
455
456 with env_ctor(session=session):
--> 457 return f(*args, **kwds)
458
459 return wrapper

/usr/local/lib/python3.10/dist-packages/fiona/init.py in open(fp, mode, driver, schema, crs, encoding, layer, vfs, enabled_drivers, crs_wkt, allow_unsupported_drivers, **kwargs)
301 )
302 elif mode == "w":
--> 303 colxn = Collection(
304 path,
305 mode,

/usr/local/lib/python3.10/dist-packages/fiona/collection.py in init(self, path, mode, driver, schema, crs, encoding, layer, vsi, archive, enabled_drivers, crs_wkt, ignore_fields, ignore_geometry, include_fields, wkt_version, allow_unsupported_drivers, **kwargs)
244 elif self.mode in ("a", "w"):
245 self.session = WritingSession()
--> 246 self.session.start(self, **kwargs)
247 except OSError:
248 self.session = None

fiona/ogrext.pyx in fiona.ogrext.WritingSession.start()

AttributeError: 'int' object has no attribute 'encode'

@PatBall1 PatBall1 changed the title clean.to_file Error clean.to_file Error - strange 0/NaN column in cleaned output Jun 14, 2023
@PatBall1
Copy link
Owner

PatBall1 commented Jun 14, 2023

Thanks @LiamTrees for raising this issue - I am looking into it! Would you mind posting a screen grab of how the geopandas df looked (with the strange 0 column)?

The behaviour comes from a recent update I made to the clean_crowns function.

@PatBall1 PatBall1 linked a pull request Jun 14, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants