-
Notifications
You must be signed in to change notification settings - Fork 340
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
Refactor GeoDataset #73
Conversation
hits = self.index.intersection(query, objects=True) | ||
|
||
try: | ||
hit = next(hits) # TODO: this assumes there is only a single hit | ||
except StopIteration: | ||
raise IndexError( | ||
f"query: {query} is not within bounds of the index: {self.bounds}" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change fixes #57 (comment)
if self.crs is None: | ||
self.crs = src.crs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change fixes #57 (comment)
crs
is now optional. Instead of computing the most common CRS, I just took the first CRS we find, as it's much simpler.
if i == 0: | ||
raise FileNotFoundError( | ||
f"No {self.__class__.__name__} data was found in '{root}'" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change fixes #57 (comment)
with WarpedVRT(src, crs=self.crs) as vrt: | ||
minx, miny, maxx, maxy = vrt.bounds | ||
except rasterio.errors.RasterioIOError: | ||
# Skip files that rasterio is unable to read |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we want to spit out a warning here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could issue debug-level logging messages for these (#39), but these are far too common to warrant info-level warning messages. This will be hit for every .zip
, .txt
, .dbf
, etc. file in the directory.
This PR refactors GeoDataset by adding two additional base classes:
All existing GeoDataset implementations now subclass these new base classes.
The motivation behind this PR is to reduce the significant amount of code duplication that has already accumulated. Note that since this is a refactor, no changes to the API or tests have been made.