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

Watershed delineation: handling the case where flow_dir doesn't have an SRS. #338

Merged

Conversation

phargogh
Copy link
Member

Also noting this change in HISTORY and testing.

Fixes #254

Also noting this change in HISTORY and testing.

RE:natcap#254
Copy link
Member

@emlys emlys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@phargogh this looks good, but I'm not sure I understand when it would be OK to have a missing SRS? How do we know that the flow direction raster intersects with the other inputs?

@phargogh
Copy link
Member Author

when it would be OK to have a missing SRS? How do we know that the flow direction raster intersects with the other inputs?

Well, we don't know for sure! But if the units of the geotransform and geometries are all the same, it may be reasonable to assume that the user knows what they are doing and continue running. So we would be assuming that the inputs are in some projected coordinate system and valid for delineating watersheds. I don't think that's a reasonable assumption to make in InVEST, specifically, but I think it could be OK for a geoprocessing routine like this.

What do you think?

@emlys
Copy link
Member

emlys commented Aug 28, 2023

I wonder if it makes sense to have a larger conversation about this and decide when/if this makes sense in general, so we can be consistent within pygeoprocessing? For instance, maybe it's also ok for the outflow vector to have no SRS? But if both inputs have no SRS, is that a problem?

@phargogh
Copy link
Member Author

The consistency question is a good one, and probably worth a discussion! I'll add it to the agenda for an upcoming software team call.

In the shorter term, it turns out that we have a valid use case for where there might not be a defined spatial reference: in the various supported raster formats that don't support georeferencing. Taking this CEOS example file from the GDAL tests, the SRS's WKT is falsey:

>>> from osgeo import gdal
>>> ds = gdal.Open('/Users/jdouglass/Downloads/IMAGERY-75K.L-3')
>>> ds.GetProjection()
''

@phargogh
Copy link
Member Author

Thanks for your thoughts and the review @emlys ! I created a new issue #341 for the general pygeoprocessing question in line with the discussion this morning, and I improved the docstring in the watershed delineation routine.

Copy link
Member

@emlys emlys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding that note to the docstring! It just looks like some extra carraige returns got in there, otherwise good!

@phargogh
Copy link
Member Author

Huh, I'm so used to my editor chomping them that I missed them in the diff! Thanks @emlys I think they should be clear now

@phargogh phargogh requested a review from emlys August 29, 2023 20:52
Copy link
Member

@emlys emlys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @phargogh but I'm seeing one more ^M on line 631, those line ending characters are sneaky!

@phargogh phargogh requested a review from emlys August 30, 2023 18:02
@phargogh
Copy link
Member Author

phargogh commented Aug 30, 2023

Ugh, the lesson for me here is to be very careful when copying code out of a git diff! Thanks @emlys and I'm sorry for missing these!

Patched and pushed in 5ab4a46

@emlys emlys merged commit 879fd70 into natcap:main Aug 30, 2023
56 checks passed
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 this pull request may close these issues.

delineate_watersheds_d8 does not handle the case where SRS is undefined
2 participants