Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: unproject images in add_raster #435

Merged
merged 3 commits into from
Mar 29, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion sepal_ui/mapping/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
WidgetControl,
ZoomControl,
)
from rasterio.crs import CRS
from traitlets import Bool, link, observe
import ipyvuetify as v
import ipyleaflet
Expand Down Expand Up @@ -405,6 +406,11 @@ def add_raster(
# That will also improve performances as the generation of a tile can be done in parallel using Dask.
da = da.chunk((1000, 1000))

# unproject if necessary
epsg_4326 = "EPSG:4326"
if da.rio.crs != CRS.from_string(epsg_4326):
da = da.rio.reproject(epsg_4326)

# Create a named tuple with raster bounds and resolution
local_raster = collections.namedtuple(
"LocalRaster",
Expand Down Expand Up @@ -625,7 +631,7 @@ def addLayer(
inverted = vis_params.pop("inverted", None)
if inverted is not None:

# get the index of the bands taht need to be inverted
# get the index of the bands that need to be inverted
index_list = [i for i, v in enumerate(inverted) if v is True]

# multiply everything by -1
Expand Down