-
Notifications
You must be signed in to change notification settings - Fork 13
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
Create a utility module (util) with useful helper functions #164
Comments
@emiliom, I really like this idea, as I think it is fundamental to the purpose of having a functional and performant Python API. I think the extra requirements are a small price to pay for also getting efficient and tested I/O capabilities. Thanks for continuing to move this critical repo forward. |
@emiliom - I don't have a really strong feeling about this other than I think we should be very careful about adding additional requirements and complexity. My feeling is that we never finished the core functionality and so adding additional functionality and dependencies should perhaps be secondary to firming up the foundation. Utility functions would be nice. Is there ongoing work that's driving this? |
@horsburgh, good question. I'm also interested in hearing what is motivating this work! I agree with the points about managing complexity and need to better develop core functionality. |
For my own future reference, to be moved into new issues when I'm ready to work on this stuff. Enhanced timeseries result valuesFrom the WaterQualityMeasurements_RetrieveVisualize.ipynb example in the odm2api documentation. # set the index to ValueDateTime for convenience.
tsValues = read.getResultValues(resultids=[1], lowercols=False)
tsValues.set_index('ValueDateTime', inplace=True)
tsValues.sort_index(inplace=True) And to conveniently unpack relevant metadata, on variable names and units, use something like GeoPandas GeoDataFrameStarting point for ingesting Sites into a GeoDataFrame. From the WaterQualityMeasurements_RetrieveVisualize.ipynb example in the odm2api documentation. import geopandas as gpd
# Get all of the SamplingFeatures from the ODM2 database that are Sites
siteFeatures = read.getSamplingFeatures(sftype='Site')
# Read Sites records into a Pandas DataFrame
# "if sf.Latitude" is used only to instantiate/read Site attributes)
df = pd.DataFrame.from_records([vars(sf) for sf in siteFeatures if sf.Latitude])
# Create a GeoPandas GeoDataFrame from Sites DataFrame
ptgeom = [Point(xy) for xy in zip(df['Longitude'], df['Latitude'])]
gdf = gpd.GeoDataFrame(df, geometry=ptgeom, crs={'init': 'epsg:4326'}) High-level database core summary
|
@emiliom, thanks for all your work on this! |
The text was updated successfully, but these errors were encountered: