Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentsarago committed Oct 22, 2024
1 parent 522f132 commit c13cf41
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
1 change: 0 additions & 1 deletion docs/src/advanced/dynamic.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ class DynamicStacBackend(BaseBackend):
default=(-180, -90, 180, 90)
)
crs: CRS = attr.ib(default=WGS84_CRS)
geographic_crs: CRS = attr.ib(default=WGS84_CRS)

# STAC API related options
# max_items | next_link_key | limit
Expand Down
21 changes: 10 additions & 11 deletions docs/src/examples/Create_a_Dynamic_RtreeBackend.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"with httpx.stream(\"GET\", url) as r:\n",
" r.raise_for_status()\n",
" with open(\"tiles.p\", \"wb\") as f:\n",
" for chunk in r.iter_bytes(chunk_size=8192): \n",
" for chunk in r.iter_bytes(chunk_size=8192):\n",
" f.write(chunk)\n",
"\n",
"# Load tile index and create rtree index\n",
Expand Down Expand Up @@ -162,15 +162,15 @@
"class DynamicRtreeBackend(BaseBackend):\n",
"\n",
" asset_filter: Callable = attr.ib(default=lambda x: x)\n",
" \n",
"\n",
" # The reader is read-only, we can't pass mosaic_def to the init method\n",
" mosaic_def: MosaicJSON = attr.ib(init=False)\n",
"\n",
" index = attr.ib(init=False)\n",
" \n",
"\n",
" tms: morecantile.TileMatrixSet = attr.ib(default=WEB_MERCATOR_TMS)\n",
" minzoom: int = attr.ib(default=12) # we know this by analysing the NAIP data \n",
" maxzoom: int = attr.ib(default=17) # we know this by analysing the NAIP data \n",
" minzoom: int = attr.ib(default=12) # we know this by analysing the NAIP data\n",
" maxzoom: int = attr.ib(default=17) # we know this by analysing the NAIP data\n",
"\n",
" _backend_name = \"DynamicSTAC\"\n",
"\n",
Expand All @@ -190,16 +190,15 @@
" self.index = index.Index(self.input)\n",
" self.bounds = tuple(self.index.bounds)\n",
" self.crs = self.tms.rasterio_geographic_crs\n",
" self.geographic_crs = self.tms.rasterio_geographic_crs\n",
"\n",
" def close(self):\n",
" \"\"\"Close SQLite connection.\"\"\"\n",
" self.index.close()\n",
"\n",
" def __exit__(self, exc_type, exc_value, traceback):\n",
" \"\"\"Support using with Context Managers.\"\"\"\n",
" self.close() \n",
" \n",
" self.close()\n",
"\n",
" def write(self, overwrite: bool = True):\n",
" \"\"\"This method is not used but is required by the abstract class.\"\"\"\n",
" pass\n",
Expand Down Expand Up @@ -274,14 +273,14 @@
"import pathlib\n",
"\n",
"def latest_naip_asset(assets: List[str]) -> List[str]:\n",
" \n",
"\n",
" def get_info(asset) -> Dict:\n",
" parts = pathlib.Path(asset).parts\n",
" capture_date = parts[-1].split(\"_\")[-1].rstrip(\".tif\")\n",
" resolution = int(parts[-3].split(\"_\")[1].rstrip(\"cm\"))\n",
" fname_parts = parts[-1].split(\"_\")\n",
" quadrangle = f\"{fname_parts[1]}_{fname_parts[2]}_{fname_parts[3]}\"\n",
" \n",
"\n",
" return {\n",
" \"path\": asset,\n",
" \"capture_date\": capture_date,\n",
Expand All @@ -290,7 +289,7 @@
" }\n",
"\n",
" asset_info = [get_info(f) for f in assets]\n",
" \n",
"\n",
" # Sort by resolution and by dates\n",
" asset_info = sorted(\n",
" asset_info, key=lambda item: (item[\"capture_date\"], -item[\"resolution\"]),\n",
Expand Down
1 change: 0 additions & 1 deletion docs/src/examples/Create_a_Dynamic_StacBackend.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
" default=(-180, -90, 180, 90)\n",
" )\n",
" crs: CRS = attr.ib(default=WGS84_CRS)\n",
" geographic_crs: CRS = attr.ib(default=WGS84_CRS)\n",
"\n",
" # STAC API related options\n",
" # max_items | next_link_key | limit\n",
Expand Down
4 changes: 2 additions & 2 deletions docs/src/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,8 @@ with S3Backend("s3://mybucket/amosaic.json") as mosaic:
mosaic.maxzoom # attribute - Mosaic (default to tms or mosaic maxzoom)

mosaic.crs # property - CRS (from mosaic's TMS geographic CRS)
mosaic.geographic_crs # property - CRS (from mosaic's TMS geographic CRS)
mosaic.bounds # property - Mosaic bounds in `mosaic.crs`
mosaic.center # property - Mosaic center (lon, lat, minzoom)
mosaic.geographic_bounds # property - Mosaic bounds in `mosaic.geographic_crs`

mosaic.mosaicid # property - Return sha224 id from the mosaicjson doc
mosaic.quadkey_zoom # property - Return Quadkey zoom of the mosaic
Expand All @@ -84,6 +82,8 @@ with S3Backend("s3://mybucket/amosaic.json") as mosaic:

mosaic.info(quadkeys=True/False) # method - spatial_info, list of quadkeys and mosaic name

mosaic.get_geographic_bounds(crs: CRS) # method - Return mosaic bounds in a geographic CRS

mosaic.assets_for_tile(x, y, z) # method - Find assets for a specific mercator tile
mosaic.assets_for_point(lng, lat) # method - Find assets for a specific point
mosaic.assets_for_bbox(xmin, ymin, xmax, ymax) # method - Find assets for a specific bbox
Expand Down

0 comments on commit c13cf41

Please sign in to comment.