-
-
Notifications
You must be signed in to change notification settings - Fork 31
Open
Labels
bugSomething isn't workingSomething isn't working
Description
It looks like some colormaps can easily become too large when serialized to pass through as a URL parameter. Take the following example originally reported in opengeos/leafmap#966
Create the sample data
import numpy as np
import rasterio
l = list(range(0,80,1))
l.extend([65535]*10) # 65535 means missing data
l.extend([65533]*10) # 65533 is another special value
nparr = np.array(l, dtype=np.float32)
nparr[nparr<65000] /= 10
nparr = nparr.reshape([10,10])
GT33 = (1000.0,0.0,300000.0,0.0,-1000.0,7000000.0)
profile = {
'driver': 'GTiff',
'height': nparr.shape[0],
'width': nparr.shape[1],
'count': 1, # Number of bands
'dtype': nparr.dtype,
'crs': 'EPSG:32633',
'transform': GT33,
}
with rasterio.open('output.tif', 'w', **profile) as dst:
dst.write(nparr, 1) # Write data to the first bandAttempt plotting
Create the colormap
import matplotlib.colors as mcolors
import matplotlib.pyplot as plt
colors = ['green', 'yellow', 'orange', 'red']
cmap = mcolors.LinearSegmentedColormap.from_list('custom_cmap', colors)
cmap.set_under('grey')
cmap.set_over('grey')Attempt to use with localtileserver (not that the above/below colors are unused:
import localtileserver as lts
client = lts.TileClient('output.tif')
client.tile(10, 543, 279, nodata=65535, colormap=cmap, vmin=0, vmax=10)and if I try to use on a map:
m = client.get_leaflet_map()
m.zoom = 11
m.add(lts.get_leaflet_tile_layer(client, nodata=65535, colormap=cmap, vmin=0, vmax=10))
mthen I see browser network errors: 414 Request-URI Too Large
Summary
- above/below colors on a matplotlib
LinearSegmentedColormapare not used - serializing the
LinearSegmentedColormapis too large for the URL parameters and silently fails
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working

