L1A -> L2

This commit is contained in:
nuknal
2024-09-25 16:41:19 +08:00
parent 5ccae01ee2
commit 648387af98
2 changed files with 10 additions and 6 deletions

View File

@@ -90,6 +90,8 @@ func (r *Registrator) makeProductMeta(scene *Scene) *ProductMeta {
MapProjection: "GEOGRAPHIC",
EarthEllipsoid: "WGS_84",
ProductLevel: "L1A",
UtmZone: -1,
GainLevel: 6,
}
switch scene.Type {

View File

@@ -50,7 +50,7 @@ func L1AtoL2(in, out, meta, rpb, demtif string) error {
sensor = "PAN"
}
corners, err := computeBound(out)
corners, width, height, err := computeBound(out)
if err != nil {
return err
}
@@ -60,6 +60,8 @@ func L1AtoL2(in, out, meta, rpb, demtif string) error {
m.ProductID = id
m.ProductLevel = "L2"
m.Corners = *corners
m.Width = width
m.Height = height
xmlfile := filepath.Join(dir, id+".meta.xml")
writeProductMeta(m, xmlfile)
@@ -68,17 +70,17 @@ func L1AtoL2(in, out, meta, rpb, demtif string) error {
return nil
}
func computeBound(tif string) (*Corners, error) {
func computeBound(tif string) (*Corners, int, int, error) {
ds, err := godal.Open(tif)
if err != nil {
log.Printf("Error opening TIFF file %s: %v", tif, err)
return nil, err
return nil, -1, -1, err
}
defer ds.Close()
geotransform, err := ds.GeoTransform()
if err != nil {
return nil, err
return nil, -1, -1, err
}
// Xp = padfTransform[0] + P*padfTransform[1] + L*padfTransform[2];
@@ -98,7 +100,7 @@ func computeBound(tif string) (*Corners, error) {
data := make([]uint16, width*height)
err = band.Read(0, 0, data, width, height)
if err != nil {
return nil, err
return nil, -1, -1, err
}
nodata, _ := band.NoData()
@@ -150,5 +152,5 @@ func computeBound(tif string) (*Corners, error) {
corners.LowerRight.Longitude = xmin + float64(index2)*geotransform[1]
corners.LowerRight.Latitude = ymin
return &corners, nil
return &corners, width, height, nil
}