Esempio n. 1
0
        public void Export(string dbfile, string ascfile, int nrow, int ncol, int cellsize, float xcorner, float ycorner, float nodatavalue = -999)
        {
            DBFReader        dbf        = new DBFReader(dbfile);
            int              act_index  = dbf.GetFiledNameIndex("active");
            int              row_index  = dbf.GetFiledNameIndex("row");
            int              col_index  = dbf.GetFiledNameIndex("col");
            int              elev_index = dbf.GetFiledNameIndex("elev");
            DataCube <float> mat        = new DataCube <float>(1, nrow, ncol);
            int              nact       = 0;

            for (int n = 0; n < dbf.RecordCount; n++)
            {
                var obj = dbf.NextRecord();
                int row = int.Parse(obj[row_index].ToString());
                int col = int.Parse(obj[col_index].ToString());
                int act = int.Parse(obj[act_index].ToString());
                if (act > 0)
                {
                    mat[0, row - 1, col - 1] = float.Parse(obj[elev_index].ToString());
                    nact++;
                }
                else
                {
                    mat[0, row - 1, col - 1] = nodatavalue;
                }
            }

            dbf.Close();
            //  this.Save<float>(ascfile, Value, nrow, ncol, cellsize, xcorner, ycorner, nodatavalue);
        }