32 const char *envifilename,
35 const char *misrfilename,
36 const char *misrgridname,
37 const char *misrfieldname )
42 int idl_datatype[
MTKd_NDATATYPE] = { 0, 1, 1, 1, 1, 2, 12, 3, 13, 14, 15, 4, 5 };
57 double IncAng, AscLong;
61 char *endian_ptr = (
char *)&endian;
63 if (envifilename == NULL)
68 strcpy(imgfname, envifilename);
69 strcat(imgfname,
".img");
70 if ((fp = fopen(imgfname,
"wb")) == NULL) {
79 strcpy(hdrfname, envifilename);
80 strcat(hdrfname,
".hdr");
81 if ((fp = fopen(hdrfname,
"wb")) == NULL) {
85 fprintf(fp,
"ENVI\n");
86 fprintf(fp,
"description = {%s}\n", misrfilename);
87 fprintf(fp,
"samples = %d\n", buf.
nsample);
88 fprintf(fp,
"lines = %d\n", buf.
nline);
89 fprintf(fp,
"bands = 1\n");
90 fprintf(fp,
"header offset = 0\n");
91 fprintf(fp,
"file type = ENVI Standard\n");
92 fprintf(fp,
"data type = %d\n", idl_datatype[buf.
datatype]);
93 fprintf(fp,
"interleave = bsq\n");
94 fprintf(fp,
"sensor type = MISR\n");
95 if (endian_ptr[0] == 1)
96 fprintf(fp,
"byte order = 0\n");
98 fprintf(fp,
"byte order = 1\n");
100 fprintf(fp,
"x start = 0.0\n");
101 fprintf(fp,
"y start = 0.0\n");
103 fprintf(fp,
"map info = {");
104 fprintf(fp,
"Space Oblique Mercator A (MISR Path %d), ", mapinfo.
path);
105 fprintf(fp,
"1.0, ");
106 fprintf(fp,
"1.0, ");
107 fprintf(fp,
"%f, ", mapinfo.
som.
ulc.
x);
108 fprintf(fp,
"%f, ", mapinfo.
som.
ulc.
y);
109 fprintf(fp,
"%f, ", (
float)mapinfo.
resolution);
110 fprintf(fp,
"%f, ", (
float)mapinfo.
resolution);
111 fprintf(fp,
"WGS-84, ");
112 fprintf(fp,
"units=Meters, ");
113 fprintf(fp,
"rotation=90.0");
120 b = sqrt(pow(a,2) - e2 * pow(a,2));
131 fprintf(fp,
"projection info = {");
133 fprintf(fp,
"%f, ", a);
134 fprintf(fp,
"%f, ", b);
135 fprintf(fp,
"%f, ", IncAng);
136 fprintf(fp,
"%f, ", AscLong);
137 fprintf(fp,
"%f, ", x0);
138 fprintf(fp,
"%f, ", y0);
139 fprintf(fp,
"%f, ", PSRev);
140 fprintf(fp,
"%f, ", LRat);
141 fprintf(fp,
"WGS-84, ");
142 fprintf(fp,
"Space Oblique Mercator A (MISR Path %d), ", mapinfo.
path);
143 fprintf(fp,
"units=Meters");
146 fprintf(fp,
"pixel size = {");
147 fprintf(fp,
"%f, ", (
float)mapinfo.
resolution);
148 fprintf(fp,
"%f, ", (
float)mapinfo.
resolution);
149 fprintf(fp,
"units=Meters");
152 fprintf(fp,
"band names = {");
153 fprintf(fp,
"%s:%s", misrgridname, misrfieldname);
2-dimensional Data Buffer
MTKt_status MtkDmsToDd(double dms, double *dd)
Convert packed degrees, minutes, seconds to decimal degrees.
MTKt_status MtkWriteEnviFile(const char *envifilename, MTKt_DataBuffer buf, MTKt_MapInfo mapinfo, const char *misrfilename, const char *misrgridname, const char *misrfieldname)
Write ENVI file.
#define MTK_ERR_MSG_JUMP(msg)