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

Feature-request, make readers pathlib compatible #5

Open
d2hydro opened this issue Sep 21, 2020 · 0 comments
Open

Feature-request, make readers pathlib compatible #5

d2hydro opened this issue Sep 21, 2020 · 0 comments

Comments

@d2hydro
Copy link
Contributor

d2hydro commented Sep 21, 2020

The advantage of using Path-lib is that it comes with some handy and very frequently used methods. Common packages ((geo)pandas, rasterio, etc) support Path-objects.

E.g.
from pathlib import Path
delft3dfmpy_path = Path(r'd:\repositories\delft3dfmpy')
data_path = delft3dfmpy_path.joinpath('data')

If you supply a Path-object to the read_gml method one gets the following error as ogr.Open(gml_path) does not accept Path-objects.

suggested edit: ogr.Open(str(gml_path))

Current error:


RuntimeError Traceback (most recent call last)
in
3
4 # Branches
----> 5 hydamo.branches.read_gml(data_path.joinpath('gml/hydroobject.gml'), index_col='code', clip=hydamo.clipgeo)
6 hydamo.branches['ruwheidstypecode'] = 4
7

C:\Anaconda3\envs\delft3dfmpy\lib\site-packages\delft3dfmpy\datamodels\common.py in read_gml(self, gml_path, index_col, groupby_column, order_column, column_mapping, check_columns, check_geotype, clip)
177
178 ogr.UseExceptions()
--> 179 gml = ogr.Open(gml_path)
180 layer = gml.GetLayer()
181 layerDefinition = layer.GetLayerDefn()

C:\Anaconda3\envs\delft3dfmpy\lib\site-packages\osgeo\ogr.py in Open(*args, **kwargs)
7798 def Open(*args, **kwargs):
7799 """Open(char const * utf8_path, int update=0) -> DataSource"""
-> 7800 return _ogr.Open(*args, **kwargs)
7801
7802 def OpenShared(*args, **kwargs):

RuntimeError: not a string

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

No branches or pull requests

0 participants