Skip to content

Commit

Permalink
Changed COG and STAC function names #61
Browse files Browse the repository at this point in the history
  • Loading branch information
giswqs committed Jun 28, 2021
1 parent ded51db commit 4719259
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 60 deletions.
16 changes: 8 additions & 8 deletions docs/notebooks/03_cog_stac.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"metadata": {},
"outputs": [],
"source": [
"leafmap.get_cog_bounds(url)"
"leafmap.cog_bounds(url)"
]
},
{
Expand All @@ -88,7 +88,7 @@
"metadata": {},
"outputs": [],
"source": [
"leafmap.get_cog_center(url)"
"leafmap.cog_center(url)"
]
},
{
Expand All @@ -97,7 +97,7 @@
"metadata": {},
"outputs": [],
"source": [
"leafmap.get_cog_bands(url)"
"leafmap.cog_bands(url)"
]
},
{
Expand All @@ -106,7 +106,7 @@
"metadata": {},
"outputs": [],
"source": [
"leafmap.get_cog_tile(url)"
"leafmap.cog_tile(url)"
]
},
{
Expand Down Expand Up @@ -186,7 +186,7 @@
"metadata": {},
"outputs": [],
"source": [
"leafmap.get_stac_bounds(url)"
"leafmap.stac_bounds(url)"
]
},
{
Expand All @@ -195,7 +195,7 @@
"metadata": {},
"outputs": [],
"source": [
"leafmap.get_stac_center(url)"
"leafmap.stac_center(url)"
]
},
{
Expand All @@ -204,7 +204,7 @@
"metadata": {},
"outputs": [],
"source": [
"leafmap.get_stac_bands(url)"
"leafmap.stac_bands(url)"
]
},
{
Expand All @@ -213,7 +213,7 @@
"metadata": {},
"outputs": [],
"source": [
"leafmap.get_stac_tile(url, bands=['B3', 'B2', 'B1'])"
"leafmap.stac_tile(url, bands=['B3', 'B2', 'B1'])"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions docs/notebooks/04_cog_mosaic.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"metadata": {},
"outputs": [],
"source": [
"# leafmap.get_cog_mosaic_from_file(pre_fire_url)"
"# leafmap.cog_mosaic_from_file(pre_fire_url)"
]
},
{
Expand All @@ -89,7 +89,7 @@
"metadata": {},
"outputs": [],
"source": [
"# leafmap.get_cog_mosaic_from_file(post_fire_url)"
"# leafmap.cog_mosaic_from_file(post_fire_url)"
]
},
{
Expand Down
16 changes: 8 additions & 8 deletions examples/notebooks/03_cog_stac.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"metadata": {},
"outputs": [],
"source": [
"leafmap.get_cog_bounds(url)"
"leafmap.cog_bounds(url)"
]
},
{
Expand All @@ -88,7 +88,7 @@
"metadata": {},
"outputs": [],
"source": [
"leafmap.get_cog_center(url)"
"leafmap.cog_center(url)"
]
},
{
Expand All @@ -97,7 +97,7 @@
"metadata": {},
"outputs": [],
"source": [
"leafmap.get_cog_bands(url)"
"leafmap.cog_bands(url)"
]
},
{
Expand All @@ -106,7 +106,7 @@
"metadata": {},
"outputs": [],
"source": [
"leafmap.get_cog_tile(url)"
"leafmap.cog_tile(url)"
]
},
{
Expand Down Expand Up @@ -186,7 +186,7 @@
"metadata": {},
"outputs": [],
"source": [
"leafmap.get_stac_bounds(url)"
"leafmap.stac_bounds(url)"
]
},
{
Expand All @@ -195,7 +195,7 @@
"metadata": {},
"outputs": [],
"source": [
"leafmap.get_stac_center(url)"
"leafmap.stac_center(url)"
]
},
{
Expand All @@ -204,7 +204,7 @@
"metadata": {},
"outputs": [],
"source": [
"leafmap.get_stac_bands(url)"
"leafmap.stac_bands(url)"
]
},
{
Expand All @@ -213,7 +213,7 @@
"metadata": {},
"outputs": [],
"source": [
"leafmap.get_stac_tile(url, bands=['B3', 'B2', 'B1'])"
"leafmap.stac_tile(url, bands=['B3', 'B2', 'B1'])"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions examples/notebooks/04_cog_mosaic.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"metadata": {},
"outputs": [],
"source": [
"# leafmap.get_cog_mosaic_from_file(pre_fire_url)"
"# leafmap.cog_mosaic_from_file(pre_fire_url)"
]
},
{
Expand All @@ -89,7 +89,7 @@
"metadata": {},
"outputs": [],
"source": [
"# leafmap.get_cog_mosaic_from_file(post_fire_url)"
"# leafmap.cog_mosaic_from_file(post_fire_url)"
]
},
{
Expand Down
28 changes: 14 additions & 14 deletions leafmap/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ def create_code_cell(code="", where="below"):
)


def get_cog_tile(url, titiler_endpoint="https://api.cogeo.xyz/", **kwargs):
def cog_tile(url, titiler_endpoint="https://api.cogeo.xyz/", **kwargs):
"""Get a tile layer from a Cloud Optimized GeoTIFF (COG).
Source code adapted from https://developmentseed.org/titiler/examples/Working_with_CloudOptimizedGeoTIFF_simple/
Expand Down Expand Up @@ -795,7 +795,7 @@ def get_cog_tile(url, titiler_endpoint="https://api.cogeo.xyz/", **kwargs):
return r["tiles"][0]


def get_cog_mosaic(
def cog_mosaic(
links,
titiler_endpoint="https://api.cogeo.xyz/",
username="anonymous",
Expand Down Expand Up @@ -860,7 +860,7 @@ def get_cog_mosaic(
raise Exception(e)


def get_cog_mosaic_from_file(
def cog_mosaic_from_file(
filepath,
skip_rows=0,
titiler_endpoint="https://api.cogeo.xyz/",
Expand Down Expand Up @@ -898,13 +898,13 @@ def get_cog_mosaic_from_file(

links = links[skip_rows:]
# print(links)
mosaic = get_cog_mosaic(
mosaic = cog_mosaic(
links, titiler_endpoint, username, layername, overwrite, verbose, **kwargs
)
return mosaic


def get_cog_bounds(url, titiler_endpoint="https://api.cogeo.xyz/"):
def cog_bounds(url, titiler_endpoint="https://api.cogeo.xyz/"):
"""Get the bounding box of a Cloud Optimized GeoTIFF (COG).
Args:
Expand All @@ -925,7 +925,7 @@ def get_cog_bounds(url, titiler_endpoint="https://api.cogeo.xyz/"):
return bounds


def get_cog_center(url, titiler_endpoint="https://api.cogeo.xyz/"):
def cog_center(url, titiler_endpoint="https://api.cogeo.xyz/"):
"""Get the centroid of a Cloud Optimized GeoTIFF (COG).
Args:
Expand All @@ -935,12 +935,12 @@ def get_cog_center(url, titiler_endpoint="https://api.cogeo.xyz/"):
Returns:
tuple: A tuple representing (longitude, latitude)
"""
bounds = get_cog_bounds(url, titiler_endpoint)
bounds = cog_bounds(url, titiler_endpoint)
center = ((bounds[0] + bounds[2]) / 2, (bounds[1] + bounds[3]) / 2) # (lat, lon)
return center


def get_cog_bands(url, titiler_endpoint="https://api.cogeo.xyz/"):
def cog_bands(url, titiler_endpoint="https://api.cogeo.xyz/"):
"""Get band names of a Cloud Optimized GeoTIFF (COG).
Args:
Expand All @@ -963,7 +963,7 @@ def get_cog_bands(url, titiler_endpoint="https://api.cogeo.xyz/"):
return bands


def get_stac_tile(url, bands=None, titiler_endpoint="https://api.cogeo.xyz/", **kwargs):
def stac_tile(url, bands=None, titiler_endpoint="https://api.cogeo.xyz/", **kwargs):
"""Get a tile layer from a single SpatialTemporal Asset Catalog (STAC) item.
Args:
Expand Down Expand Up @@ -991,7 +991,7 @@ def get_stac_tile(url, bands=None, titiler_endpoint="https://api.cogeo.xyz/", **
if "maxzoom" in kwargs.keys():
params["maxzoom"] = kwargs["maxzoom"]

allowed_bands = get_stac_bands(url, titiler_endpoint)
allowed_bands = stac_bands(url, titiler_endpoint)

if bands is None:
bands = [allowed_bands[0]]
Expand All @@ -1014,7 +1014,7 @@ def get_stac_tile(url, bands=None, titiler_endpoint="https://api.cogeo.xyz/", **
return r["tiles"][0]


def get_stac_bounds(url, titiler_endpoint="https://api.cogeo.xyz/"):
def stac_bounds(url, titiler_endpoint="https://api.cogeo.xyz/"):
"""Get the bounding box of a single SpatialTemporal Asset Catalog (STAC) item.
Args:
Expand All @@ -1032,7 +1032,7 @@ def get_stac_bounds(url, titiler_endpoint="https://api.cogeo.xyz/"):
return bounds


def get_stac_center(url, titiler_endpoint="https://api.cogeo.xyz/"):
def stac_center(url, titiler_endpoint="https://api.cogeo.xyz/"):
"""Get the centroid of a single SpatialTemporal Asset Catalog (STAC) item.
Args:
Expand All @@ -1042,12 +1042,12 @@ def get_stac_center(url, titiler_endpoint="https://api.cogeo.xyz/"):
Returns:
tuple: A tuple representing (longitude, latitude)
"""
bounds = get_stac_bounds(url, titiler_endpoint)
bounds = stac_bounds(url, titiler_endpoint)
center = ((bounds[0] + bounds[2]) / 2, (bounds[1] + bounds[3]) / 2) # (lat, lon)
return center


def get_stac_bands(url, titiler_endpoint="https://api.cogeo.xyz/"):
def stac_bands(url, titiler_endpoint="https://api.cogeo.xyz/"):
"""Get band names of a single SpatialTemporal Asset Catalog (STAC) item.
Args:
Expand Down
20 changes: 10 additions & 10 deletions leafmap/foliumap.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,8 +631,8 @@ def add_cog_layer(
shown (bool, optional): A flag indicating whether the layer should be on by default. Defaults to True.
titiler_endpoint (str, optional): Titiler endpoint. Defaults to "https://api.cogeo.xyz/".
"""
tile_url = get_cog_tile(url, titiler_endpoint, **kwargs)
center = get_cog_center(url, titiler_endpoint) # (lon, lat)
tile_url = cog_tile(url, titiler_endpoint, **kwargs)
center = cog_center(url, titiler_endpoint) # (lon, lat)
self.add_tile_layer(
url=tile_url,
name=name,
Expand Down Expand Up @@ -671,7 +671,7 @@ def add_cog_mosaic(
verbose (bool, optional): Whether or not to print descriptions. Defaults to True.
"""
layername = name.replace(" ", "_")
tile = get_cog_mosaic(
tile = cog_mosaic(
links,
titiler_endpoint=titiler_endpoint,
username=username,
Expand All @@ -688,7 +688,7 @@ def add_cog_mosaic(
)
coords = []
for link in links:
coord = get_cog_bounds(link)
coord = cog_bounds(link)
if coord is not None:
coords.append(coord)
fc = coords_to_geojson(coords)
Expand All @@ -705,7 +705,7 @@ def add_cog_mosaic(
if verbose:
print("The footprint layer has been added.")
else:
center = get_cog_center(links[0], titiler_endpoint)
center = cog_center(links[0], titiler_endpoint)

self.set_center(center[0], center[1], zoom=6)

Expand Down Expand Up @@ -755,7 +755,7 @@ def add_cog_mosaic_from_file(

links = links[skip_rows:]

tile = get_cog_mosaic(
tile = cog_mosaic(
links,
titiler_endpoint=titiler_endpoint,
username=username,
Expand All @@ -772,7 +772,7 @@ def add_cog_mosaic_from_file(
)
coords = []
for link in links:
coord = get_cog_bounds(link)
coord = cog_bounds(link)
if coord is not None:
coords.append(coord)
fc = coords_to_geojson(coords)
Expand All @@ -789,7 +789,7 @@ def add_cog_mosaic_from_file(
if verbose:
print("The footprint layer has been added.")
else:
center = get_cog_center(links[0], titiler_endpoint)
center = cog_center(links[0], titiler_endpoint)

self.set_center(center[0], center[1], zoom=6)

Expand All @@ -814,8 +814,8 @@ def add_stac_layer(
shown (bool, optional): A flag indicating whether the layer should be on by default. Defaults to True.
titiler_endpoint (str, optional): Titiler endpoint. Defaults to "https://api.cogeo.xyz/".
"""
tile_url = get_stac_tile(url, bands, titiler_endpoint, **kwargs)
center = get_stac_center(url, titiler_endpoint)
tile_url = stac_tile(url, bands, titiler_endpoint, **kwargs)
center = stac_center(url, titiler_endpoint)
self.add_tile_layer(
url=tile_url,
name=name,
Expand Down
Loading

0 comments on commit 4719259

Please sign in to comment.