예제 #1
0
def gee_mapserver(request, platform, sensor, product, method, z, x, y,
                  from_date, until_date):
    print(
        f"Received map tile request: {platform} {sensor} {product}, x: {x}, y: {y}, zoom: {z}",
        {from_date} - {until_date})

    ee_product = get_ee_product(platform=platform,
                                sensor=sensor,
                                product=product)

    query = TileDateRangeQuery(x=x,
                               y=y,
                               z=z,
                               date_from=from_date,
                               date_to=until_date,
                               reducer="median")

    out = gee_loader.load(ee_product, query, subdir="map")
    if out is None:
        image = get_empty_image()
    else:
        handler = get_vis_handler(ee_product, method)
        image = handler(out, ee_product)

    response = HttpResponse(content_type='image/png')
    image.save(response, "PNG")
    return response
예제 #2
0
파일: config.py 프로젝트: oxai/wildfire
def get_ee_session() -> dict:
    """
    Gets ee_product from Google Earth Engine
    :return: ee_product (a dict)
    """
    ee.Initialize(EE_CREDENTIALS)

    ee_product = get_ee_product(platform="sentinel", sensor="2", product="l1c")
    return ee_product
예제 #3
0
def get_arguments():
    parser = get_parser(globfire=True)
    args = parser.parse_args()

    ee_product = get_ee_product(
        platform=args.platform,
        sensor=args.sensor,
        product=args.product
    )

    zoom = args.zoom if args.zoom else 13

    subdir = args.subdir
    if not subdir:
        dir_name_base = f"{args.platform}-{args.sensor}_{args.product}_globfire_" \
                        f"{args.from_date}_{args.until_date}_{zoom}_{args.min_period}-{args.max_period}"
        subdir = dir_name_base + ("_no_fire" if args.neg else "_w_fire")

    return args, ee_product, subdir, zoom
예제 #4
0
def get_arguments():
    parser = get_parser()
    args = parser.parse_args()

    ee_product = get_ee_product(platform=args.platform,
                                sensor=args.sensor,
                                product=args.product)

    subdir = args.subdir
    if not subdir:
        dir_name_base = f"{args.platform}-{args.sensor}_{args.product}_{args.fire_record}_" \
                        f"{args.from_date}_{args.until_date}_{args.zoom}_{args.img_size}x{args.img_size}"
        subdir = dir_name_base + ("_no_fire" if args.neg else "_w_fire")

    fire_record = args.fire_record
    if fire_record == "fpa_fod":
        fire_loader = FpaFodDataLoader()
    elif fire_record == "modis":
        fire_loader = ModisFireDataLoader()
    else:
        assert fire_record == "manual", "fire_record does not match any options"
        fire_loader = ManualFireDataLoader()

    return args, ee_product, subdir, fire_loader
예제 #5
0
파일: show_fires.py 프로젝트: oxai/wildfire
from tifffile import imread
import os
import ee

from resources.gee.config import EE_CREDENTIALS
from resources.gee.methods import get_ee_product
from resources.gee.vis_handler import vs_fire, vs_firethresh, vs_nbr, vis_default
import matplotlib.pyplot as plt

data_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)), "data_dir")

ee.Initialize(EE_CREDENTIALS)

ee_product = get_ee_product(platform="sentinel", sensor="2", product="l1c")

for root, dirs, files in os.walk(os.path.join(
        data_dir,
        "sentinel-2_l1c_fpa_fod_2015-08-01_2015-12-31_13_256x256_w_fire"),
                                 topdown=False):

    for name in files:
        fig, axs = plt.subplots(1, 3)

        image = imread(os.path.join(root, name))
        out = vs_fire(ee_product, image, {})
        axs[0].imshow(out)

        out = vis_default(ee_product, image, ee_product['vis_params'])
        axs[1].imshow(out)

        out = vs_firethresh(ee_product, image, {})
예제 #6
0
파일: show_fires.py 프로젝트: oxai/wildfire
parser = argparse.ArgumentParser()
parser.add_argument(
    'platform',
    help="satellite category ('landsat', 'sentinel', 'modis', etc.)")
parser.add_argument(
    'sensor',
    help="sensor type (landsat '8', sentinel '2', modis 'terra', etc.)")
parser.add_argument(
    'product',
    help="product name ('surface', 'ndvi', 'snow', 'temperature', etc.)")
parser.add_argument("dir", help="tiff file directory")

args = parser.parse_args()

ee_product = get_ee_product(platform=args.platform,
                            sensor=args.sensor,
                            product=args.product)

for root, dirs, files in os.walk(args.dir):
    for name in files:
        fig, axs = plt.subplots(1, 3)

        ax = axs[0]
        image = imread(os.path.join(root, name))
        out = vis_fire(ee_product, image)
        ax.imshow(out)
        ax.set_title("fire vis applied")

        ax = axs[1]
        out = vis_default(ee_product, image)
        ax.imshow(out)