-
Notifications
You must be signed in to change notification settings - Fork 23
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
DataLayerError
when writing using fsspec
#430
Comments
In this case GDAL is not currently deriving the layer name from the open fsspec handle like it would if you were writing directly to a path passed in as a string / The workaround should be to directly provide the layer name.
It is expected that you will get this warning bubbled up from GDAL: However, when Ido this, I get an empty GPKG file. Not yet sure why. |
Ah, right, this currently isn't supported by Pyogrio, but we don't specifically attempt to catch and block this usage. Currently, the In this case, coercing the fsspec file handle to a string produces bad inputs. Instead, it looks like we should be detecting if the input has a Unfortunately, this is a place where Fiona and Pyogrio differ (for now), because it works fine if you use the Fiona engine: with fs.open('test.gpkg', mode='wb') as file:
gdf.to_file(file, driver='GPKG', engine="fiona") At the moment, Fiona's handling of alternative file interfaces is more advanced than in Pyogrio. You can work around the issue by first writing to from io import BytesIO
with fs.open('test.gpkg', mode='wb') as file:
buffer = BytesIO()
gdf.to_file(buffer, driver='GPKG')
buffer.seek(0)
file.write(buffer.getvalue()) Longer term, we plan to add better support for alternative file / filesystem interfaces, but those are a bit complex to integrate properly. |
Description
pyogrio raises
DataLayerError: The layer name may not contain special characters or spaces
when passing in file object usingfsspec
'sfile.open
Traceback
MRE
Environment
The text was updated successfully, but these errors were encountered: