Comments (35)
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 0 <= values < 256
?
from xarray_leaflet.
The issue in doing da = da / da.max()
is that you are converting (in this case) uint8
values to float64
, which multiplies the array size by 8. It might be acceptable in your case but for bigger data it might not. Maybe a better solution would be to analyze the values' type and to assume integer type values can span the whole range of possible values.
I push another commit that should fix the black background. This is not an easy issue since if we don't want to change the array data type we need to choose a nodata value that is in the range of possible values, but hopefully not present in the data. Usually people choose something like -9999 for integer types, but your data type is unsigned integer in the 0-255 range. BTW, your dataset is malformed because it says the nodata value is float('nan')
, which is not possible for an uint8
type. Anyways, a workaround for now is to use:
da = da.rio.write_nodata(0)
It doesn't seem to affect the image. Also, you must not use da = da / da.max()
with this new commit.
from xarray_leaflet.
Some functions were just added yesterday. You need to install the development version from GitHub
pip install git+https://github.com/giswqs/leafmap.git
from xarray_leaflet.
Do you mean being able to select the band using e.g. LayersControl
?
from xarray_leaflet.
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? da = da.sel(band=1)
only selects on band.
from xarray_leaflet.
When I select three bands using da = da.sel(band=[5, 4, 3])
, the plot function won't work.
from xarray_leaflet.
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).
That shouldn't be too hard to implement.
from xarray_leaflet.
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.
from xarray_leaflet.
Nice. I'll try to work on that soon.
from xarray_leaflet.
Awesome! Thanks a lot.
from xarray_leaflet.
I have an initial implementation, can you try installing with:
pip install git+https://github.com/davidbrochart/xarray_leaflet
The API is: da.leaflet.plot(m, rgb_dim='band')
and the bands you select with e.g. da = da.sel(band=[5, 4, 3])
must correspond to R, G and B.
from xarray_leaflet.
Thanks a lot for your fast implementation. It seems the image can be displayed when zoomed in very closely. Otherwise, you will see the black background and weird colormap. Commenting out this line da = xr.where(da==nan, np.nan, da)
won't work.
Here are the GeoTIFF (10 MB) and notebook I used.
from xarray_leaflet.
Thanks, I will have a look at it.
from xarray_leaflet.
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, da = da / 255
might not always work. Instead, I use da = da / da.max()
, which seems to solve the colormap issue. However, the black background issue still exists. da = xr.where(da==nan, np.nan, da)
has no effect in this case.
from xarray_leaflet.
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 plot()
function, is it possible to get the lat/lon of the raster centroid, and then call m.center = [lat, lon]
to center the map?
from xarray_leaflet.
Thanks to your help, I have implemented an add_raster()
function in geemap based on xarray_leaflet. Here are the source code and notebook example. I have not yet made xarray_leaflet as an official dependency for geemap. As xarray_leaflet depends on rasterio, which could be challenging to install for Windows users. I need more testing to automate the package installation.
from xarray_leaflet.
Nice! Yes, it is probably better also to wait a bit until xarray-leaflet becomes more stable.
from xarray_leaflet.
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.
from xarray_leaflet.
It would be great if you can add support for centering the map at the raster centroid once the raster is loaded.
Will do.
from xarray_leaflet.
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.
/home/qiusheng/.local/lib/python3.7/site-packages/matplotlib/colors.py:527: RuntimeWarning: invalid value encountered in less
xa[xa < 0] = -1
from xarray_leaflet.
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)
from xarray_leaflet.
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.
from xarray_leaflet.
I just tested xarray_leaflet in two fresh conda envs (python=3.7), one using pip install xarray_leaflet
and the other using mamba install xarray_leaflet -c conda-forge
.
Both envs experienced the same black background issue with the introduction.ipynb
. Interestingly, the warning below only appeared in the env with xarray_leaflet installed using mamba.
/home/qiusheng/.local/lib/python3.7/site-packages/matplotlib/colors.py:527: RuntimeWarning: invalid value encountered in less
xa[xa < 0] = -1
from xarray_leaflet.
Could you report the output of conda list
?
from xarray_leaflet.
/home/qiusheng/.local/lib/python3.7/site-packages/matplotlib/colors.py:527: RuntimeWarning: invalid value encountered in less
xa[xa < 0] = -1
Note that this location is not from a conda environment.
from xarray_leaflet.
(xr) [qiusheng@home-linux xarray_leaflet]$ conda list
# packages in environment at /home/qiusheng/.conda/envs/xr:
#
# Name Version Build Channel
_libgcc_mutex 0.1 conda_forge conda-forge
_openmp_mutex 4.5 0_gnu conda-forge
affine 2.3.0 py_0 conda-forge
attrs 19.3.0 py_0 conda-forge
backcall 0.2.0 pyh9f0ad1d_0 conda-forge
bleach 3.1.5 pyh9f0ad1d_0 conda-forge
boost-cpp 1.72.0 h8e57a91_0 conda-forge
branca 0.3.1 py_0 conda-forge
brotlipy 0.7.0 py37h8f50634_1000 conda-forge
bzip2 1.0.8 h516909a_2 conda-forge
ca-certificates 2020.6.24 0
cairo 1.16.0 hcf35c78_1003 conda-forge
certifi 2020.6.20 py37hc8dfbb8_0 conda-forge
cffi 1.14.0 py37he30daa8_1
cfitsio 3.470 h3eac812_5 conda-forge
chardet 3.0.4 py37hc8dfbb8_1006 conda-forge
click 7.1.2 pyh9f0ad1d_0 conda-forge
click-plugins 1.1.1 py_0 conda-forge
cligj 0.5.0 py_0 conda-forge
conda 4.8.3 py37hc8dfbb8_1 conda-forge
conda-package-handling 1.6.1 py37h7b6447c_0
cryptography 2.9.2 py37hb09aad4_0 conda-forge
curl 7.71.1 he644dc0_0 conda-forge
cycler 0.10.0 py_2 conda-forge
decorator 4.4.2 py_0 conda-forge
defusedxml 0.6.0 py_0 conda-forge
entrypoints 0.3 py37hc8dfbb8_1001 conda-forge
expat 2.2.9 he1b5a44_2 conda-forge
fontconfig 2.13.1 h86ecdb6_1001 conda-forge
freetype 2.10.2 he06d7ca_0 conda-forge
freexl 1.0.5 h14c3975_1002 conda-forge
geos 3.8.1 he1b5a44_0 conda-forge
geotiff 1.5.1 h05acad5_10 conda-forge
giflib 5.2.1 h516909a_2 conda-forge
glib 2.65.0 h3eb4bd4_0
hdf4 4.2.13 hf30be14_1003 conda-forge
hdf5 1.10.5 nompi_h3c11f04_1104 conda-forge
icu 64.2 he1b5a44_1 conda-forge
idna 2.10 pyh9f0ad1d_0 conda-forge
importlib-metadata 1.7.0 py37hc8dfbb8_0 conda-forge
importlib_metadata 1.7.0 0 conda-forge
ipykernel 5.3.1 py37h43977f1_0 conda-forge
ipyleaflet 0.13.1 pyh9f0ad1d_0 conda-forge
ipython 7.16.1 py37h43977f1_0 conda-forge
ipython_genutils 0.2.0 py_1 conda-forge
ipywidgets 7.5.1 py_0 conda-forge
jedi 0.17.1 py37hc8dfbb8_0 conda-forge
jinja2 2.11.2 pyh9f0ad1d_0 conda-forge
jpeg 9d h516909a_0 conda-forge
json-c 0.13.1 hbfbb72e_1002 conda-forge
jsonschema 3.2.0 py37hc8dfbb8_1 conda-forge
jupyter_client 6.1.5 py_0 conda-forge
jupyter_core 4.6.3 py37hc8dfbb8_1 conda-forge
jupyter_server 0.2.1 py37hc8dfbb8_1 conda-forge
kealib 1.4.13 hec59c27_0 conda-forge
kiwisolver 1.2.0 py37h99015e2_0 conda-forge
krb5 1.17.1 hfafb76e_1 conda-forge
ld_impl_linux-64 2.34 h53a641e_5 conda-forge
libarchive 3.3.3 h3a8160c_1008 conda-forge
libblas 3.8.0 14_openblas conda-forge
libcblas 3.8.0 14_openblas conda-forge
libcurl 7.71.1 hcdd3856_0 conda-forge
libdap4 3.20.6 h1d1bd15_0 conda-forge
libedit 3.1.20191231 h7b6447c_0
libffi 3.3 he6710b0_1
libgcc-ng 9.2.0 h24d8f2e_2 conda-forge
libgdal 2.4.4 h5439ffd_1 conda-forge
libgfortran-ng 7.5.0 hdf63c60_6 conda-forge
libgomp 9.2.0 h24d8f2e_2 conda-forge
libiconv 1.15 h516909a_1006 conda-forge
libkml 1.3.0 hb574062_1011 conda-forge
liblapack 3.8.0 14_openblas conda-forge
libnetcdf 4.7.4 nompi_h9f9fd6a_101 conda-forge
libopenblas 0.3.7 h5ec1e0e_6 conda-forge
libpng 1.6.37 hed695b0_1 conda-forge
libpq 12.2 h5513abc_1 conda-forge
libsodium 1.0.17 h516909a_0 conda-forge
libsolv 0.7.14 h8b12597_3 conda-forge
libspatialite 4.3.0a h2482549_1038 conda-forge
libssh2 1.9.0 hab1572f_2 conda-forge
libstdcxx-ng 9.2.0 hdf63c60_2 conda-forge
libtiff 4.1.0 hc7e4089_6 conda-forge
libuuid 2.32.1 h14c3975_1000 conda-forge
libwebp-base 1.1.0 h516909a_3 conda-forge
libxcb 1.14 h7b6447c_0
libxml2 2.9.10 hee79883_0 conda-forge
lz4-c 1.9.2 he1b5a44_1 conda-forge
lzo 2.10 h14c3975_1000 conda-forge
mamba 0.4.1 py37h6d3251c_0 conda-forge
markupsafe 1.1.1 py37h8f50634_1 conda-forge
matplotlib-base 3.2.2 py37h30547a4_0 conda-forge
mercantile 1.1.5 pyh9f0ad1d_0 conda-forge
mistune 0.8.4 py37h8f50634_1001 conda-forge
nbconvert 5.6.1 py37hc8dfbb8_1 conda-forge
nbformat 5.0.7 py_0
ncurses 6.2 he6710b0_1
notebook 6.0.3 py37_0 conda-forge
numpy 1.18.5 py37h8960a57_0 conda-forge
olefile 0.46 py_0 conda-forge
openjpeg 2.3.1 h981e76c_3 conda-forge
openssl 1.1.1g h516909a_0 conda-forge
packaging 20.4 pyh9f0ad1d_0 conda-forge
pandas 1.0.5 py37h0da4684_0 conda-forge
pandoc 2.10 0 conda-forge
pandocfilters 1.4.2 py_1 conda-forge
parso 0.7.0 pyh9f0ad1d_0 conda-forge
pcre 8.44 he1b5a44_0 conda-forge
pexpect 4.8.0 py37hc8dfbb8_1 conda-forge
pickleshare 0.7.5 py37hc8dfbb8_1001 conda-forge
pillow 7.2.0 py37h718be6c_0 conda-forge
pip 20.1.1 py_1 conda-forge
pixman 0.38.0 h516909a_1003 conda-forge
poppler 0.67.0 h14e79db_8 conda-forge
poppler-data 0.4.9 0 conda-forge
postgresql 12.2 h8573dbc_1 conda-forge
proj 7.0.0 h966b41f_4 conda-forge
prometheus_client 0.8.0 pyh9f0ad1d_0 conda-forge
prompt-toolkit 3.0.5 py_1 conda-forge
ptyprocess 0.6.0 py37_1000 conda-forge
pycosat 0.6.3 py37h8f50634_1004 conda-forge
pycparser 2.20 pyh9f0ad1d_2 conda-forge
pygments 2.6.1 py_0 conda-forge
pyopenssl 19.1.0 py_1 conda-forge
pyparsing 2.4.7 pyh9f0ad1d_0 conda-forge
pyproj 2.6.1.post1 py37h34dd122_0 conda-forge
pyrsistent 0.16.0 py37h8f50634_0 conda-forge
pysocks 1.7.1 py37hc8dfbb8_1 conda-forge
python 3.7.7 hcff3b4d_5
python-dateutil 2.8.1 py_0 conda-forge
python_abi 3.7 1_cp37m conda-forge
pytz 2020.1 pyh9f0ad1d_0 conda-forge
pyzmq 19.0.1 py37hac76be4_0 conda-forge
rasterio 1.1.5 py37hf4c872c_0 conda-forge
readline 8.0 h7b6447c_0
requests 2.24.0 pyh9f0ad1d_0 conda-forge
rioxarray 0.0.31 py_0 conda-forge
ruamel_yaml 0.15.87 py37h7b6447c_1
scipy 1.5.0 py37ha3d9a3c_0 conda-forge
send2trash 1.5.0 py_0 conda-forge
setuptools 49.1.0 py37hc8dfbb8_0 conda-forge
six 1.15.0 pyh9f0ad1d_0 conda-forge
snuggs 1.4.7 py_0 conda-forge
sqlite 3.32.3 h62c20be_0
terminado 0.8.3 py37hc8dfbb8_1 conda-forge
testpath 0.4.4 py_0 conda-forge
tk 8.6.10 hed695b0_0 conda-forge
tornado 6.0.4 py37h8f50634_1 conda-forge
tqdm 4.47.0 pyh9f0ad1d_0 conda-forge
traitlets 4.3.3 py37hc8dfbb8_1 conda-forge
traittypes 0.2.1 py_1 conda-forge
tzcode 2020a h516909a_0 conda-forge
urllib3 1.25.9 py_0 conda-forge
wcwidth 0.2.5 pyh9f0ad1d_0 conda-forge
webencodings 0.5.1 py_1 conda-forge
wheel 0.34.2 py_1 conda-forge
widgetsnbextension 3.5.1 py37_0 conda-forge
xarray 0.15.1 py_0 conda-forge
xarray_leaflet 0.1.10 pyh9f0ad1d_0 conda-forge
xerces-c 3.2.2 h8412b87_1004 conda-forge
xorg-kbproto 1.0.7 h14c3975_1002 conda-forge
xorg-libice 1.0.10 h516909a_0 conda-forge
xorg-libsm 1.2.3 h84519dc_1000 conda-forge
xorg-libx11 1.6.9 h516909a_0 conda-forge
xorg-libxext 1.3.4 h516909a_0 conda-forge
xorg-libxrender 0.9.10 h516909a_1002 conda-forge
xorg-renderproto 0.11.1 h14c3975_1002 conda-forge
xorg-xextproto 7.3.0 h14c3975_1002 conda-forge
xorg-xproto 7.0.31 h14c3975_1007 conda-forge
xz 5.2.5 h516909a_0 conda-forge
yaml 0.2.5 h516909a_0 conda-forge
zeromq 4.3.2 he1b5a44_2 conda-forge
zipp 3.1.0 py_0 conda-forge
zlib 1.2.11 h516909a_1006 conda-forge
zstd 1.4.4 h6597ccf_3 conda-forge
from xarray_leaflet.
from xarray_leaflet.
python 3.7.7 hcff3b4d_5
Why is python not installed from conda-forge? It seems to me that you have your base environment conflicting with your xr
environment. Note that you should have almost nothing installed in your base environment.
from xarray_leaflet.
Thanks for catching this! It seems the issue was caused by conda.
When using conda create -n xrr python=3.7
, python comes from pkgs/main/linux-64::python-3.7.7-hcff3b4d_5
When using conda create -n xrr python
, python comes from conda-forge/linux-64::python-3.8.3-cpython_he5300dc_0
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.
[qiusheng@home-linux xarray_leaflet]$ conda create -n xrr python=3.7
Collecting package metadata (current_repodata.json): done
Solving environment: done
## Package Plan ##
environment location: /home/qiusheng/.conda/envs/xrr
added / updated specs:
- python=3.7
The following packages will be downloaded:
package | build
---------------------------|-----------------
libffi-3.3 | he6710b0_2 50 KB
------------------------------------------------------------
Total: 50 KB
The following NEW packages will be INSTALLED:
_libgcc_mutex conda-forge/linux-64::_libgcc_mutex-0.1-conda_forge
_openmp_mutex conda-forge/linux-64::_openmp_mutex-4.5-0_gnu
ca-certificates pkgs/main/linux-64::ca-certificates-2020.6.24-0
certifi conda-forge/linux-64::certifi-2020.6.20-py37hc8dfbb8_0
ld_impl_linux-64 conda-forge/linux-64::ld_impl_linux-64-2.34-h53a641e_5
libedit pkgs/main/linux-64::libedit-3.1.20191231-h7b6447c_0
libffi pkgs/main/linux-64::libffi-3.3-he6710b0_2
libgcc-ng conda-forge/linux-64::libgcc-ng-9.2.0-h24d8f2e_2
libgomp conda-forge/linux-64::libgomp-9.2.0-h24d8f2e_2
libstdcxx-ng conda-forge/linux-64::libstdcxx-ng-9.2.0-hdf63c60_2
ncurses pkgs/main/linux-64::ncurses-6.2-he6710b0_1
openssl conda-forge/linux-64::openssl-1.1.1g-h516909a_0
pip conda-forge/noarch::pip-20.1.1-py_1
python pkgs/main/linux-64::python-3.7.7-hcff3b4d_5
python_abi conda-forge/linux-64::python_abi-3.7-1_cp37m
readline pkgs/main/linux-64::readline-8.0-h7b6447c_0
setuptools conda-forge/linux-64::setuptools-49.1.0-py37hc8dfbb8_0
sqlite pkgs/main/linux-64::sqlite-3.32.3-h62c20be_0
tk conda-forge/linux-64::tk-8.6.10-hed695b0_0
wheel conda-forge/noarch::wheel-0.34.2-py_1
xz conda-forge/linux-64::xz-5.2.5-h516909a_0
zlib conda-forge/linux-64::zlib-1.2.11-h516909a_1006
Proceed ([y]/n)?
[qiusheng@home-linux xarray_leaflet]$ conda create -n xrr python
Collecting package metadata (current_repodata.json): done
Solving environment: done
## Package Plan ##
environment location: /home/qiusheng/.conda/envs/xrr
added / updated specs:
- python
The following NEW packages will be INSTALLED:
_libgcc_mutex conda-forge/linux-64::_libgcc_mutex-0.1-conda_forge
_openmp_mutex conda-forge/linux-64::_openmp_mutex-4.5-0_gnu
ca-certificates pkgs/main/linux-64::ca-certificates-2020.6.24-0
certifi conda-forge/linux-64::certifi-2020.6.20-py38h32f6830_0
ld_impl_linux-64 conda-forge/linux-64::ld_impl_linux-64-2.34-h53a641e_5
libedit pkgs/main/linux-64::libedit-3.1.20191231-h7b6447c_0
libffi conda-forge/linux-64::libffi-3.2.1-he1b5a44_1007
libgcc-ng conda-forge/linux-64::libgcc-ng-9.2.0-h24d8f2e_2
libgomp conda-forge/linux-64::libgomp-9.2.0-h24d8f2e_2
libstdcxx-ng conda-forge/linux-64::libstdcxx-ng-9.2.0-hdf63c60_2
ncurses pkgs/main/linux-64::ncurses-6.2-he6710b0_1
openssl conda-forge/linux-64::openssl-1.1.1g-h516909a_0
pip conda-forge/noarch::pip-20.1.1-py_1
python conda-forge/linux-64::python-3.8.3-cpython_he5300dc_0
python_abi conda-forge/linux-64::python_abi-3.8-1_cp38
readline pkgs/main/linux-64::readline-8.0-h7b6447c_0
setuptools conda-forge/linux-64::setuptools-49.1.0-py38h32f6830_0
sqlite pkgs/main/linux-64::sqlite-3.32.3-h62c20be_0
tk conda-forge/linux-64::tk-8.6.10-hed695b0_0
wheel conda-forge/noarch::wheel-0.34.2-py_1
xz conda-forge/linux-64::xz-5.2.5-h516909a_0
zlib conda-forge/linux-64::zlib-1.2.11-h516909a_1006
Proceed ([y]/n)?
from xarray_leaflet.
I suspect you already have python3.7 installed in your base environment, and maybe notebook
also. You can check with conda list
when you open a new terminal and don't activate any environment.
I suggest you reinstall miniconda from scratch. Then you should put this in ~/.condarc
:
channels:
- conda-forge
- defaults
channel_priority: strict
With that you don't need to specify -c conda-forge
anymore.
The only thing allowed to install in your base environment is conda install mamba
, so that you can use mamba in your created environments instead of conda (much faster).
from xarray_leaflet.
I just used conda config --set channel_priority strict
, and it seems working properly now. And for sure, mamba is way faster than conda. I love it. Glad to have this haunting issue resolved. Thank you for your patience!
[qiusheng@home-linux xarray_leaflet]$ conda create -n xr python=3.7
Collecting package metadata (current_repodata.json): done
Solving environment: done
## Package Plan ##
environment location: /home/qiusheng/.conda/envs/xr
added / updated specs:
- python=3.7
The following packages will be downloaded:
package | build
---------------------------|-----------------
ca-certificates-2020.6.20 | hecda079_0 145 KB conda-forge
sqlite-3.32.3 | hcee41ef_0 2.0 MB conda-forge
------------------------------------------------------------
Total: 2.1 MB
The following NEW packages will be INSTALLED:
_libgcc_mutex conda-forge/linux-64::_libgcc_mutex-0.1-conda_forge
_openmp_mutex conda-forge/linux-64::_openmp_mutex-4.5-0_gnu
ca-certificates conda-forge/linux-64::ca-certificates-2020.6.20-hecda079_0
certifi conda-forge/linux-64::certifi-2020.6.20-py37hc8dfbb8_0
ld_impl_linux-64 conda-forge/linux-64::ld_impl_linux-64-2.34-h53a641e_5
libffi conda-forge/linux-64::libffi-3.2.1-he1b5a44_1007
libgcc-ng conda-forge/linux-64::libgcc-ng-9.2.0-h24d8f2e_2
libgomp conda-forge/linux-64::libgomp-9.2.0-h24d8f2e_2
libstdcxx-ng conda-forge/linux-64::libstdcxx-ng-9.2.0-hdf63c60_2
ncurses conda-forge/linux-64::ncurses-6.1-hf484d3e_1002
openssl conda-forge/linux-64::openssl-1.1.1g-h516909a_0
pip conda-forge/noarch::pip-20.1.1-py_1
python conda-forge/linux-64::python-3.7.6-cpython_h8356626_6
python_abi conda-forge/linux-64::python_abi-3.7-1_cp37m
readline conda-forge/linux-64::readline-8.0-hf8c457e_0
setuptools conda-forge/linux-64::setuptools-49.1.0-py37hc8dfbb8_0
sqlite conda-forge/linux-64::sqlite-3.32.3-hcee41ef_0
tk conda-forge/linux-64::tk-8.6.10-hed695b0_0
wheel conda-forge/noarch::wheel-0.34.2-py_1
xz conda-forge/linux-64::xz-5.2.5-h516909a_0
zlib conda-forge/linux-64::zlib-1.2.11-h516909a_1006
from xarray_leaflet.
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 tile_2523.tif
and landsat.tif
are plotted as expected. Further, landsat.tif
plots also correctly on leaflet using this libraryxarray_leaflet
.
However, when trying to plot tile_2523.tif
on leaflet I get this undesired output: link-to-gif
Do you maybe know what is going wrong? You can use that gist to reproduce the behaviour.
from xarray_leaflet.
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
from xarray_leaflet.
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: leafmap 0.6.1 pyhd8ed1ab_0 conda-forge
from xarray_leaflet.
Leafmap supports local COG as well. pip install git+https://github.com/giswqs/leafmap.git
import leafmap
m = leafmap.Map()
m.add_local_tile("./tile_2523.tif", band=[4,3,2])
m
from xarray_leaflet.
Related Issues (20)
- can't see data on map HOT 3
- Default CRS and nodata
- Interact with extra dimensions
- How to render xarray_leaflet with voila? E.g. $ voila xarray_interact.ipynb HOT 4
- Attribute error on open_rasterio function
- No data display HOT 5
- No data display HOT 10
- 'LeafletMap' object has no attribute 'base_url' in JupyterLab HOT 6
- are you considering releasing the colormap ? HOT 2
- Tile URL management HOT 5
- Zarr support HOT 20
- Colorbar does not show if dynamic=False
- Renamed default branch to main
- DataArrays that aren't in lat-lon co-ordinates: are they supported? HOT 3
- is it possible to filter out some values when using the plot function ?
- Extra install for vector support
- Hierarchical arrays
- module 'xarray.core' has no attribute 'rolling' HOT 1
- Installing xarray-leaflet causes jupyter server to be really slow to start HOT 9
- LocalTileLayer does not appear on map HOT 13
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xarray_leaflet.