コード例 #1
0
                        # we need to translate and scale reference seed points so that they
                        # fall within our new cell.
                        translation = [
                            (border.centroid.x -
                             cell_ref.centroid.x).values[0],
                            (border.centroid.y - cell_ref.centroid.y).values[0]
                        ]

                        S = map.S_find_centroid(map_ref,
                                                tree,
                                                frac[tree].unique(),
                                                border,
                                                random_shift=True)

                        S_shapely = MultiPoint(S)
                        if S_shapely.within(border) == False:
                            S_shapely = shapely.affinity.translate(
                                S_shapely,
                                xoff=translation[0],
                                yoff=translation[1])

                            while S_shapely.within(border) == False:
                                S_shapely = shapely.affinity.scale(S_shapely,
                                                                   xfact=0.9,
                                                                   yfact=0.9)

                            S = np.array([[s.x, s.y] for s in S_shapely])

                        # Initialize random set of weightings for Voronoi cells.
                        W = (.8 * np.random.random(sample_count) +
                             .2) * (border.area /