hypercoast module¶
Main module.
Map (Map)
¶
A class that extends leafmap.Map to provide additional functionality for hypercoast.
Methods
Any methods inherited from leafmap.Map.
Source code in hypercoast/hypercoast.py
class Map(leafmap.Map):
"""
A class that extends leafmap.Map to provide additional functionality for hypercoast.
Attributes:
Any attributes inherited from leafmap.Map.
Methods:
Any methods inherited from leafmap.Map.
"""
def __init__(self, **kwargs):
"""
Initializes a new instance of the Map class.
Args:
**kwargs: Arbitrary keyword arguments that are passed to the parent class's constructor.
"""
super().__init__(**kwargs)
def add(self, obj, position="topright", **kwargs):
"""Add a layer to the map.
Args:
**kwargs: Arbitrary keyword arguments that are passed to the parent class's add_layer method.
"""
if isinstance(obj, str):
if obj == "spectral":
SpectralWidget(self, position=position)
self.set_plot_options(add_marker_cluster=True)
else:
super().add(obj, **kwargs)
else:
super().add(obj, **kwargs)
def search_emit(self, default_dataset="EMITL2ARFL"):
"""
Adds a NASA Earth Data search tool to the map with a default dataset for EMIT.
Args:
default_dataset (str, optional): The default dataset to search for. Defaults to "EMITL2ARFL".
"""
self.add("nasa_earth_data", default_dataset=default_dataset)
def search_pace(self, default_dataset="PACE_OCI_L2_AOP_NRT"):
"""
Adds a NASA Earth Data search tool to the map with a default dataset for PACE.
Args:
default_dataset (str, optional): The default dataset to search for. Defaults to "PACE_OCI_L2_AOP_NRT".
"""
self.add("nasa_earth_data", default_dataset=default_dataset)
def add_raster(
self,
source,
indexes=None,
colormap=None,
vmin=None,
vmax=None,
nodata=None,
attribution=None,
layer_name="Raster",
zoom_to_layer=True,
visible=True,
array_args={},
**kwargs,
):
"""Add a local raster dataset to the map.
If you are using this function in JupyterHub on a remote server (e.g., Binder, Microsoft Planetary Computer) and
if the raster does not render properly, try installing jupyter-server-proxy using `pip install jupyter-server-proxy`,
then running the following code before calling this function. For more info, see https://bit.ly/3JbmF93.
import os
os.environ['LOCALTILESERVER_CLIENT_PREFIX'] = 'proxy/{port}'
Args:
source (str): The path to the GeoTIFF file or the URL of the Cloud Optimized GeoTIFF.
indexes (int, optional): The band(s) to use. Band indexing starts at 1. Defaults to None.
colormap (str, optional): The name of the colormap from `matplotlib` to use when plotting a single band. See https://matplotlib.org/stable/gallery/color/colormap_reference.html. Default is greyscale.
vmin (float, optional): The minimum value to use when colormapping the palette when plotting a single band. Defaults to None.
vmax (float, optional): The maximum value to use when colormapping the palette when plotting a single band. Defaults to None.
nodata (float, optional): The value from the band to use to interpret as not valid data. Defaults to None.
attribution (str, optional): Attribution for the source raster. This defaults to a message about it being a local file.. Defaults to None.
layer_name (str, optional): The layer name to use. Defaults to 'Raster'.
zoom_to_layer (bool, optional): Whether to zoom to the extent of the layer. Defaults to True.
visible (bool, optional): Whether the layer is visible. Defaults to True.
array_args (dict, optional): Additional arguments to pass to `array_to_memory_file` when reading the raster. Defaults to {}.
"""
import numpy as np
if nodata is None:
nodata = np.nan
super().add_raster(
source,
indexes=indexes,
colormap=colormap,
vmin=vmin,
vmax=vmax,
nodata=nodata,
attribution=attribution,
layer_name=layer_name,
zoom_to_layer=zoom_to_layer,
visible=visible,
array_args=array_args,
**kwargs,
)
def add_emit(
self,
source,
wavelengths=None,
indexes=None,
colormap=None,
vmin=None,
vmax=None,
nodata=np.nan,
attribution=None,
layer_name="EMIT",
zoom_to_layer=True,
visible=True,
array_args={},
**kwargs,
):
"""Add a local raster dataset to the map.
If you are using this function in JupyterHub on a remote server (e.g., Binder, Microsoft Planetary Computer) and
if the raster does not render properly, try installing jupyter-server-proxy using `pip install jupyter-server-proxy`,
then running the following code before calling this function. For more info, see https://bit.ly/3JbmF93.
import os
os.environ['LOCALTILESERVER_CLIENT_PREFIX'] = 'proxy/{port}'
Args:
source (str): The path to the GeoTIFF file or the URL of the Cloud Optimized GeoTIFF.
indexes (int, optional): The band(s) to use. Band indexing starts at 1. Defaults to None.
colormap (str, optional): The name of the colormap from `matplotlib` to use when plotting a single band. See https://matplotlib.org/stable/gallery/color/colormap_reference.html. Default is greyscale.
vmin (float, optional): The minimum value to use when colormapping the palette when plotting a single band. Defaults to None.
vmax (float, optional): The maximum value to use when colormapping the palette when plotting a single band. Defaults to None.
nodata (float, optional): The value from the band to use to interpret as not valid data. Defaults to None.
attribution (str, optional): Attribution for the source raster. This defaults to a message about it being a local file.. Defaults to None.
layer_name (str, optional): The layer name to use. Defaults to 'EMIT'.
zoom_to_layer (bool, optional): Whether to zoom to the extent of the layer. Defaults to True.
visible (bool, optional): Whether the layer is visible. Defaults to True.
array_args (dict, optional): Additional arguments to pass to `array_to_memory_file` when reading the raster. Defaults to {}.
"""
xds = None
if isinstance(source, str):
xds = read_emit(source)
source = emit_to_image(xds, wavelengths=wavelengths)
elif isinstance(source, xr.Dataset):
xds = source
source = emit_to_image(xds, wavelengths=wavelengths)
self.add_raster(
source,
indexes=indexes,
colormap=colormap,
vmin=vmin,
vmax=vmax,
nodata=nodata,
attribution=attribution,
layer_name=layer_name,
zoom_to_layer=zoom_to_layer,
visible=visible,
array_args=array_args,
**kwargs,
)
self.cog_layer_dict[layer_name]["xds"] = xds
self.cog_layer_dict[layer_name]["type"] = "EMIT"
def add_pace(
self,
source,
wavelengths=None,
indexes=None,
colormap="jet",
vmin=None,
vmax=None,
nodata=np.nan,
attribution=None,
layer_name="PACE",
zoom_to_layer=True,
visible=True,
method="nearest",
gridded=False,
array_args={},
**kwargs,
):
"""Add a PACE dataset to the map.
If you are using this function in JupyterHub on a remote server (e.g., Binder, Microsoft Planetary Computer) and
if the raster does not render properly, try installing jupyter-server-proxy using `pip install jupyter-server-proxy`,
then running the following code before calling this function. For more info, see https://bit.ly/3JbmF93.
import os
os.environ['LOCALTILESERVER_CLIENT_PREFIX'] = 'proxy/{port}'
Args:
source (str): The path to the GeoTIFF file or the URL of the Cloud Optimized GeoTIFF.
indexes (int, optional): The band(s) to use. Band indexing starts at 1. Defaults to None.
colormap (str, optional): The name of the colormap from `matplotlib` to use when plotting a single band. See https://matplotlib.org/stable/gallery/color/colormap_reference.html. Default is greyscale.
vmin (float, optional): The minimum value to use when colormapping the palette when plotting a single band. Defaults to None.
vmax (float, optional): The maximum value to use when colormapping the palette when plotting a single band. Defaults to None.
nodata (float, optional): The value from the band to use to interpret as not valid data. Defaults to None.
attribution (str, optional): Attribution for the source raster. This defaults to a message about it being a local file.. Defaults to None.
layer_name (str, optional): The layer name to use. Defaults to 'EMIT'.
zoom_to_layer (bool, optional): Whether to zoom to the extent of the layer. Defaults to True.
visible (bool, optional): Whether the layer is visible. Defaults to True.
array_args (dict, optional): Additional arguments to pass to `array_to_memory_file` when reading the raster. Defaults to {}.
"""
if isinstance(source, str):
source = read_pace(source)
image = pace_to_image(
source, wavelengths=wavelengths, method=method, gridded=gridded
)
if isinstance(wavelengths, list) and len(wavelengths) > 1:
colormap = None
self.add_raster(
image,
indexes=indexes,
colormap=colormap,
vmin=vmin,
vmax=vmax,
nodata=nodata,
attribution=attribution,
layer_name=layer_name,
zoom_to_layer=zoom_to_layer,
visible=visible,
array_args=array_args,
**kwargs,
)
self.cog_layer_dict[layer_name]["xds"] = source
self.cog_layer_dict[layer_name]["type"] = "PACE"
def set_plot_options(
self,
add_marker_cluster=False,
plot_type=None,
overlay=False,
position="bottomright",
min_width=None,
max_width=None,
min_height=None,
max_height=None,
**kwargs,
):
"""Sets plotting options.
Args:
add_marker_cluster (bool, optional): Whether to add a marker cluster. Defaults to False.
sample_scale (float, optional): A nominal scale in meters of the projection to sample in . Defaults to None.
plot_type (str, optional): The plot type can be one of "None", "bar", "scatter" or "hist". Defaults to None.
overlay (bool, optional): Whether to overlay plotted lines on the figure. Defaults to False.
position (str, optional): Position of the control, can be ‘bottomleft’, ‘bottomright’, ‘topleft’, or ‘topright’. Defaults to 'bottomright'.
min_width (int, optional): Min width of the widget (in pixels), if None it will respect the content size. Defaults to None.
max_width (int, optional): Max width of the widget (in pixels), if None it will respect the content size. Defaults to None.
min_height (int, optional): Min height of the widget (in pixels), if None it will respect the content size. Defaults to None.
max_height (int, optional): Max height of the widget (in pixels), if None it will respect the content size. Defaults to None.
"""
plot_options_dict = {}
plot_options_dict["add_marker_cluster"] = add_marker_cluster
plot_options_dict["plot_type"] = plot_type
plot_options_dict["overlay"] = overlay
plot_options_dict["position"] = position
plot_options_dict["min_width"] = min_width
plot_options_dict["max_width"] = max_width
plot_options_dict["min_height"] = min_height
plot_options_dict["max_height"] = max_height
for key in kwargs:
plot_options_dict[key] = kwargs[key]
self._plot_options = plot_options_dict
if not hasattr(self, "_plot_marker_cluster"):
self._plot_marker_cluster = ipyleaflet.MarkerCluster(name="Marker Cluster")
if add_marker_cluster and (self._plot_marker_cluster not in self.layers):
self.add(self._plot_marker_cluster)
def spectral_to_df(self, **kwargs):
"""Converts the spectral data to a pandas DataFrame.
Returns:
pd.DataFrame: The spectral data as a pandas DataFrame.
"""
import pandas as pd
df = pd.DataFrame(self._spectral_data, **kwargs)
return df
def spectral_to_csv(self, filename, index=True, **kwargs):
"""Saves the spectral data to a CSV file.
Args:
filename (str): The output CSV file.
index (bool, optional): Whether to write the index. Defaults to True.
"""
df = self.spectral_to_df()
df = df.rename_axis("band")
df.to_csv(filename, index=index, **kwargs)
__init__(self, **kwargs)
special
¶
Initializes a new instance of the Map class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs |
Arbitrary keyword arguments that are passed to the parent class's constructor. |
{} |
Source code in hypercoast/hypercoast.py
def __init__(self, **kwargs):
"""
Initializes a new instance of the Map class.
Args:
**kwargs: Arbitrary keyword arguments that are passed to the parent class's constructor.
"""
super().__init__(**kwargs)
add(self, obj, position='topright', **kwargs)
¶
Add a layer to the map.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs |
Arbitrary keyword arguments that are passed to the parent class's add_layer method. |
{} |
Source code in hypercoast/hypercoast.py
def add(self, obj, position="topright", **kwargs):
"""Add a layer to the map.
Args:
**kwargs: Arbitrary keyword arguments that are passed to the parent class's add_layer method.
"""
if isinstance(obj, str):
if obj == "spectral":
SpectralWidget(self, position=position)
self.set_plot_options(add_marker_cluster=True)
else:
super().add(obj, **kwargs)
else:
super().add(obj, **kwargs)
add_emit(self, source, wavelengths=None, indexes=None, colormap=None, vmin=None, vmax=None, nodata=nan, attribution=None, layer_name='EMIT', zoom_to_layer=True, visible=True, array_args={}, **kwargs)
¶
Add a local raster dataset to the map.
If you are using this function in JupyterHub on a remote server (e.g., Binder, Microsoft Planetary Computer) and
if the raster does not render properly, try installing jupyter-server-proxy using pip install jupyter-server-proxy
,
then running the following code before calling this function. For more info, see https://bit.ly/3JbmF93.
1 2 |
|
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source |
str |
The path to the GeoTIFF file or the URL of the Cloud Optimized GeoTIFF. |
required |
indexes |
int |
The band(s) to use. Band indexing starts at 1. Defaults to None. |
None |
colormap |
str |
The name of the colormap from |
None |
vmin |
float |
The minimum value to use when colormapping the palette when plotting a single band. Defaults to None. |
None |
vmax |
float |
The maximum value to use when colormapping the palette when plotting a single band. Defaults to None. |
None |
nodata |
float |
The value from the band to use to interpret as not valid data. Defaults to None. |
nan |
attribution |
str |
Attribution for the source raster. This defaults to a message about it being a local file.. Defaults to None. |
None |
layer_name |
str |
The layer name to use. Defaults to 'EMIT'. |
'EMIT' |
zoom_to_layer |
bool |
Whether to zoom to the extent of the layer. Defaults to True. |
True |
visible |
bool |
Whether the layer is visible. Defaults to True. |
True |
array_args |
dict |
Additional arguments to pass to |
{} |
Source code in hypercoast/hypercoast.py
def add_emit(
self,
source,
wavelengths=None,
indexes=None,
colormap=None,
vmin=None,
vmax=None,
nodata=np.nan,
attribution=None,
layer_name="EMIT",
zoom_to_layer=True,
visible=True,
array_args={},
**kwargs,
):
"""Add a local raster dataset to the map.
If you are using this function in JupyterHub on a remote server (e.g., Binder, Microsoft Planetary Computer) and
if the raster does not render properly, try installing jupyter-server-proxy using `pip install jupyter-server-proxy`,
then running the following code before calling this function. For more info, see https://bit.ly/3JbmF93.
import os
os.environ['LOCALTILESERVER_CLIENT_PREFIX'] = 'proxy/{port}'
Args:
source (str): The path to the GeoTIFF file or the URL of the Cloud Optimized GeoTIFF.
indexes (int, optional): The band(s) to use. Band indexing starts at 1. Defaults to None.
colormap (str, optional): The name of the colormap from `matplotlib` to use when plotting a single band. See https://matplotlib.org/stable/gallery/color/colormap_reference.html. Default is greyscale.
vmin (float, optional): The minimum value to use when colormapping the palette when plotting a single band. Defaults to None.
vmax (float, optional): The maximum value to use when colormapping the palette when plotting a single band. Defaults to None.
nodata (float, optional): The value from the band to use to interpret as not valid data. Defaults to None.
attribution (str, optional): Attribution for the source raster. This defaults to a message about it being a local file.. Defaults to None.
layer_name (str, optional): The layer name to use. Defaults to 'EMIT'.
zoom_to_layer (bool, optional): Whether to zoom to the extent of the layer. Defaults to True.
visible (bool, optional): Whether the layer is visible. Defaults to True.
array_args (dict, optional): Additional arguments to pass to `array_to_memory_file` when reading the raster. Defaults to {}.
"""
xds = None
if isinstance(source, str):
xds = read_emit(source)
source = emit_to_image(xds, wavelengths=wavelengths)
elif isinstance(source, xr.Dataset):
xds = source
source = emit_to_image(xds, wavelengths=wavelengths)
self.add_raster(
source,
indexes=indexes,
colormap=colormap,
vmin=vmin,
vmax=vmax,
nodata=nodata,
attribution=attribution,
layer_name=layer_name,
zoom_to_layer=zoom_to_layer,
visible=visible,
array_args=array_args,
**kwargs,
)
self.cog_layer_dict[layer_name]["xds"] = xds
self.cog_layer_dict[layer_name]["type"] = "EMIT"
add_pace(self, source, wavelengths=None, indexes=None, colormap='jet', vmin=None, vmax=None, nodata=nan, attribution=None, layer_name='PACE', zoom_to_layer=True, visible=True, method='nearest', gridded=False, array_args={}, **kwargs)
¶
Add a PACE dataset to the map.
If you are using this function in JupyterHub on a remote server (e.g., Binder, Microsoft Planetary Computer) and
if the raster does not render properly, try installing jupyter-server-proxy using pip install jupyter-server-proxy
,
then running the following code before calling this function. For more info, see https://bit.ly/3JbmF93.
1 2 |
|
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source |
str |
The path to the GeoTIFF file or the URL of the Cloud Optimized GeoTIFF. |
required |
indexes |
int |
The band(s) to use. Band indexing starts at 1. Defaults to None. |
None |
colormap |
str |
The name of the colormap from |
'jet' |
vmin |
float |
The minimum value to use when colormapping the palette when plotting a single band. Defaults to None. |
None |
vmax |
float |
The maximum value to use when colormapping the palette when plotting a single band. Defaults to None. |
None |
nodata |
float |
The value from the band to use to interpret as not valid data. Defaults to None. |
nan |
attribution |
str |
Attribution for the source raster. This defaults to a message about it being a local file.. Defaults to None. |
None |
layer_name |
str |
The layer name to use. Defaults to 'EMIT'. |
'PACE' |
zoom_to_layer |
bool |
Whether to zoom to the extent of the layer. Defaults to True. |
True |
visible |
bool |
Whether the layer is visible. Defaults to True. |
True |
array_args |
dict |
Additional arguments to pass to |
{} |
Source code in hypercoast/hypercoast.py
def add_pace(
self,
source,
wavelengths=None,
indexes=None,
colormap="jet",
vmin=None,
vmax=None,
nodata=np.nan,
attribution=None,
layer_name="PACE",
zoom_to_layer=True,
visible=True,
method="nearest",
gridded=False,
array_args={},
**kwargs,
):
"""Add a PACE dataset to the map.
If you are using this function in JupyterHub on a remote server (e.g., Binder, Microsoft Planetary Computer) and
if the raster does not render properly, try installing jupyter-server-proxy using `pip install jupyter-server-proxy`,
then running the following code before calling this function. For more info, see https://bit.ly/3JbmF93.
import os
os.environ['LOCALTILESERVER_CLIENT_PREFIX'] = 'proxy/{port}'
Args:
source (str): The path to the GeoTIFF file or the URL of the Cloud Optimized GeoTIFF.
indexes (int, optional): The band(s) to use. Band indexing starts at 1. Defaults to None.
colormap (str, optional): The name of the colormap from `matplotlib` to use when plotting a single band. See https://matplotlib.org/stable/gallery/color/colormap_reference.html. Default is greyscale.
vmin (float, optional): The minimum value to use when colormapping the palette when plotting a single band. Defaults to None.
vmax (float, optional): The maximum value to use when colormapping the palette when plotting a single band. Defaults to None.
nodata (float, optional): The value from the band to use to interpret as not valid data. Defaults to None.
attribution (str, optional): Attribution for the source raster. This defaults to a message about it being a local file.. Defaults to None.
layer_name (str, optional): The layer name to use. Defaults to 'EMIT'.
zoom_to_layer (bool, optional): Whether to zoom to the extent of the layer. Defaults to True.
visible (bool, optional): Whether the layer is visible. Defaults to True.
array_args (dict, optional): Additional arguments to pass to `array_to_memory_file` when reading the raster. Defaults to {}.
"""
if isinstance(source, str):
source = read_pace(source)
image = pace_to_image(
source, wavelengths=wavelengths, method=method, gridded=gridded
)
if isinstance(wavelengths, list) and len(wavelengths) > 1:
colormap = None
self.add_raster(
image,
indexes=indexes,
colormap=colormap,
vmin=vmin,
vmax=vmax,
nodata=nodata,
attribution=attribution,
layer_name=layer_name,
zoom_to_layer=zoom_to_layer,
visible=visible,
array_args=array_args,
**kwargs,
)
self.cog_layer_dict[layer_name]["xds"] = source
self.cog_layer_dict[layer_name]["type"] = "PACE"
add_raster(self, source, indexes=None, colormap=None, vmin=None, vmax=None, nodata=None, attribution=None, layer_name='Raster', zoom_to_layer=True, visible=True, array_args={}, **kwargs)
¶
Add a local raster dataset to the map.
If you are using this function in JupyterHub on a remote server (e.g., Binder, Microsoft Planetary Computer) and
if the raster does not render properly, try installing jupyter-server-proxy using pip install jupyter-server-proxy
,
then running the following code before calling this function. For more info, see https://bit.ly/3JbmF93.
1 2 |
|
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source |
str |
The path to the GeoTIFF file or the URL of the Cloud Optimized GeoTIFF. |
required |
indexes |
int |
The band(s) to use. Band indexing starts at 1. Defaults to None. |
None |
colormap |
str |
The name of the colormap from |
None |
vmin |
float |
The minimum value to use when colormapping the palette when plotting a single band. Defaults to None. |
None |
vmax |
float |
The maximum value to use when colormapping the palette when plotting a single band. Defaults to None. |
None |
nodata |
float |
The value from the band to use to interpret as not valid data. Defaults to None. |
None |
attribution |
str |
Attribution for the source raster. This defaults to a message about it being a local file.. Defaults to None. |
None |
layer_name |
str |
The layer name to use. Defaults to 'Raster'. |
'Raster' |
zoom_to_layer |
bool |
Whether to zoom to the extent of the layer. Defaults to True. |
True |
visible |
bool |
Whether the layer is visible. Defaults to True. |
True |
array_args |
dict |
Additional arguments to pass to |
{} |
Source code in hypercoast/hypercoast.py
def add_raster(
self,
source,
indexes=None,
colormap=None,
vmin=None,
vmax=None,
nodata=None,
attribution=None,
layer_name="Raster",
zoom_to_layer=True,
visible=True,
array_args={},
**kwargs,
):
"""Add a local raster dataset to the map.
If you are using this function in JupyterHub on a remote server (e.g., Binder, Microsoft Planetary Computer) and
if the raster does not render properly, try installing jupyter-server-proxy using `pip install jupyter-server-proxy`,
then running the following code before calling this function. For more info, see https://bit.ly/3JbmF93.
import os
os.environ['LOCALTILESERVER_CLIENT_PREFIX'] = 'proxy/{port}'
Args:
source (str): The path to the GeoTIFF file or the URL of the Cloud Optimized GeoTIFF.
indexes (int, optional): The band(s) to use. Band indexing starts at 1. Defaults to None.
colormap (str, optional): The name of the colormap from `matplotlib` to use when plotting a single band. See https://matplotlib.org/stable/gallery/color/colormap_reference.html. Default is greyscale.
vmin (float, optional): The minimum value to use when colormapping the palette when plotting a single band. Defaults to None.
vmax (float, optional): The maximum value to use when colormapping the palette when plotting a single band. Defaults to None.
nodata (float, optional): The value from the band to use to interpret as not valid data. Defaults to None.
attribution (str, optional): Attribution for the source raster. This defaults to a message about it being a local file.. Defaults to None.
layer_name (str, optional): The layer name to use. Defaults to 'Raster'.
zoom_to_layer (bool, optional): Whether to zoom to the extent of the layer. Defaults to True.
visible (bool, optional): Whether the layer is visible. Defaults to True.
array_args (dict, optional): Additional arguments to pass to `array_to_memory_file` when reading the raster. Defaults to {}.
"""
import numpy as np
if nodata is None:
nodata = np.nan
super().add_raster(
source,
indexes=indexes,
colormap=colormap,
vmin=vmin,
vmax=vmax,
nodata=nodata,
attribution=attribution,
layer_name=layer_name,
zoom_to_layer=zoom_to_layer,
visible=visible,
array_args=array_args,
**kwargs,
)
search_emit(self, default_dataset='EMITL2ARFL')
¶
Adds a NASA Earth Data search tool to the map with a default dataset for EMIT.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
default_dataset |
str |
The default dataset to search for. Defaults to "EMITL2ARFL". |
'EMITL2ARFL' |
Source code in hypercoast/hypercoast.py
def search_emit(self, default_dataset="EMITL2ARFL"):
"""
Adds a NASA Earth Data search tool to the map with a default dataset for EMIT.
Args:
default_dataset (str, optional): The default dataset to search for. Defaults to "EMITL2ARFL".
"""
self.add("nasa_earth_data", default_dataset=default_dataset)
search_pace(self, default_dataset='PACE_OCI_L2_AOP_NRT')
¶
Adds a NASA Earth Data search tool to the map with a default dataset for PACE.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
default_dataset |
str |
The default dataset to search for. Defaults to "PACE_OCI_L2_AOP_NRT". |
'PACE_OCI_L2_AOP_NRT' |
Source code in hypercoast/hypercoast.py
def search_pace(self, default_dataset="PACE_OCI_L2_AOP_NRT"):
"""
Adds a NASA Earth Data search tool to the map with a default dataset for PACE.
Args:
default_dataset (str, optional): The default dataset to search for. Defaults to "PACE_OCI_L2_AOP_NRT".
"""
self.add("nasa_earth_data", default_dataset=default_dataset)
set_plot_options(self, add_marker_cluster=False, plot_type=None, overlay=False, position='bottomright', min_width=None, max_width=None, min_height=None, max_height=None, **kwargs)
¶
Sets plotting options.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
add_marker_cluster |
bool |
Whether to add a marker cluster. Defaults to False. |
False |
sample_scale |
float |
A nominal scale in meters of the projection to sample in . Defaults to None. |
required |
plot_type |
str |
The plot type can be one of "None", "bar", "scatter" or "hist". Defaults to None. |
None |
overlay |
bool |
Whether to overlay plotted lines on the figure. Defaults to False. |
False |
position |
str |
Position of the control, can be ‘bottomleft’, ‘bottomright’, ‘topleft’, or ‘topright’. Defaults to 'bottomright'. |
'bottomright' |
min_width |
int |
Min width of the widget (in pixels), if None it will respect the content size. Defaults to None. |
None |
max_width |
int |
Max width of the widget (in pixels), if None it will respect the content size. Defaults to None. |
None |
min_height |
int |
Min height of the widget (in pixels), if None it will respect the content size. Defaults to None. |
None |
max_height |
int |
Max height of the widget (in pixels), if None it will respect the content size. Defaults to None. |
None |
Source code in hypercoast/hypercoast.py
def set_plot_options(
self,
add_marker_cluster=False,
plot_type=None,
overlay=False,
position="bottomright",
min_width=None,
max_width=None,
min_height=None,
max_height=None,
**kwargs,
):
"""Sets plotting options.
Args:
add_marker_cluster (bool, optional): Whether to add a marker cluster. Defaults to False.
sample_scale (float, optional): A nominal scale in meters of the projection to sample in . Defaults to None.
plot_type (str, optional): The plot type can be one of "None", "bar", "scatter" or "hist". Defaults to None.
overlay (bool, optional): Whether to overlay plotted lines on the figure. Defaults to False.
position (str, optional): Position of the control, can be ‘bottomleft’, ‘bottomright’, ‘topleft’, or ‘topright’. Defaults to 'bottomright'.
min_width (int, optional): Min width of the widget (in pixels), if None it will respect the content size. Defaults to None.
max_width (int, optional): Max width of the widget (in pixels), if None it will respect the content size. Defaults to None.
min_height (int, optional): Min height of the widget (in pixels), if None it will respect the content size. Defaults to None.
max_height (int, optional): Max height of the widget (in pixels), if None it will respect the content size. Defaults to None.
"""
plot_options_dict = {}
plot_options_dict["add_marker_cluster"] = add_marker_cluster
plot_options_dict["plot_type"] = plot_type
plot_options_dict["overlay"] = overlay
plot_options_dict["position"] = position
plot_options_dict["min_width"] = min_width
plot_options_dict["max_width"] = max_width
plot_options_dict["min_height"] = min_height
plot_options_dict["max_height"] = max_height
for key in kwargs:
plot_options_dict[key] = kwargs[key]
self._plot_options = plot_options_dict
if not hasattr(self, "_plot_marker_cluster"):
self._plot_marker_cluster = ipyleaflet.MarkerCluster(name="Marker Cluster")
if add_marker_cluster and (self._plot_marker_cluster not in self.layers):
self.add(self._plot_marker_cluster)
spectral_to_csv(self, filename, index=True, **kwargs)
¶
Saves the spectral data to a CSV file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str |
The output CSV file. |
required |
index |
bool |
Whether to write the index. Defaults to True. |
True |
Source code in hypercoast/hypercoast.py
def spectral_to_csv(self, filename, index=True, **kwargs):
"""Saves the spectral data to a CSV file.
Args:
filename (str): The output CSV file.
index (bool, optional): Whether to write the index. Defaults to True.
"""
df = self.spectral_to_df()
df = df.rename_axis("band")
df.to_csv(filename, index=index, **kwargs)
spectral_to_df(self, **kwargs)
¶
Converts the spectral data to a pandas DataFrame.
Returns:
Type | Description |
---|---|
pd.DataFrame |
The spectral data as a pandas DataFrame. |
Source code in hypercoast/hypercoast.py
def spectral_to_df(self, **kwargs):
"""Converts the spectral data to a pandas DataFrame.
Returns:
pd.DataFrame: The spectral data as a pandas DataFrame.
"""
import pandas as pd
df = pd.DataFrame(self._spectral_data, **kwargs)
return df