Skip to content

Commit

Permalink
Update numpy_to_raster
Browse files Browse the repository at this point in the history
  • Loading branch information
banesullivan committed Jun 14, 2023
1 parent ff70753 commit 70e1a22
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions localtileserver/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# flake8: noqa: F401
from localtileserver._version import __version__
from localtileserver.client import RemoteTileClient, TileClient, get_or_create_tile_client
from localtileserver.helpers import hillshade, parse_shapely, polygon_to_geojson, save_new_raster
from localtileserver.report import Report
from localtileserver.tiler import get_cache_dir, make_vsi, purge_cache
from localtileserver.validate import validate_cog
Expand Down
5 changes: 5 additions & 0 deletions localtileserver/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,16 @@ def numpy_to_raster(ras_meta, data, out_path: str = None):
use a temporary file
"""
if data.ndim == 2:
data = data[np.newaxis, ...]

ras_meta = ras_meta.copy()
ras_meta.update({"count": data.shape[0]})
ras_meta.update({"dtype": str(data.dtype)})
ras_meta.update({"height": data.shape[1]})
ras_meta.update({"width": data.shape[2]})
ras_meta.update({"compress": "lzw"})
ras_meta.update({"driver": "GTiff"})

if not out_path:
ext = get_extensions_from_driver(ras_meta["driver"])[0]
Expand Down

0 comments on commit 70e1a22

Please sign in to comment.