dustming / basinmaker

An automated GIS toolbox for watershed delineation with lakes
Artistic License 2.0
24 stars 6 forks source link

Incompatibility between the Decrease_River_Network_Resolution() post-processing tool and MacOS #21

Closed lou-a closed 1 day ago

lou-a commented 3 months ago

There is an issue with the Decrease_River_Network_Resolution() post-processing tool, which I think is specific to MacOS systems.

When a shapefile is opened (for example in QGIS) and perhaps modified on a mac, hidden files, prefixed with ._, are often created for the corresponding shapefile. The folder where the original shapefile was located may now contain a bunch of hidden files - for example: sl_connected_lake.cpg ._sl_connected_lake.dbf sl_connected_lake.dbf sl_connected_lake.prj ._sl_connected_lake.shp sl_connected_lake.shp ._sl_connected_lake.shx sl_connected_lake.shx

When running the basinmaker.postprocess().Decrease_River_Network_Resolution() post-processing tool, the simplify_routing_structure_by_drainage_area_purepy function in script increasedapurepy.py will try to find the shapefiles it needs in the provided Routing_Product_Folder. The way it looks for them can cause issues when these hidden files are present. On L106 of increasedapurepy.py the script looks for all files in that folder ending with ".shp", which will lead to the following error: File "fiona/ogrext.pyx", line 136, in fiona.ogrext.gdal_open_vector File "fiona/_err.pyx", line 291, in fiona._err.exc_wrap_pointer fiona._err.CPLE_OpenFailedError: '._sl_connected_lake.shp' not recognized as a supported file format.

I think that excluding the files starting with ._ from the search should do the trick.

dustming commented 1 day ago

The issue was fixed in the latest master branch~ Thanks