0
votes

I have unstructured data , i'm using trimesh and try to plot it in geoview python atmost its done only the colorbar and colormap is not working. please help me in doing this .

Data views

x[:10]

array([84.0023  , 84.08752 , 83.91598 , 83.93291 , 84.01886 , 84.103714,
   84.18686 , 84.271126, 84.35396 , 84.36929 ], dtype=float32)

y[:10]

array([3.2143488, 3.2616525, 3.161731 , 3.245199 , 3.2980833, 3.3457222,
   3.3847086, 3.4297318, 3.4661648, 3.5507472], dtype=float32)

z1[:10]

array([2.0012133, 1.9862963, 1.9983754, 2.0019515, 2.0047712, 2.0055804,
   1.9985499, 1.9724607, 1.0084723, 1.7957278], dtype=float32)

 pts = np.stack((x,y,z)).T

 verts = pd.DataFrame(np.stack((x,y,z)).T, columns=['x', 'y' , 'z'])

 verts[:10]

x    y    z1

0 84.002296 3.214349 2.001213

1 84.087517 3.261652 1.986296

2 83.915977 3.161731 1.998375

3 83.932907 3.245199 2.001951

4 84.018860 3.298083 2.004771

5 84.103714 3.345722 2.005580

6 84.186859 3.384709 1.998550

7 84.271126 3.429732 1.972461

8 84.353958 3.466165 1.008472

9 84.369293 3.550747 1.795728

tri_sub[:10]

    B    C    D

0 280486 280494 280485

1 280484 280485 280494

2 280484 280494 280493

3 280483 280484 280493

4 280492 280483 280493

5 280482 280483 280492

6 280491 280482 280492

7 280481 280482 280491

8 280490 280481 280491

9 280480 280481 280490

The plot z axis is showing in RGBA color and hover show the RGBA Color value .

pts = np.stack((x,y,z)).T
# The main code of plotting  is given below .
verts = pd.DataFrame(np.stack((x,y,z)).T, columns=['x', 'y' , 'z'])
#cvs = ds.Canvas(plot_height=600,plot_width=600)

%opts WMTS[width=950 height=950]
tiles=gv.WMTS('https://maps.wikimedia.org/osm-intl/{Z}/{X}/{Y}@2x.png')

tri_sub = tri_new.apply(lambda x: x - 1)

gg=tiles*datashade(gv.TriMesh((tri_sub,gv.Points(verts, vdims='z'))), 
aggregator=ds.mean('z')).opts( cmap='jet', edge_color='z', filled=True,
height=400,
tools=['hover'], width=400)

gv.save(gg,datetostr+"out432.html")

print("End2")
break

My expectation colormap , colorbar and hover should show the z value .

1

1 Answers

1
votes

The datashade operation transforms your trimesh into a RGBA image which cannot be colormapped. If you need a colorbar you should use the rasterize operation which can be imported from the same module as datashade. This will return an Image which is colormapped client side and can therefore be given a colorbar.