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

String parsing error in Windows #4

Closed
behzad-vahedi opened this issue Jun 19, 2023 · 2 comments
Closed

String parsing error in Windows #4

behzad-vahedi opened this issue Jun 19, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@behzad-vahedi
Copy link

behzad-vahedi commented Jun 19, 2023

Running the nbar_SAFE() function in Windows results in the following error:
rasterio._err.CPLE_OpenFailedError: Attempt to create new tiff file '...' failed in VSI_TIFFOpen().

After further investigation, I realized it is caused by a platform-dependent string parsing in nbar.py (the following line).
filename = img_path.split("/")[-1].replace("jp2", "tif")

I would suggest a quick fix like this:

if os.name == 'nt':  # Windows
    dir_sep = "\\"
else:  # Linux, macOS, and other platforms
    dir_sep = "/"
filename = img_path.split(dir_sep)[-1].replace("jp2", "tif")
@davemlz
Copy link
Collaborator

davemlz commented Jul 9, 2023

You are totally right!

I will correct this now.

Best,

David

@davemlz davemlz self-assigned this Jul 9, 2023
@davemlz davemlz added the bug Something isn't working label Jul 9, 2023
@davemlz
Copy link
Collaborator

davemlz commented Jul 9, 2023

This was fixed!

It will be available in the next version of sen2nbar!

Best,

David

@davemlz davemlz closed this as completed Jul 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants