utils Module¶
Utility functions for DeepGEE
calculate_area_stats(classified_image, class_names, pixel_size=30.0, nodata=None)
¶
Calculate area statistics for classified image.
Parameters:¶
classified_image : np.ndarray Classified image (2D array) class_names : list List of class names pixel_size : float Pixel size in meters nodata : int, optional No data value to exclude
Returns:¶
pd.DataFrame : Area statistics
Examples:¶
stats = calculate_area_stats( ... classified, class_names, pixel_size=30 ... ) print(stats)
Source code in deepgee\utils.py
create_rgb_composite(image, rgb_bands=(3, 2, 1), stretch=2.5)
¶
Create RGB composite from multi-band image.
Parameters:¶
image : np.ndarray Multi-band image (bands, height, width) rgb_bands : tuple Band indices for RGB (0-indexed) stretch : float Contrast stretch factor
Returns:¶
np.ndarray : RGB composite (height, width, 3)
Source code in deepgee\utils.py
load_geotiff(filepath)
¶
Load a GeoTIFF file.
Parameters:¶
filepath : str Path to GeoTIFF file
Returns:¶
tuple : (image_array, metadata)
Examples:¶
image, meta = load_geotiff('composite.tif') print(image.shape)
Source code in deepgee\utils.py
plot_area_distribution(stats_df, class_colors=None, save_path=None, figsize=(12, 6))
¶
Plot area distribution bar chart.
Parameters:¶
stats_df : pd.DataFrame Area statistics dataframe class_colors : list, optional Class colors save_path : str, optional Path to save figure figsize : tuple Figure size
Source code in deepgee\utils.py
plot_classification_map(classified_image, class_names, class_colors, save_path=None, figsize=(12, 10), title='Land Cover Classification')
¶
Plot classification map.
Parameters:¶
classified_image : np.ndarray Classified image (2D) class_names : list Class names class_colors : list Class colors (hex codes) save_path : str, optional Path to save figure figsize : tuple Figure size title : str Plot title
Source code in deepgee\utils.py
plot_confusion_matrix(cm, class_names, save_path=None, figsize=(10, 8))
¶
Plot confusion matrix.
Parameters:¶
cm : np.ndarray Confusion matrix class_names : list Class names save_path : str, optional Path to save figure figsize : tuple Figure size
Source code in deepgee\utils.py
plot_training_history(history, save_path=None, figsize=(14, 5))
¶
Plot training history.
Parameters:¶
history : keras.callbacks.History Training history save_path : str, optional Path to save figure figsize : tuple Figure size
Source code in deepgee\utils.py
print_model_summary(results)
¶
Print model evaluation summary.
Parameters:¶
results : dict Evaluation results from classifier.evaluate()
Source code in deepgee\utils.py
save_geotiff(image, filepath, meta, nodata=None)
¶
Save array as GeoTIFF.
Parameters:¶
image : np.ndarray Image array (bands, height, width) or (height, width) filepath : str Output file path meta : dict Metadata dictionary nodata : float, optional No data value
Returns:¶
str : Path to saved file
Examples:¶
save_geotiff(classified, 'output.tif', meta, nodata=255)