Beispiel #1
0
width = sourceProduct.getSceneRasterWidth()
height = sourceProduct.getSceneRasterHeight()
targetProduct = Product('FLH_Product', 'FLH_Type', width, height)
targetBand = targetProduct.addBand('FLH', ProductData.TYPE_FLOAT32)
ProductUtils.copyGeoCoding(sourceProduct, targetProduct)
targetProduct.setProductWriter(ProductIO.getProductWriter('GeoTIFF'))

targetProduct.writeHeader(String('beampy_flh_output.tif'))

r1 = numpy.zeros(width, dtype=numpy.float32)
r2 = numpy.zeros(width, dtype=numpy.float32)
r3 = numpy.zeros(width, dtype=numpy.float32)

print("Writing...")

for y in range(height):
    b1.readPixels(0, y, width, 1, r1)
    b2.readPixels(0, y, width, 1, r2)
    b2.readPixels(0, y, width, 1, r3)
    print("processing line ", y, " of ", height)
    FLH = r2 - k * (r1 + a * (r3 - r1))
    targetBand.writePixels(0, y, width, 1, FLH)

    print("processing line ", y, " of ", height)
    FLH = r2 - k * (r1 + a * (r3 - r1))
    targetBand.writePixels(0, y, width, 1, FLH)

targetProduct.closeIO()

print("Done.")
Beispiel #2
0
ndviFlagCoding.addFlag("NDVI_HIGH", 2, "NDVI above 1")
group = ndviProduct.getFlagCodingGroup()
# print(dir(group))
group.add(ndviFlagCoding)

ndviFlagsBand.setSampleCoding(ndviFlagCoding)

ndviProduct.setProductWriter(writer)
ndviProduct.writeHeader("beampy_ndvi_output.dim")

r7 = numpy.zeros(width, dtype=numpy.float32)
r10 = numpy.zeros(width, dtype=numpy.float32)

print("Writing...")

for y in range(height):
    print("processing line ", y, " of ", height)
    r7 = b7.readPixels(0, y, width, 1, r7)
    r10 = b10.readPixels(0, y, width, 1, r10)

    ndvi = (r10 - r7) / (r10 + r7)
    ndviBand.writePixels(0, y, width, 1, ndvi)
    ndviLow = ndvi < 0.0
    ndviHigh = ndvi > 1.0
    ndviFlags = ndviLow + 2 * ndviHigh
    ndviFlagsBand.writePixels(0, y, width, 1, ndviFlags)

ndviProduct.closeIO()

print("Done.")
Beispiel #3
0
ndviFlagCoding.addFlag("NDVI_LOW", 1, "NDVI below 0")
ndviFlagCoding.addFlag("NDVI_HIGH", 2, "NDVI above 1")
group = ndviProduct.getFlagCodingGroup()
#print(dir(group))
group.add(ndviFlagCoding)

ndviFlagsBand.setSampleCoding(ndviFlagCoding)

ndviProduct.setProductWriter(writer)
ndviProduct.writeHeader('beampy_ndvi_output.dim')

r7 = numpy.zeros(width, dtype=numpy.float32)
r10 = numpy.zeros(width, dtype=numpy.float32)

print("Writing...")

for y in range(height):
    print("processing line ", y, " of ", height)
    r7 = b7.readPixels(0, y, width, 1, r7)
    r10 = b10.readPixels(0, y, width, 1, r10)

    ndvi = (r10 - r7) / (r10 + r7)
    ndviBand.writePixels(0, y, width, 1, ndvi)
    ndviLow = ndvi < 0.0
    ndviHigh = ndvi > 1.0
    ndviFlags = ndviLow + 2 * ndviHigh
    ndviFlagsBand.writePixels(0, y, width, 1, ndviFlags)

ndviProduct.closeIO()

print("Done.")