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

issue in Map.add_raster function #195

Closed
NickCarraway96 opened this issue Dec 7, 2020 · 18 comments
Closed

issue in Map.add_raster function #195

NickCarraway96 opened this issue Dec 7, 2020 · 18 comments
Labels
bug Something isn't working

Comments

@NickCarraway96
Copy link

  • geemap version: 0.8.4
  • Python version: 3.8.6
  • Operating System: Window 10 Pro

Description

When I tried to run tutorial 25_load_rasters, this line of code `Map.add_raster(landsat, bands=[5,4,3], layer_name='Landsat') raised an TypeError, as detailed below.

image
where da = rioxarray.open_rasterio(image, masked=True)

What I Did

This tutorial ipynb file is intact, and I haven't edited it. According to the error message, the 'rgb_dim' parameter is not expected in da.leaflet.plot function and should be deleted. Is this bug caused by the updated dependency of rioxarray (version 0.1.1 in my case)?

Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.
@giswqs
Copy link
Member

giswqs commented Dec 7, 2020

I just tested the tutorial on my Linux machine, and it worked fine. My rioxarray version is v0.1.1 as well. Not sure why it wouldn't work on Windows.

@i-ambale
Copy link

Hi Nick,

I am afraid I am not a python guru. I normally use R but not that much advanced. I hope you got help.
Thank you Nick.

@NickCarraway96
Copy link
Author

Hi Ambale,
As you can see the comment above yours, the author has mentioned that Windows users may failed to run xarray-leaflet. The bug has not been fixed yet, as I just ran the Map.add_raster function again. The advice I can give is to run it on Linux distro.

@haseeb33
Copy link

@giswqs Can you please share the xarray version as well? Because with new xarray older versions of rioxarray is not working.

@giswqs
Copy link
Member

giswqs commented Mar 29, 2022

@haseeb33 xarray-leaflet is buggy and difficult to make it work. I have switched to localtileserver. See

https://geemap.org/notebooks/83_local_tile/

@haseeb33
Copy link

@giswqs Thank you very much for the quick response. But I am disappointed to say that it's not showing expected results. The map's center shifts to the destination area but tiles aren't shown and there are no errors. Please guide to debug this issue.
Screen Shot 2022-03-30 at 7 21 38 AM

@giswqs
Copy link
Member

giswqs commented Mar 29, 2022

@haseeb33 Use the Map.add_cog_layer() function for remote COG.

https://geemap.org/notebooks/44_cog_stac

Checkout out this web page. You should be able to play with the COG layers interactively. It should also work if you run it locally.
https://leafmap.org/notebooks/03_cog_stac/

@haseeb33
Copy link

@giswqs Actually, I have local tiff files and I want to add those to the map. The above screenshot with add_remote_tile function is just to explain that it's not working on my side. Both add_remote_tile and add_local_tile .
Any guidance to debug the issue, please.
Thanks!

@giswqs
Copy link
Member

giswqs commented Mar 29, 2022

Are you running the Jupyter instance in the cloud or is Jupyter installed locally?

@haseeb33
Copy link

@giswqs I am running it on Linux server. Btw Map.add_cog_layer() works fine. Just need to find a way to run add_local_tile as well.
Screen Shot 2022-03-30 at 7 36 55 AM

@giswqs
Copy link
Member

giswqs commented Mar 29, 2022

Are you using the server physically or virtually? This makes a difference when using add_local_tile()

@haseeb33
Copy link

@giswqs I am not using any cloud-based server. These are in-house servers installed by us.

@giswqs
Copy link
Member

giswqs commented Mar 29, 2022

I understand, but where is Jupyter installed? On the same computer you are using or is it from a server (not the same computer where you are using leafmap)? If it is from a remote server, you need to add the following two lines to the beginning of a notebook.

import os
os.environ['LOCALTILESERVER_CLIENT_PREFIX'] = f'{os.environ['JUPYTERHUB_SERVICE_PREFIX'].lstrip('/')}/proxy/{{port}}'

@haseeb33
Copy link

@giswqs Everything is installed on the server. jupyter notebook, python, local raster files are also on the server. Just accessing jupyter notebook on my local computer(nothing else from the local computer interacts with note book).

@haseeb33
Copy link

There is no Key JUPYTERHUB_SERVICE_PREFIX so setting LOCALTILESERVER_CLIENT_PREFIX won't work.

environ{'PATH': '/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
        'HOSTNAME': '7b029622c57f',
        'TERM': 'xterm-color',
        'NVARCH': 'x86_64',
        'NVIDIA_REQUIRE_CUDA': 'cuda>=11.3 brand=tesla,driver>=418,driver<419 brand=tesla,driver>=440,driver<441 driver>=450',
        'NV_CUDA_CUDART_VERSION': '11.3.109-1',
        'NV_CUDA_COMPAT_PACKAGE': 'cuda-compat-11-3',
        'NV_ML_REPO_ENABLED': '1',
        'NV_ML_REPO_URL': 'https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu2004/x86_64',
        'CUDA_VERSION': '11.3.1',
        'LD_LIBRARY_PATH': '/usr/local/nvidia/lib:/usr/local/nvidia/lib64',
        'NVIDIA_VISIBLE_DEVICES': 'all',
        'NVIDIA_DRIVER_CAPABILITIES': 'compute,utility',
        'NV_CUDA_LIB_VERSION': '11.3.1-1',
        'NV_NVTX_VERSION': '11.3.109-1',
        'NV_LIBNPP_VERSION': '11.3.3.95-1',
        'NV_LIBNPP_PACKAGE': 'libnpp-11-3=11.3.3.95-1',
        'NV_LIBCUSPARSE_VERSION': '11.6.0.109-1',
        'NV_LIBCUBLAS_PACKAGE_NAME': 'libcublas-11-3',
        'NV_LIBCUBLAS_VERSION': '11.5.1.109-1',
        'NV_LIBCUBLAS_PACKAGE': 'libcublas-11-3=11.5.1.109-1',
        'NV_LIBNCCL_PACKAGE_NAME': 'libnccl2',
        'NV_LIBNCCL_PACKAGE_VERSION': '2.9.9-1',
        'NCCL_VERSION': '2.9.9-1',
        'NV_LIBNCCL_PACKAGE': 'libnccl2=2.9.9-1+cuda11.3',
        'NV_CUDA_CUDART_DEV_VERSION': '11.3.109-1',
        'NV_NVML_DEV_VERSION': '11.3.58-1',
        'NV_LIBCUSPARSE_DEV_VERSION': '11.6.0.109-1',
        'NV_LIBNPP_DEV_VERSION': '11.3.3.95-1',
        'NV_LIBNPP_DEV_PACKAGE': 'libnpp-dev-11-3=11.3.3.95-1',
        'NV_LIBCUBLAS_DEV_VERSION': '11.5.1.109-1',
        'NV_LIBCUBLAS_DEV_PACKAGE_NAME': 'libcublas-dev-11-3',
        'NV_LIBCUBLAS_DEV_PACKAGE': 'libcublas-dev-11-3=11.5.1.109-1',
        'NV_LIBNCCL_DEV_PACKAGE_NAME': 'libnccl-dev',
        'NV_LIBNCCL_DEV_PACKAGE_VERSION': '2.9.9-1',
        'NV_LIBNCCL_DEV_PACKAGE': 'libnccl-dev=2.9.9-1+cuda11.3',
        'LIBRARY_PATH': '/usr/local/cuda/lib64/stubs',
        'NV_CUDNN_VERSION': '8.2.0.53',
        'NV_CUDNN_PACKAGE': 'libcudnn8=8.2.0.53-1+cuda11.3',
        'NV_CUDNN_PACKAGE_DEV': 'libcudnn8-dev=8.2.0.53-1+cuda11.3',
        'NV_CUDNN_PACKAGE_NAME': 'libcudnn8',
        'LANG': 'C.UTF-8',
        'HOME': '/root',
        'PYDEVD_USE_FRAME_EVAL': 'NO',
        'JPY_PARENT_PID': '1',
        'CLICOLOR': '1',
        'PAGER': 'cat',
        'GIT_PAGER': 'cat',
        'MPLBACKEND': 'module://matplotlib_inline.backend_inline'}

@giswqs
Copy link
Member

giswqs commented Mar 29, 2022

This is a localtileserver issue. Try the following example. If it does not work, then you can open an issue at https://github.com/banesullivan/localtileserver/issues @banesullivan

https://github.com/banesullivan/localtileserver#-usage

from localtileserver import get_leaflet_tile_layer, TileClient
from ipyleaflet import Map

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

# Create ipyleaflet tile layer from that server
t = get_leaflet_tile_layer(tile_client)

m = Map(center=tile_client.center(), zoom=6)
m.add_child(t)
m

@haseeb33
Copy link

@giswqs Thank you very much for all the help.

@giswqs
Copy link
Member

giswqs commented Mar 29, 2022

What you described is the usage of a remote server. It does not matter if the server is in-house or hosted remotely somewhere else. I encourage you to install conda and try out the function on a local computer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants