Hello, i am doing an algortihm for this:
- Reading a .SAFE file
- Run sen2cor and get the 2A level product
- Read L2A. SAFE product
it works like this
import sys
import numpy
from snappy import Product
from snappy import ProductData
from snappy import ProductIO
from snappy import ProductUtils
from snappy import FlagCoding
import os
cmd = ‘L2A_Process --resolution 60 D:\S2A_MSIL1C_20170407T153621_N0204_R068_T18NUJ_20170407T154054.SAFE’
os.system(cmd)
file = (‘D:\S2A_MSIL1C_20170407T153621_N0204_R068_T18NUJ_20170407T154054.SAFE’)
print(“Reading…”)
product = ProductIO.readProduct(file)
width = product.getSceneRasterWidth()
height = product.getSceneRasterHeight()
name = product.getName()
description = product.getDescription()
band_names = product.getBandNames()
print(“Product: %s, %s” % (name, description))
print(“Raster size: %d x %d pixels” % (width, height))
print("Start time: " + str(product.getStartTime()))
print("End time: " + str(product.getEndTime()))
print(“Bands: %s” % (list(band_names)))
and the response is
Reading…
Product: MER_FRS_L1B_SUBSET, MERIS Full Resolution Geolocated and Calibrated TOA Radiance
Raster size: 221 x 184 pixels
Start time: 09-JUL-2007 11:14:55.493954
End time: 09-JUL-2007 11:15:03.545405
Bands: [‘radiance_1’, ‘radiance_2’, ‘radiance_3’, ‘radiance_4’, ‘radiance_5’, ‘radiance_6’, ‘radiance_7’, ‘radiance_8’, ‘radiance_9’, ‘radiance_10’, ‘radiance_11’, ‘radiance_12’, ‘radiance_13’, ‘radiance_14’, ‘radiance_15’, ‘l1_flags’, ‘detector_index’]
so this part is going well but now i have 2 problems i can’t solve
1- first one is cutting the L2A.safe file to my region of interest that is a square with this coordinates (Because the L2A is too big for processing):
‘POLYGON ((-74.911862 4.162501, -74.915142 4.162332, -74.914788 4.156032, -74.912351 4.156068))’
2 - the second one is that inside the polygon and obviously the image, i have to get the NDVI value of a specific pixel giving a coordinate
for example… i cut the image to my ROI , calculate NDVI of the image, give a coordinate and then i need the pixel value for that coordinate
thanks if anyone can guide me in this way because i have been trying for 2 weeks but i’m new in this