Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Multiband support and MPL colormaps #28

Merged
merged 12 commits into from Dec 6, 2021
Merged

Multiband support and MPL colormaps #28

merged 12 commits into from Dec 6, 2021

Conversation

banesullivan
Copy link
Owner

@banesullivan banesullivan commented Dec 5, 2021

Resolve #22

This all feels a bit hacky, but it works. @giswqs, would you please review/test.

Here is an example

from localtileserver import get_leaflet_tile_layer, TileClient
from ipyleaflet import Map

# First, create a tile server from local raster file
tile_client = TileClient('./landsat.tif')

# Create ipyleaflet tile layer from that server
t = get_leaflet_tile_layer(tile_client, band=[4, 3, 2])

# Create ipyleaflet map, add tile layer, and display
m = Map(center=tile_client.center())
m.add_layer(t)
m

Screen Shot 2021-12-05 at 1 12 18 PM 1

or like the screenshots in #22:

# Create ipyleaflet tile layer from that server
t = get_leaflet_tile_layer(tile_client, band=[5, 4, 3])

# Create ipyleaflet map, add tile layer, and display
m = Map(center=tile_client.center())
m.add_layer(t)
m

Screen Shot 2021-12-05 at 1 17 28 PM


To do:

  • Update type hints and documentation
  • Add example to README
  • User test

@codecov-commenter
Copy link

codecov-commenter commented Dec 5, 2021

Codecov Report

Merging #28 (36be185) into main (c9890cc) will increase coverage by 1.10%.
The diff coverage is 85.38%.

@@            Coverage Diff             @@
##             main      #28      +/-   ##
==========================================
+ Coverage   76.51%   77.61%   +1.10%     
==========================================
  Files          12       14       +2     
  Lines         545      630      +85     
==========================================
+ Hits          417      489      +72     
- Misses        128      141      +13     

@banesullivan
Copy link
Owner Author

banesullivan commented Dec 5, 2021

Also, @giswqs, what Landsat data is this? 7? 8? I'd like to use it for a demo and know which bands are what per something like: http://gsp.humboldt.edu/olm/Courses/GSP_216/lessons/composites.html

So that I can make a false color image, etc.

edit: this looks like LS8 to me

@banesullivan
Copy link
Owner Author

banesullivan commented Dec 5, 2021

This example was added to the README:

from localtileserver import get_leaflet_tile_layer, TileClient
from ipyleaflet import Map, ScaleControl, FullScreenControl, SplitMapControl

# First, create a tile server from local raster file
tile_client = TileClient('landsat.tif')

# Create 2 tile layers from same raster viewing different bands
l = get_leaflet_tile_layer(tile_client, band=[7, 5, 4])
r = get_leaflet_tile_layer(tile_client, band=[5, 3, 2])

# Make the ipyleaflet map
m = Map(center=tile_client.center(), zoom=12)
control = SplitMapControl(left_layer=l, right_layer=r)
m.add_control(control)
m.add_control(ScaleControl(position='bottomleft'))
m.add_control(FullScreenControl())
m

ipyleaflet-multi-bands

@giswqs
Copy link

giswqs commented Dec 5, 2021

This is AWESOME! I can confirm that it works for both local raster datasets and remote pre-tiled COG. The sample dataset I provided is Landsat 7 image.

from localtileserver import get_leaflet_tile_layer, TileClient
from ipyleaflet import Map

# First, create a tile server from local raster file
# tile_client = TileClient('./landsat7.tif')
url = 'https://opendata.digitalglobe.com/events/california-fire-2020/pre-event/2018-02-16/pine-gulch-fire20/1030010076004E00.tif'

tile_client = TileClient(url)

# Create ipyleaflet tile layer from that server
t = get_leaflet_tile_layer(tile_client, band=[3, 2, 1])

# Create ipyleaflet map, add tile layer, and display
m = Map(center=tile_client.center())
m.add_layer(t)
m

@giswqs
Copy link

giswqs commented Dec 5, 2021

By default, if band is not provided, the image looks like this. Maybe there is a nodata issue?

image

@giswqs
Copy link

giswqs commented Dec 5, 2021

Here is the dataset I used for the example above.
https://drive.google.com/file/d/16ji8ze8gqSR1kJssf7vqdhR3d58ZBYT0/view?usp=sharing

@banesullivan banesullivan changed the title Multiband support Multiband support and MPL colormaps Dec 5, 2021
@banesullivan
Copy link
Owner Author

I can reproduce that visual effect with the shared file on my end. I suspect there is an issue with the alpha channel on that particular image rather than a nodata issue or an issue with the tile serving

@banesullivan banesullivan merged commit 085c9ea into main Dec 6, 2021
@banesullivan banesullivan deleted the rgb branch December 6, 2021 00:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support band selection for multi-spectral imagery
3 participants