Modules
Convert
- convert.convert.convert(indir, proj, band_info, startdate, enddate, outdir=None)
Compile features from multiple processings into one geodataframe
- Parameters:
inlist (list) – List of files or geopandas.dataframe.DataFrame objects to merge
- Returns:
all_gdf – Compiled goedataframe
- Return type:
geopandas.dataframe.GeoDataFrame
- convert.raster_to_vector.raster_to_vector(infile, proj, band_info, startdate, enddate, outfile=None)
Convert raster to vector file with geopandas
- Parameters:
infile (str) – Input file location as string
band_info (int) – Band number
startdate (str) – Start date
enddate (str) –
End date outfile : str, optional
Output file location as string
- Returns:
all_gdf – Converted vectors geodataframe
- Return type:
geopandas.GeoDataFrame
Filter
- filter.filter_area.filter_area(iml, min_area=0.05)
Filter vectors in GeoDataframe object by a defined area
- Parameters:
iml (geopandas.GeoDataframe) – Vector object to filter by area
min_area (int, optional) – Threshold area (sq km) to filter by
- Returns:
iml – Filtered vector object
- Return type:
geopandas.GeoDataframe
- filter.filter_margin.filter_margin(iml, margin_buffer)
Filter vectors by polygon (such as a margin buffer) using a spatial join
- Parameters:
iml (geopandas.GeoDataframe) – Vector object to filter by area
margin_buffer (geopandas.GeoSeries) – Vector shape which will be used to filter
- Returns:
iml – Filtered vector object
- Return type:
geopandas.GeoDataframe
- filter.filter_vectors.filter_vectors(inlist, margin_file, outdir=None, min_area=0.05)
Filter vectors by area and margin proximity
- Parameters:
inlist (list) – List of either file paths of GeoDataFrame objects to filter
margin_file (str, geopandas.GeoSeries) – Bufferred margin to perform margin proximity filter
outdir (str, optional) – Output directory to write files to
min_area (int, optional) – Threshold area (sq km) to filter by
- Returns:
filtered – List of filtered GeoDataFrame objects
- Return type:
list
Merge
- merge.merge_vectors.merge_vectors(inlist, outfile=None, proj='EPSG:3413')
Compile features from multiple processings into one geodataframe
- Parameters:
inlist (list) – List of files or geopandas.dataframe.DataFrame objects to merge
- Returns:
all_gdf – Compiled goedataframe
- Return type:
geopandas.dataframe.GeoDataFrame
Metadata
- metadata.add_metadata.add_metadata(iml, names, regions, outfile=None)
- metadata.assign_certainty.assign_certainty(gdf, search_names, scores, source='all_src')
Assign certainty score to geodataframe based on sources
- Parameters:
gdf (pandas.GeoDataFrame) – Vectors to assign ncertainty to
search_names (str) – Names of sources to count and determine certainty
scores (list) – List of scores of certainty
sources (str) – Column name of sources information
- metadata.assign_id.assign_id(gdf, col_name='lake_id')
Assign unique identification numbers to non-overlapping geometries in geodataframe
- Parameters:
gdf (pandas.GeoDataFrame) – Vectors to assign identification numbers to
col_name (str) – Column name to assign ID from
- Returns:
gdf – Vectors with assigned IDs
- Return type:
pandas.GeoDataFrame
- metadata.assign_sources.assign_sources(gdf, col_names=['lake_id', 'source'])
Assign source metadata to geodataframe, based on unique lake id and individual source information
- Parameters:
gdf (geopandas.GeoDataFrame) – Vectors to assign sources to
col_names (list) – Column names to assign sources from
- Returns:
gdf – Vectors with assigned sources
- Return type:
geopandas.GeoDataFrame
stats
- stats.method_stats.method_stats(infile1, infile2, outfile)
Calculate general statistics on a lake inventory file
- Parameters:
infile1 (str) – File path to lake geodataframe
infile2 (str) – File path to basin (as polygons) geodataframe
outfile (str) – Outputted file name for general statistics
- stats.reformat.aggregate(geofile, col_name='lake_id')
Generate areal statistics for aggregated geodataframe. Aggregation is determined from a given column name
- Parameters:
geofile (gpd.GeoDataFrame) – Dataframe to perform aggregation statistics on
col_name (str, optional) – Column name to aggregate dataframe by. The default is “lake_id”
- Returns:
agg_geofile – Aggregated dataframe with updated areal statistics
- Return type:
gpd.GeoDataFrame
- stats.reformat.centroids(geofile)
Generate centroids for geodataframe
- Parameters:
geofile (gpd.GeoDataFrame) – Dataframe to obtain centroids for
- Returns:
geofile – Dataframe with centroid information
- Return type:
gpd.GeoDataFrame
test
- class test.test.TestGrIML(methodName='runTest')
Bases:
TestCase
Unittest for the GrIML post-processing workflow
- create_sample_pointfile(filepath, num_features=5)
Generate a synthetic GeoDataFrame with simple point geometries
- create_sample_polyfile(filepath, num_features=5, side_length=1.0)
Generate a synthetic GeoDataFrame with square polygon geometries
- create_sample_raster(filepath)
Generate a small synthetic raster file with three bands
- setUp()
Set up temporary directories
- tearDown()
Clean up temporary files
- test_convert()
Test vector to raster conversion
- test_filter()
Test vector filtering
- test_merge()
Test vector merging
- test_metadata()
Test metadata population