Skip to content

Can add_raster work with a matplotlib.colors.LinearSegmentedColormap? #966

Answered by banesullivan
nve-sak asked this question in Q&A
Discussion options

You must be logged in to vote

You're close! What I recommend is starting simple with a plot in something like matplotlib. This will help you properly create the colormap without navigating other bugs or oddities of the more complicated geospatial stack like localtilserver.

This is what I have:

import os, numpy as np
import matplotlib.colors as mcolors
import matplotlib.pyplot as plt

# Create the raster to plot:
l = list(range(0,80,1)) # Values to be classified into green, yellow, orange, red danger level
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,3…

Replies: 4 comments 8 replies

Comment options

You must be logged in to vote
2 replies
@nve-sak
Comment options

@nve-sak
Comment options

Comment options

You must be logged in to vote
1 reply
@nve-sak
Comment options

Comment options

You must be logged in to vote
4 replies
@banesullivan
Comment options

@nve-sak
Comment options

@nve-sak
Comment options

@nve-sak
Comment options

Answer selected by nve-sak
Comment options

You must be logged in to vote
1 reply
@banesullivan
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants