-
Notifications
You must be signed in to change notification settings - Fork 21
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
Plot multi-band raster dataset #16
Comments
Do you mean being able to select the band using e.g. |
I meant displaying a RGB color image on the map. I am not quite familiar with xarray yet. How to select multiple bands and store them as an array? |
I see. Currently we do the opposite: from a 2D array we create a RGB (3D) image by applying a colormap. What you want is to create a RGB image from a 3D array, where one dimension has size 3 for each band (R, G and B). |
Yes, because most remote sensing datasets are mutli-band images. Users can select three bands as RGB channels to display them as one single image on the map. There are many RGB band combinations. Check this demo. In this case, there is no need to use plt.cm. |
Nice. I'll try to work on that soon. |
Awesome! Thanks a lot. |
I have an initial implementation, can you try installing with:
The API is: |
Thanks, I will have a look at it. |
So the problem is that xarray-leaflet expects normalized values (between 0 and 1), and it looks like in your case values are between 0 and 255. So this solves the issue: da = da / 255 Maybe we should just accept |
Thank you for your advice. Remote sensing images can have various pixel types, e.g., 8-bit integer, 16-bit integer, 32-bit float, etc. Therefore, |
The issue in doing da = da.rio.write_nodata(0) It doesn't seem to affect the image. Also, you must not use |
Nice!! I works as expected now. One potential improvement would be to center the map around the raster once it is loaded. For a raster covering a small area, it might not be very obvious when seen from the global map. Within the |
Thanks to your help, I have implemented an |
Nice! Yes, it is probably better also to wait a bit until xarray-leaflet becomes more stable. |
Yes, I will add dependency later. It would be great if you can add support for centering the map at the raster centroid once the raster is loaded. Closing this issue for now. Thanks. |
Will do. |
I just tested v0.1.10. It seems the black background issue is coming back. Using the introduction.ipynb, I replaced the the raster with a GeoTIFF DEM I downloaded from USGS (link, 52 MB). Also, there are warnings when using either your sample adffile or my geotiff.
|
It's working fine on my side. From the warnings that you are reporting, it looks like you forgot: da = da.rio.write_nodata(np.nan) |
This is very strange. I just created a fresh conda env, then installed xarray-leaflet. Ran the introduction.ipynb without change anything, I still got the blackground. |
I just tested xarray_leaflet in two fresh conda envs (python=3.7), one using Both envs experienced the same black background issue with the
|
Could you report the output of |
Note that this location is not from a conda environment. |
|
Why is python not installed from conda-forge? It seems to me that you have your base environment conflicting with your |
Thanks for catching this! It seems the issue was caused by conda. When using By using the conda-forge python, xarray_leaflet seems to working properly now. This conda thing is driving me nuts! Not sure why it would not pull from conda-forge when specifying python=3.7.
|
I suspect you already have python3.7 installed in your base environment, and maybe
With that you don't need to specify |
I just used
|
I'm trying to plot multispectral data following your procedure explained above. Although the data is plotted on a leaflet map the output is not as expected; it shows an "irregular" image, without smooth gradients. Presumably I misconfigured something with normalization or a colormap. In this gist you can see that when using rasterio + numpy both However, when trying to plot Do you maybe know what is going wrong? You can use that gist to reproduce the behaviour. |
COG files can be displayed using leafmap with a few lines of code. import leafmap
m= leafmap.Map()
url = "https://s3.eu-central-1.amazonaws.com/floris.calkoen.open.data/tile_2523.tif"
m.add_cog_layer(url, bidx=[4,3,2], rescale="600,2000")
m |
Thanks, that will do for reading in COG's from the cloud! But just in case I have the tif stored locally... How would you load it into leaflet then? Quick follow up: code snippet above is not working for me: see gif. What version of leafmap are you running? I'm running: |
Some functions were just added yesterday. You need to install the development version from GitHub |
Is it possible to plot multi-band raster datasets (e.g., Landsat imagery)? For now, I can only display one band at a time. It would be great if it can display three RGB bands.
The text was updated successfully, but these errors were encountered: