def test_polygon_cx_selection(gp_polygon, rect): x0, y0, x1, y1 = rect for xslice in get_slices(x0, x1): for yslice in get_slices(y0, y1): expected = PolygonArray.from_geopandas(gp_polygon.cx[xslice, yslice]) result = PolygonArray.from_geopandas(gp_polygon).cx[xslice, yslice] assert all(expected == result)
def test_polygon_intersects_rect(gp_polygon, rect): sg_rect = sg.box(*rect) expected = gp_polygon.intersects(sg_rect) polygons = PolygonArray.from_geopandas(gp_polygon) # Test PolygonArray.intersects_rect result = polygons.intersects_bounds(rect) np.testing.assert_equal(result, expected) # Test PolygonArray.intersects_rect with inds inds = np.flipud(np.arange(0, len(polygons))) result = polygons.intersects_bounds(rect, inds) np.testing.assert_equal(result, np.flipud(expected)) # Test Polygon.intersects_rect result = np.array( [polygon.intersects_bounds(rect) for polygon in polygons]) np.testing.assert_equal(result, expected)
def test_polygon_area(gp_polygon): polygons = PolygonArray.from_geopandas(gp_polygon) expected_area = gp_polygon.area area = polygons.area np.testing.assert_allclose(area, expected_area)