How to use the flopy.utils.gridintersect.GridIntersect function in flopy

To help you get started, we’ve selected a few flopy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github modflowpy / flopy / autotest / t065_test_gridintersect.py View on Github external
def test_tri_grid_linestring_on_outer_boundary():
    # avoid test fail when shapely not available
    try:
        import shapely
    except:
        return
    gr = get_tri_grid(triangle_exe=triangle_exe)
    if gr == -1:
        return
    ix = GridIntersect(gr)
    result = ix.intersect_linestring(LineString([(15., 20.), (5., 20.)]))
    assert len(result) == 2
    assert result.lengths.sum() == 10.
    assert result.cellids[0] == 2
    assert result.cellids[1] == 7
    return result
github modflowpy / flopy / autotest / t065_test_gridintersect.py View on Github external
def test_point_offset_rot_structured_grid():
    # avoid test fail when shapely not available
    try:
        import shapely
    except:
        return
    sgr = get_rect_grid(angrot=45., xyoffset=10.)
    p = Point(10., 10 + np.sqrt(200.))
    ix = GridIntersect(sgr, method="structured")
    result = ix.intersect_point(p)
    # assert len(result) == 1.
    return result
github modflowpy / flopy / autotest / t065_test_gridintersect.py View on Github external
def test_rect_grid_linestring_in_2cells_shapely():
    # avoid test fail when shapely not available
    try:
        import shapely
    except:
        return
    gr = get_rect_grid()
    ix = GridIntersect(gr)
    result = ix.intersect_linestring(LineString([(5., 5.), (15., 5.)]))
    assert len(result) == 2
    assert result.lengths.sum() == 10.
    assert result.cellids[0] == (1, 0)
    assert result.cellids[1] == (1, 1)
    return result
github modflowpy / flopy / autotest / t065_test_gridintersect.py View on Github external
def test_polygon_offset_rot_structured_grid_shapely():
    # avoid test fail when shapely not available
    try:
        import shapely
    except:
        return
    sgr = get_rect_grid(angrot=45., xyoffset=10.)
    p = Polygon([(5, 10. + np.sqrt(200.)), (15, 10. + np.sqrt(200.)),
                 (15, 10. + 1.5*np.sqrt(200.)), (5, 10. + 1.5*np.sqrt(200.))])
    ix = GridIntersect(sgr, method="strtree")
    result = ix.intersect_polygon(p)
    # assert len(result) == 3.
    return result
github modflowpy / flopy / autotest / t065_test_gridintersect.py View on Github external
def test_rect_grid_polygon_with_hole():
    # avoid test fail when shapely not available
    try:
        import shapely
    except:
        return
    gr = get_rect_grid()
    ix = GridIntersect(gr, method="structured")
    p = Polygon([(5., 5.), (5., 15.), (25., 15.), (25., -5.),
                 (5., -5.)], holes=[[(9., -1), (9, 11), (21, 11), (21, -1)]])
    result = ix.intersect_polygon(p)
    assert len(result) == 3
    assert result.areas.sum() == 104.
    return result
github modflowpy / flopy / autotest / t065_test_gridintersect.py View on Github external
def test_rect_grid_polygon_with_hole_shapely():
    # avoid test fail when shapely not available
    try:
        import shapely
    except:
        return
    gr = get_rect_grid()
    ix = GridIntersect(gr)
    p = Polygon([(5., 5.), (5., 15.), (25., 15.), (25., -5.),
                 (5., -5.)], holes=[[(9., -1), (9, 11), (21, 11), (21, -1)]])
    result = ix.intersect_polygon(p)
    assert len(result) == 3
    assert result.areas.sum() == 104.
    return result
github modflowpy / flopy / autotest / t065_test_gridintersect.py View on Github external
def test_rect_grid_multipolygon_in_one_cell():
    # avoid test fail when shapely not available
    try:
        import shapely
    except:
        return
    gr = get_rect_grid()
    ix = GridIntersect(gr, method="structured")
    p1 = Polygon([(1., 1.), (8., 1.), (8., 3.), (1., 3.)])
    p2 = Polygon([(1., 9.), (8., 9.), (8., 7.), (1., 7.)])
    p = MultiPolygon([p1, p2])
    result = ix.intersect_polygon(p)
    assert len(result) == 1
    assert result.areas.sum() == 28.
    return result
github modflowpy / flopy / autotest / t065_test_gridintersect.py View on Github external
def test_tri_grid_multipolygon_in_one_cell():
    # avoid test fail when shapely not available
    try:
        import shapely
    except:
        return
    gr = get_tri_grid(triangle_exe=triangle_exe)
    if gr == -1:
        return
    ix = GridIntersect(gr)
    p1 = Polygon([(1., 1.), (8., 1.), (8., 3.), (3., 3.)])
    p2 = Polygon([(5., 5.), (8., 5.), (8., 8.)])
    p = MultiPolygon([p1, p2])
    result = ix.intersect_polygon(p)
    assert len(result) == 1
    assert result.areas.sum() == 16.5
    return result
github modflowpy / flopy / autotest / t065_test_gridintersect.py View on Github external
def test_tri_grid_polygon_on_inner_boundary():
    gr = get_tri_grid(triangle_exe=triangle_exe)
    if gr == -1:
        return
    ix = GridIntersect(gr)
    result = ix.intersect_polygon(
        Polygon([(5., 10.0), (15., 10.0), (15., 5.), (5., 5.)]))
    assert len(result) == 4
    assert result.areas.sum() == 50.
    return result
github modflowpy / flopy / autotest / t065_test_gridintersect.py View on Github external
def test_rect_grid_linestring_in_and_out_of_cell_shapely():
    # avoid test fail when shapely not available
    try:
        import shapely
    except:
        return
    gr = get_rect_grid()
    ix = GridIntersect(gr)
    result = ix.intersect_linestring(
        LineString([(5., 9), (15., 5.), (5., 1.)]))
    assert len(result) == 2
    assert result.cellids[0] == (1, 0)
    assert result.cellids[1] == (1, 1)
    assert np.allclose(result.lengths.sum(), 21.540659228538015)
    return result