Exemplo n.º 1
0
def test_rasterize_wkt_attrs():
    geom = box(135004, 455995, 135004.5, 455996)
    view = raster.RasterizeWKT(geom.wkt, "EPSG:28992")
    assert view.projection == "EPSG:28992"
    assert_almost_equal(view.geometry.GetEnvelope(), [135004, 135004.5, 455995, 455996])
    assert view.geometry.GetSpatialReference().IsSame(get_sr("EPSG:28992"))
    assert view.dtype == bool
    assert view.fillvalue is None
    assert_almost_equal(
        view.extent, shapely_transform(geom, "EPSG:28992", "EPSG:4326").bounds
    )
    assert view.timedelta is None
    assert view.period == (datetime(1970, 1, 1), datetime(1970, 1, 1))
def test_rasterize_wkt_vals(vals_request, projection):
    # vals_request has width=4, height=6 and cell size of 0.5
    # we place a rectangle of 2 x 3 with corner at x=1, y=2
    view = raster.RasterizeWKT(
        shapely_transform(box(135000.5, 455998, 135001.5, 455999.5),
                          "EPSG:28992", projection).wkt,
        projection,
    )
    vals_request["start"] = vals_request["stop"] = None
    actual = view.get_data(**vals_request)
    assert actual["values"][0].astype(int).tolist() == [
        [0, 0, 0, 0],
        [0, 1, 1, 0],
        [0, 1, 1, 0],
        [0, 1, 1, 0],
        [0, 0, 0, 0],
        [0, 0, 0, 0],
    ]
Exemplo n.º 3
0
def test_rasterize_wkt_point(point_request, bbox, expected):
    view = raster.RasterizeWKT(box(*bbox).wkt, "EPSG:28992")
    point_request["start"] = point_request["stop"] = None
    actual = view.get_data(**point_request)
    assert actual["values"].tolist() == [[[expected]]]
Exemplo n.º 4
0
def test_rasterize_wkt_vals_no_intersection(vals_request):
    view = raster.RasterizeWKT(box(135004, 455995, 135004.5, 455996).wkt, "EPSG:28992")
    vals_request["start"] = vals_request["stop"] = None
    actual = view.get_data(**vals_request)
    assert ~actual["values"].any()