opengeos/leafmap

leafmap add_raster function can't work in windows

mrpan opened this issue · 2 comments

mrpan commented

Environment Information

  • leafmap version:0.22.0
  • Python version:3.9
  • Operating System:windows 10

Description

error:
1019
1020 if http_error_msg:
-> 1021 raise HTTPError(http_error_msg, response=self)
1022
1023 def close(self):

HTTPError: 400 Client Error: BAD REQUEST for url: http://localhost:62933/api/metadata?&filename=D%3A%5Ccode%5Cpy%5Cimages%5CImage10.tif

What I Did

m = leafmap.Map(center=[30.33049401, 104.10887847], zoom=18, height="800px")
m.add_basemap("SATELLITE")
m

image = "D:\\code\\py\\images\\Image10.tif"
tms_to_geotiff(output=image, bbox=bbox, zoom=19, source="Satellite", overwrite=True)

m.layers[-1].visible = False
m.add_raster(image, layer_name="Image")
m

The add_raster function depends on localtileserver. Try it directly without leafmap. If it does not work, report the issue to https://github.com/banesullivan/localtileserver/issues

from localtileserver import get_leaflet_tile_layer, TileClient
from ipyleaflet import Map

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

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

m = Map(center=client.center(), zoom=client.default_zoom)
m.add_layer(t)
m
mrpan commented

Thank you for your answer,I tested this code, maybe localtilsever doesn't support,i report the issue to localtileserver。