Widgets
geostudio.gswidgets
geojson_to_details
This function takes a GeoJSON object as input and returns a string containing the area, perimeter, and bounding box coordinates of the polygon.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geojson
|
dict
|
A dictionary representing a GeoJSON object with 'geometry' and 'type' keys. The 'geometry' key should contain a dictionary with 'type' set to 'Polygon' and 'coordinates' containing a list of coordinate pairs. The 'type' key should be set to 'Feature'. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
A string containing the area (in square kilometers), perimeter (in kilometers), and bounding box coordinates (in decimal degrees) of the polygon. |
Source code in geostudio/gswidgets.py
geojson_to_bbox
Convert a GeoJSON feature to a bounding box in the format [west, south, east, north].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geojson
|
dict
|
A dictionary representing a GeoJSON feature. It should contain a 'geometry' key with a GeoJSON geometry object. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
list |
A list of four floating point numbers representing the bounding box in the order [west, south, east, north]. |
|
|
The values are rounded to 5 decimal places. Longitude and latitude values are adjusted to be within the range [-180, 180]. |
Source code in geostudio/gswidgets.py
list_output_files
Lists the files present in a remote zip archive.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
The URL of the remote zip archive. |
required |
just_tif
|
bool
|
If True, only return files with '.tif' extension. Defaults to True. |
True
|
Returns:
| Type | Description |
|---|---|
|
List[str]: A list of filenames present in the zip archive. |
Source code in geostudio/gswidgets.py
download_file
Downloads a file from a given URL and saves it to a specified output path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
The URL of the file to download. |
required |
filename
|
str
|
The name of the file to save locally. |
required |
output_path
|
str
|
The directory where the file will be saved. Defaults to './'. |
'./'
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
The path where the file was saved. |
Source code in geostudio/gswidgets.py
bboxSelector
Creates a user interface for selecting a bounding box on a map.
Returns:
| Type | Description |
|---|---|
|
ipywidgets.widgets.GridspecLayout: A grid layout containing that can be displayed in a Jupyter notebook or similar environment. It contains a map, a search control, a full screen control, a title, a text area for displaying bounding box details, |
|
|
a clear button, and a use button. The map has a draw control for selecting a bounding box. |
Source code in geostudio/gswidgets.py
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | |
time_selector
Creates a time range selector using ipywidgets.
Returns:
| Type | Description |
|---|---|
|
ipywidgets.widgets.GridspecLayout: A layout containing two datetime pickers for selecting a start and end time. |
Source code in geostudio/gswidgets.py
add_geotiff
Adds a GeoTIFF file to a Folium map as an overlay.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
The path to the GeoTIFF file. |
required |
layer_name
|
str
|
The name of the layer. Defaults to "". |
''
|
colormap
|
str
|
The colormap to use for the GeoTIFF data. Defaults to "viridis". |
'viridis'
|
cmin
|
int or float
|
The minimum value for the colormap. Defaults to 0. |
0
|
cmax
|
int or float
|
The maximum value for the colormap. If not provided, it is automatically calculated as the maximum value in the GeoTIFF data. Defaults to "". |
''
|
opacity
|
float
|
The opacity of the overlay. Defaults to 1.0. |
1.0
|
Returns:
| Type | Description |
|---|---|
|
folium.raster_layers.ImageOverlay: An ImageOverlay object that can be added to a Folium map. |
Source code in geostudio/gswidgets.py
colorize
Converts a 2D numpy array of values into an RGBA array given a colour map and range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
array
|
ndarray
|
|
required |
cmax
|
float
|
Max value for colour range |
required |
cmin
|
float
|
Min value for colour range |
0
|
cmap
|
string
|
Colour map to use (from matplotlib colourmaps) |
'rainbow'
|
Returns:
| Name | Type | Description |
|---|---|---|
rgba_array |
ndarray
|
3D RGBA array which can be plotted. |
Source code in geostudio/gswidgets.py
available_models_ui
A UI for browsing and selecting available models.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
object
|
:py:class: |
required |
Returns:
| Type | Description |
|---|---|
|
widgets.VBox: A Jupyter widget containing a header, text input for filtering, checkbox for active models, interactive dropdown for selecting a model, and the model selection table. |
Source code in geostudio/gswidgets.py
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 | |
fileDownloader
Downloads the output files of an inference task.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client (
|
py:class: |
required | |
id
|
str
|
The unique identifier of the inference task. |
required |
Returns:
| Type | Description |
|---|---|
|
None |
Source code in geostudio/gswidgets.py
fileDownloaderTasks
Downloads the output files of an inference task.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client (
|
py:class: |
required | |
task_id
|
str
|
The unique identifier of the inference task id. |
required |
Returns:
| Type | Description |
|---|---|
|
None |
Source code in geostudio/gswidgets.py
geotiff2img
Converts a GeoTIFF file to a base64 encoded PNG image URL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
The path to the GeoTIFF file. |
required |
band
|
int
|
The band number to use for the image. Default is 1. |
1
|
cmax
|
str or float
|
The maximum value for color scaling. If not provided, it will be automatically calculated. |
''
|
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
A tuple containing the base64 encoded PNG image URL and the image bounds. |
Source code in geostudio/gswidgets.py
inferenceViewer
Creates a Jupyter widget for visualizing inference task outputs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client (
|
py:class: |
required | |
id
|
str
|
The unique identifier for the inference task. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
object |
A Jupyter widget containing a map with image overlays of the inference outputs. |
Source code in geostudio/gswidgets.py
635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 | |
inferenceTaskViewer
Creates a Jupyter widget for visualizing inference task outputs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client (
|
py:class: |
required | |
task_id
|
str
|
The unique identifier for the inference task. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
object |
A Jupyter widget containing a map with image overlays of the inference outputs. |
Source code in geostudio/gswidgets.py
734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 | |
color_inference_tasks_by_status
Takes a scalar and returns a string with
the css property 'color: red' for negative
strings, black otherwise.
Source code in geostudio/gswidgets.py
plot_tune_metrics
Plots training and validation metrics for a given tuning experiment in a 2x2 subplot grid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tune_id
|
str
|
The unique identifier of the tuning experiment. |
required |
Returns:
| Type | Description |
|---|---|
|
None |
Source code in geostudio/gswidgets.py
crop_image_bytes
Crops the white space from the training image provided as raw bytes and return PNG bytes.
Parameters
img_bytes : bytes Raw image bytes (any format supported by PIL.Image.open).
Returns
bytes PNG-encoded bytes of the cropped image. The function uses a fixed crop box (left=0, upper=350, right=image_width, lower=650) so the returned image contains the horizontal strip between y=350 and y=650 from the original image.
Notes
- The result is always encoded as PNG.
- If the crop box extends beyond the source image bounds, PIL.Image.crop behavior applies.
Source code in geostudio/gswidgets.py
save_training_image
Save a training sample image from img_dict to a PNG file.
Parameters
image_number : int The sample index/number to save (matches the 'image_number' key in img_dict). epoch : int The epoch number to save (matches the 'epoch' key in img_dict). img_dict : list[dict] List of artefact records as returned by get_tuning_artefacts. Each item must contain: - 'filename' : str - 'image' : bytes - 'epoch' : int - 'image_number' : int cropped : bool, optional If True (default) crop the image bytes using crop_image_bytes before saving.
Raises
ValueError If no matching image is found in img_dict.
Source code in geostudio/gswidgets.py
browse_training_images
Create an interactive Jupyter widget viewer to browse fine-tuning sample images.
Parameters
img_dict : list[dict] List of artefact records. Each item must be a dict with at least the keys: - 'filename' : str - 'image' : bytes (raw image bytes as returned by get_tuning_artefacts) - 'epoch' : int - 'image_number' : int tune_id : str Identifier shown in the viewer header.
Notes
- Depends on crop_image_bytes(img_bytes) to produce the PNG bytes shown in the widget.
- Expects img_dict to contain at least one image; raises ValueError otherwise.
- Uses ipywidgets and functools to wire button callbacks.
- To use: viewer = browse_training_images(img_dict, tune_id); display(viewer)
Source code in geostudio/gswidgets.py
1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 | |