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
Overlay a network over voronoi testellation #478
Comments
Hi Deepa, the example on the web deosn't work me, anyway, try #!/usr/bin/env python3
#
import geopandas as gpd, numpy as np
from scipy.spatial import Voronoi
from vedo import Points, Grid, delaunay2D, Mesh, show
shape = gpd.read_file('shps/rios.shp')
def vertexAsList(shape):
vertexList = []
for line in shape.iterrows():
partialList = []
if line[1].geometry.geom_type == 'Polygon':
pointList = line[1].geometry.exterior.coords.xy
elif line[1].geometry.geom_type == 'LineString':
pointObject = line[1].geometry.coords.xy
pointList = list(zip(pointObject[0],pointObject[1]))
for index, point in enumerate(pointList):
partialList.append(point)
vertexList += partialList
return np.array(vertexList)-[610000,8300000]
pts = Points(vertexAsList(shape))#.densify(.01)
grid = Grid([14500, 61700, 0], sx=24000, sy=26000, resx=30, resy=30).ps(1)
allpts = pts.points().tolist() + grid.points().tolist()
allpts = np.array(allpts)
deln = delaunay2D(allpts).lw(0.1)
#deln.smooth()
#vor = voronoi(allpts[:,(0,1)]) ## VTK IS TOO SLOW ON THIS!
vor = Voronoi(deln.points()[:,(0,1)])
regs = [] # filter out invalid indices
for r in vor.regions:
flag=True
for x in r:
if x<0: flag=False
if flag and len(r):
regs.append(r)
msh = Mesh([vor.vertices, regs])
msh.lw(0.1).cmap('Set3', list(range(len(regs))), on='cells')
show([deln, [msh,Points(deln)]], N=2, axes=dict(digits=3)) |
@marcomusy,
Could you please clarify? |
Thank you. What is still not clear to me is the following: Also could you please clarify if |
from vedo import Grid
Grid().show(axes=8) |
Ahh, thanks a ton! this clarifies my doubts. |
Hi @marcomusy , I have an example in which a network is overlayed on voronoi cells
I would like to find the ids/index of voronoi cells through which the edge (1,2) and (1,3) passes.
I would like to know if this looks ok or if is there a better way to do this. Many thanks |
This is less easy :) Ideas you can explore:
Good luck! |
..oh, an idea could be that you make a |
Hi, Thanks so much. Instead of .closestPoint(returnPointId=True) I tried
|
Hi @marcomusy,
I would like to create a geometry like the following in vedo.
source
For this, I would like to use vedo
I am not sure how to do step 3. Could you please give some ideas and help me with this?
Thanks a lot for all your support
The text was updated successfully, but these errors were encountered: