I try to cluster a shape file divided as voronoi polygons, to make it as groups of aggregated adjacent polygons , according to this code
but it seems to be wrong , can you advice me please , I also try many different values as the max. distance between the polygons, but the same result .
model ProtoType
global
{
file vor <-file('../includes/VoronoiVoronoi.shp') ;
geometry shape <-envelope(vor) ;
init
{
create vorpoly from: vor with:[towerpoly ::int(read('Tower')),
location.x::int(read('pos_x')),
location.y::int(read('pos_y'))];
list<list<vorpoly>> clusters <- list<list<vorpoly>>(simple_clustering_by_distance(vorpoly, 0.2));
loop cluster over: clusters {
rgb rnd_color <- rgb(rnd(255),rnd(255),rnd(255));
ask cluster as: vorpoly { color <- rnd_color; }
}
}//init
}//global
entities
{
species vorpoly
{ rgb color ;
int towerpoly;
aspect vorpolygon { draw shape color: color ; } } }
experiment Clustering type:gui { output { display city_display refresh_every: 1 type:java2D
{ species vorpoly aspect:vorpolygon transparency:0.5; } } }
any Example !
thanks in advance
cheers
suhad