static float[] TestReadTileAcrossTime(int column, int row, int xSize = 512, int ySize = 512)
        {
            int xOff = column * xSize;
            int yOff = row * ySize;

            string fileWildCard = "F:\\MOD11A2_Gapfilled_Output\\LST_Day\\Output_Final_30k_2030pc\\*Data.tif";
            IFilenameDateParser modisFileParse = new FilenameDateParser_MODIS8DayRaw();
            var    details       = GetFilenamesAndDates(fileWildCard, modisFileParse);
            string firstFileName = details[0].Item1;

            double[] overallGT = GDAL_Operations.GetGeoTransform(firstFileName);
            var      shape     = GDAL_Operations.GetRasterShape(firstFileName);

            if (yOff > shape.Item1 || xOff > shape.Item2)
            {
                throw new ArgumentException("you specified a column or row greater than the number of tiles available");
            }
            if (yOff + ySize > shape.Item1)
            {
                ySize = shape.Item1 - yOff;
            }
            if (xOff + xSize > shape.Item2)
            {
                xSize = shape.Item2 - xOff;
            }
            int nPix = xSize * ySize;

            float[] tileData = new float[nPix * details.Count];

            for (int t = 0; t < details.Count; t++)
            {
                int      pxStart  = nPix * t;
                string   filename = details[t].Item1;
                DateTime filedate = details[t].Item2;
                var      newshape = GDAL_Operations.GetRasterShape(filename);
                if (newshape.Item1 != shape.Item1 || newshape.Item2 != shape.Item2)
                {
                    throw new ArgumentException("Raster shapes don't match");
                }
                var bandarr = GDAL_Operations.ReadGDALRasterBandsToFlatArray(filename, xSize, ySize, xOff, yOff, 1);
                Array.Copy(bandarr, 0, tileData, pxStart, bandarr.Length);
                // tileData[pxStart : pxStart+nPix] = arr;
            }
            return(tileData);
        }
Beispiel #2
0
        public DateTime?TryParseFilenameDate(string Filename)
        {
            DateTime?parsedDate = null;

            try
            {
                IFilenameDateParser mgParser = new FilenameDateParser_MODIS8DayRaw();
                parsedDate = mgParser.TryParseFilenameDate(Filename);
            }
            catch (ArgumentException e)
            {
            }
            if (parsedDate != null)
            {
                return(parsedDate);
            }
            IFilenameDateParser rawParser = new FilenameDateParser_Mastergrid();

            return(rawParser.TryParseFilenameDate(Filename));
        }