예제 #1
0
 public static void CalLAIParts(int istart, int iend, int outwidth, UInt16[] reddata, UInt16[] IRdata, UInt16[] swirdata, IRasterDataProvider landcoverRaster, Int16[] sza, Int16[] saa, Int16[] vza, Int16[] vaa, float [] latM, float [] lonM)
 {
     for (int i = istart; i < iend; i++)
     {
         try
         {
             if (reddata[i] == bandfillValue || IRdata[i] == bandfillValue || swirdata[i] == bandfillValue)
             {
                 output[0][i] = laiFillVlue;
                 //output[1][i] = laiFillVlue;
                 continue;
             }
             float[] b346 = new float[] { reddata[i] * bandslope[0] + bandInt[0], IRdata[i] * bandslope[1] + bandInt[1], swirdata[i] * bandslope[2] + bandInt[2] };
             int     y    = i / outwidth;
             int     x    = i % outwidth;
             if (sza[i] == angleFillValue || saa[i] == angleFillValue || vza[i] == angleFillValue || vaa[i] == angleFillValue)
             {
                 output[0][i] = laiFillVlue;
                 //output[1][i] = laiFillVlue;
                 continue;
             }
             float[] angles = new float[] { sza[i] * angleslope, saa[i] * angleslope, vza[i] * angleslope, vaa[i] * angleslope };
             if (latM[i] == latlonFillValue || lonM[i] == latlonFillValue)
             {
                 output[0][i] = laiFillVlue;
                 //output[1][i] = laiFillVlue;
                 continue;
             }
             float  lctReslX = landcoverRaster.ResolutionX;
             float  lctReslY = landcoverRaster.ResolutionY;
             double lctMinLon = landcoverRaster.CoordEnvelope.MinX;
             double lctMaxLat = landcoverRaster.CoordEnvelope.MaxY;
             float  lat = latM[i], lon = lonM[i];
             //根据像元的经纬度去LandCoverType文件中找相应的偏移量xoffset和yoffset,offset =xoffset+yoffset*landcoverRaster.Width;
             int xoffset = (int)Math.Floor((lon - lctMinLon) / lctReslX);
             int yoffset = (int)Math.Floor((lctMaxLat - lat) / lctReslY);
             if (xoffset < 0 || yoffset < 0)
             {
                 output[0][i] = laiFillVlue;
                 //output[1][i] = laiFillVlue;
                 continue;
             }
             byte[] lct = GetDataValue <byte>(landcoverRaster.GetRasterBand(1), xoffset, yoffset, 1, 1);
             //int offset = xoffset + yoffset * lctWidth;
             UInt16[] lelai = LAICalc.CalLAI(b346, angles, lct[0]);
             output[0][i] = lelai[0];
             //output[1][i] = lelai[1];
         }
         catch (System.Exception ex)
         {
             PrintInfo(ex.Message);
             output[0][i] = laiFillVlue;
             continue;
         }
     }
 }
예제 #2
0
        public static void CalPrjLAIParts(int istart, int iend, int outwidth, byte [] cldmask, UInt16[] reddata, UInt16[] IRdata, UInt16[] swirdata, IRasterDataProvider landcoverRaster, Int16[] sza, Int16[] saa, Int16[] vza, Int16[] vaa, float prjresl, double minlon, double maxlat)
        {
            float pixelX, pixelY;

            for (int i = istart; i < iend; i++)
            {
                try
                {
                    if (cldmask[i] == 0 || (cldmask[i] != 255 && cldmask[i] != 253 && cldmask[i] != 191 && cldmask[i] != 127 && cldmask[i] != 125))
                    {
                        output[0][i] = laiFillVlue;
                        continue;
                    }
                    if (reddata[i] == _prjbandfillvalue || IRdata[i] == _prjbandfillvalue || swirdata[i] == _prjbandfillvalue)
                    {
                        output[0][i] = laiFillVlue;
                        //output[1][i] = laiFillVlue;
                        continue;
                    }
                    float[] b346 = new float[] { reddata[i] / _prjbandZoom, IRdata[i] / _prjbandZoom, swirdata[i] / _prjbandZoom };
                    //r,ir,swir的波段数据为辐射亮度而非反射率,应进行转换
                    //refl =pi*radiance*d^2/Es,ES为Solar Irradiance on RSB Detectors,每个波长的反射单元的太阳辐射量度;
                    //d为数据获取时间段内的平均日地距离/AU;
                    int y = i / outwidth;
                    int x = i % outwidth;
                    pixelX = (float)(minlon + x * prjresl);
                    pixelY = (float)(maxlat - y * prjresl);
                    if (sza[i] == _prjbandfillvalue || saa[i] == _prjbandfillvalue || vza[i] == _prjbandfillvalue || vaa[i] == _prjbandfillvalue)
                    {
                        output[0][i] = laiFillVlue;
                        //output[1][i] = laiFillVlue;
                        continue;
                    }
                    float[] angles    = new float[] { sza[i] * angleslope, saa[i] * angleslope, vza[i] * angleslope, vaa[i] * angleslope };
                    float   lctReslX  = landcoverRaster.ResolutionX;
                    float   lctReslY  = landcoverRaster.ResolutionY;
                    double  lctMinLon = landcoverRaster.CoordEnvelope.MinX;
                    double  lctMaxLat = landcoverRaster.CoordEnvelope.MaxY;
                    //根据像元的经纬度去LandCoverType文件中找相应的偏移量xoffset和yoffset,offset =xoffset+yoffset*landcoverRaster.Width;
                    int xoffset = (int)Math.Floor((pixelX - lctMinLon) / lctReslX);
                    int yoffset = (int)Math.Floor((lctMaxLat - pixelY) / lctReslY);
                    if (xoffset < 0 || yoffset < 0)
                    {
                        output[0][i] = laiFillVlue;
                        //output[1][i] = laiFillVlue;
                        continue;
                    }
                    byte[] lct = GetDataValue <byte>(landcoverRaster.GetRasterBand(1), xoffset, yoffset, 1, 1);
                    //int offset = xoffset + yoffset * lctWidth;
                    UInt16[] lelai = LAICalc.CalLAI(b346, angles, lct[0]);
                    output[0][i] = lelai[0];
                    //output[1][i] = lelai[1];
                }
                catch (System.Exception ex)
                {
                    PrintInfo(ex.Message);
                    output[0][i] = laiFillVlue;
                    continue;
                }
            }
        }