Git Product home page Git Product logo

Comments (6)

jgrss avatar jgrss commented on July 19, 2024

Hey, can you post the input data so I can better see what you're trying to do?

from geowombat.

mmann1123 avatar mmann1123 commented on July 19, 2024

@jgrss Here's an example:

from geowombat.data import (
    l8_224077_20200518_B2,
    l8_224078_20200518_B2,
    l8_224077_20200518_B3,
    l8_224078_20200518_B3,
)

with gw.open([l8_224077_20200518_B2, l8_224077_20200518_B3], stack_dim="band") as src1:
    with gw.open(
        [l8_224078_20200518_B2, l8_224078_20200518_B3], stack_dim="band"
    ) as src2:

        with gw.open([src1, src2], mosaic=True) as src:
            print(src)

from geowombat.

jgrss avatar jgrss commented on July 19, 2024

I think you can do the first approach if you set the overall bounds.

import dask.array as da
from geowombat.backends.rasterio_ import get_file_bounds

# Get the union of all bounding boxes
# Note that you probably want to pass `crs` in this method.
bounds = get_file_bounds([l8_224077_20200518_B2, l8_224078_20200518_B2], bounds_by="union", return_bounds=True)

with gw.config.update(ref_bounds=bounds):
    with gw.open([l8_224077_20200518_B2, l8_224077_20200518_B3], band_names=[1, 2], stack_dim="band") as src1:
        with gw.open([l8_224078_20200518_B2, l8_224078_20200518_B3], band_names=[1, 2], stack_dim="band") as src2:
            darray = da.maximum(src1, src2)
            print(darray)

from geowombat.

jgrss avatar jgrss commented on July 19, 2024

As for the VRT approach, that looks like it could work. However, there is a bug when passing the default integer EPSG -- gdal.BuildVRTOptions outputSRS does not like EPSG integers, so you could try setting the DataArray CRS attribute as a WKT string like src1.attrs["crs"] = src1.gw.crs_to_pyproj.to_wkt().

from geowombat.

jgrss avatar jgrss commented on July 19, 2024

Follow-up on the first option. In the case of more than two arrays, you might want to use numpy.

import numpy as np

with gw.config.update(ref_bounds=bounds):
    with gw.open([l8_224077_20200518_B2, l8_224077_20200518_B3], band_names=[1, 2], stack_dim="band") as src1:
        with gw.open([l8_224078_20200518_B2, l8_224078_20200518_B3], band_names=[1, 2], stack_dim="band") as src2:
            darray = np.maximum.reduce(src1, src2, src3, src4, ...)
            print(darray)

from geowombat.

mmann1123 avatar mmann1123 commented on July 19, 2024

ok thanks I will play around with it. Looks like the VRT option is still throwing the error.

from geowombat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.