Пример #1
0
def retrieve_pixel_value(dataset, pqa, pqa_masks, wofs, wofs_masks, latitude, longitude, ndv=NDV):

    _log.debug(
        "Retrieving pixel value(s) at lat=[%f] lon=[%f] from [%s] with pqa [%s] and paq mask [%s] and wofs [%s] and wofs mask [%s]",
        latitude, longitude, dataset.path, pqa and pqa.path or "", pqa and pqa_masks or "",
        wofs and wofs.path or "", wofs and wofs_masks or "")

    metadata = get_dataset_metadata(dataset)

    x, y = latlon_to_xy(latitude, longitude, metadata.transform)

    _log.info("Retrieving value at x=[%d] y=[%d] from %s", x, y, dataset.path)

    x_size = y_size = 1

    mask = None

    if pqa:
        mask = get_mask_pqa(pqa, pqa_masks, x=x, y=y, x_size=x_size, y_size=y_size)

    if wofs:
        mask = get_mask_wofs(wofs, wofs_masks, x=x, y=y, x_size=x_size, y_size=y_size, mask=mask)

    data = get_dataset_data_masked(dataset, x=x, y=y, x_size=x_size, y_size=y_size, mask=mask, ndv=ndv)

    _log.debug("data is [%s]", data)

    return data
Пример #2
0
def test_latlon_to_xy():
    # This equates to the 120/-20 cell
    transform = (120.0, 0.00025, 0.0, -19.0, 0.0, -0.00025)

    # TODO

    # Expected outputs:
    #
    #   (120.00000, -20.00000) -> (   0, 4000) which is actually outside the TIF!!!
    #
    #   (120.25000, -19.25000) -> (1000, 1000)
    #   (120.50000, -19.50000) -> (2000, 2000)
    #
    #   (120.00024, -19.00024) -> (   0,    0)
    #   (120.00025, -19.00025) -> (   1,    1)
    #   (120.00026, -19.00026) -> (   1,    1)

    # Should return
    latlon_to_xy(120, -20, transform)
Пример #3
0
def retrieve_pixel_value(dataset, pq, pq_masks, latitude, longitude, ndv=NDV):
    _log.debug("Retrieving pixel value(s) at lat=[%f] lon=[%f] from [%s] with pq [%s] and pq mask [%s]", latitude, longitude, dataset.path, pq and pq.path or "", pq and pq_masks or "")

    metadata = get_dataset_metadata(dataset)
    x, y = latlon_to_xy(latitude, longitude, metadata.transform)

    _log.debug("Retrieving value at x=[%d] y=[%d]", x, y)

    data = None

    if pq:
        data = get_dataset_data_with_pq(dataset, pq, x=x, y=y, x_size=1, y_size=1, pq_masks=pq_masks, ndv=ndv)
    else:
        data = get_dataset_data(dataset, x=x, y=y, x_size=1, y_size=1)

    _log.debug("data is [%s]", data)

    return data