Git Product home page Git Product logo

Comments (4)

devisperessutti avatar devisperessutti commented on July 22, 2024 1

The timestamps are saved in eopatch_ecc.timestamp, so I would suggest you actually pass a list of names to the export task so that you will get one tiff file for each timestamp, with the filename being the timestamps.

Something like this

filenames = [f"ts.strftime('%Y%m%dT%H%M%S').tiff" for ts in eopatch_ecc.timestamp]

export_task.execute(eopatch_ecc, filename=filenames)

from eo-learn.

devisperessutti avatar devisperessutti commented on July 22, 2024

Hi @NourSoltani

What you are after is the ExportToTiffTask, which allows you to export each timeframe to a tiff. Read the documentation to set the arguments correctly.

Let me know if it works.

from eo-learn.

NourSoltani avatar NourSoltani commented on July 22, 2024

Hi @devisperessutti
Thank you for the quick responding. I appreciate
Yes it works!! It fits well with my expectations..
But I still have a problem If you do not mind..
There's the full code:

#################################################################
#################################################################

Enhanced Cross-Correlation

params = {"MaxIters": 200}
coregister_ecc = ECCRegistrationTask(feat_bands, channel=2, params=params)
eopatch_ecc = coregister_ecc(eopatch_clean)

export_task = ExportToTiffTask((FeatureType.DATA, "BANDS"), folder="/home/Desktop/Nour/eo-learn-examples-main/coregistration/test/")
export_task.execute(eopatch_ecc,filename="temp_file_ecc.tiff")

with rasterio.open("temp_file_ecc.tiff") as src:

Get the number of bands in the image

num_bands = src.count

Iterate through the bands in groups of 3

for i in range(0, num_bands, 3):
#Read in the current group of 3 bands
band = src.read(indexes=range(i+3, i,-1))

Save the current group of 3 bands as a new image

with rasterio.open(f"image_{i//3}.tif", "w", driver="GTiff",
width=src.width, height=src.height,
count=3, dtype=band.dtype, crs=src.crs, transform=src.transform) as dst:
dst.write(band)
print(band)
#################################################################
#################################################################

As I said, I still have a problem If you do not mind.. I need to know the date of each timestamp. Is there any method on how to figure out the chosen dates? Because he has downloaded the images this way:

roi_bbox = BBox(bbox=[31.112895, 29.957240, 31.154222, 29.987687], crs=CRS.WGS84)
time_interval = ("2018-01-01", "2020-06-01")

feat_bands = (FeatureType.DATA, "BANDS")

class MaxCloudCoveragePredicate:
def init(self, max_cloud_coverage: float):
self.max_cloud_coverage = max_cloud_coverage

def call(self, cloud_mask: np.ndarray):
width, height, _ = cloud_mask.shape
cloud_coverage = np.sum(cloud_mask) / (width * height)
return cloud_coverage <= self.max_cloud_coverage
download_task = SentinelHubInputTask(
data_collection=DataCollection.SENTINEL2_L1C,
bands_feature=feat_bands,
resolution=10,
maxcc=0.5,
bands=["B02", "B03", "B04"],
time_difference=datetime.timedelta(hours=2),
additional_data=[(FeatureType.MASK, "dataMask", "IS_DATA"), (FeatureType.MASK, "CLM")],
)
filter_clouds = SimpleFilterTask((FeatureType.MASK, "CLM"), MaxCloudCoveragePredicate(max_cloud_coverage=0.05))

from eo-learn.

NourSoltani avatar NourSoltani commented on July 22, 2024

Thank you very much!
I really appreciate your help..
Of course without forgetting the {}: {ts.strftime('%Y%m%dT%H%M%S')}
:)

from eo-learn.

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.