Esempio n. 1
0
 def setup(self):
     # create irregular polygons by merging overlapping point buffers
     self.left = shapely.union_all(
         shapely.buffer(shapely.points(np.random.random((500, 2)) * 500),
                        15))
     # shift this up and right
     self.right = shapely.transform(self.left, lambda x: x + 50)
Esempio n. 2
0
    def unary_union(self, geoms):
        """Returns the union of a sequence of geometries

        This method replaces :meth:`cascaded_union` as the
        preferred method for dissolving many polygons.
        """
        return shapely.union_all(geoms, axis=None)
Esempio n. 3
0
 def setup(self):
     # create irregular polygons by merging overlapping point buffers
     self.polygon = shapely.union_all(
         shapely.buffer(shapely.points(np.random.random((1000, 2)) * 500),
                        10))
     xmin = np.random.random(100) * 100
     xmax = xmin + 100
     ymin = np.random.random(100) * 100
     ymax = ymin + 100
     self.bounds = np.array([xmin, ymin, xmax, ymax]).T
     self.boxes = shapely.box(xmin, ymin, xmax, ymax)
Esempio n. 4
0
    def cascaded_union(self, geoms):
        """Returns the union of a sequence of geometries

        This function is deprecated, as it was superseded by
        :meth:`unary_union`.
        """
        warn(
            "The 'cascaded_union()' function is deprecated. "
            "Use 'unary_union()' instead.",
            ShapelyDeprecationWarning,
            stacklevel=2,
        )
        return shapely.union_all(geoms, axis=None)
Esempio n. 5
0
    def setup(self):
        # create irregular polygons my merging overlapping point buffers
        self.polygons = shapely.get_parts(
            shapely.union_all(
                shapely.buffer(
                    shapely.points(np.random.random((2000, 2)) * 500), 5)))
        self.tree = shapely.STRtree(self.polygons)
        # initialize the tree by making a tiny query first
        self.tree.query(shapely.points(0, 0))

        # create points that extend beyond the domain of the above polygons to ensure
        # some don't overlap
        self.points = shapely.points((np.random.random((2000, 2)) * 750) - 125)
        self.point_tree = shapely.STRtree(
            shapely.points(np.random.random((2000, 2)) * 750))
        self.point_tree.query(shapely.points(0, 0))

        # create points on a grid for testing equidistant nearest neighbors
        # creates 2025 points
        grid_coords = np.mgrid[:45, :45].T.reshape(-1, 2)
        self.grid_point_tree = shapely.STRtree(shapely.points(grid_coords))
        self.grid_points = shapely.points(grid_coords + 0.5)
Esempio n. 6
0
 def time_union_all_prec2(self):
     shapely.union_all([self.left, self.right], grid_size=2)
Esempio n. 7
0
 def time_union_all(self):
     shapely.union_all([self.left, self.right])
Esempio n. 8
0
def test_union_all_prec(geom, grid_size, expected):
    actual = shapely.union_all(geom, grid_size=grid_size)
    assert shapely.equals(actual, expected)