MISR Toolkit  1.5.1
MtkL1B2Reproject.c
Go to the documentation of this file.
1 /*===========================================================================
2 = =
3 = MtkL1B2Reproject =
4 = =
5 =============================================================================
6 
7  Jet Propulsion Laboratory
8  MISR
9  MISR Toolkit
10 
11  Copyright 2005, California Institute of Technology.
12  ALL RIGHTS RESERVED.
13  U.S. Government Sponsorship acknowledged.
14 
15 ============================================================================*/
16 
17 #include "MisrToolkit.h"
18 #include "MisrError.h"
19 #include <stdio.h> /* for printf */
20 #include <getopt.h> /* for getopt_long */
21 #include <strings.h> /* for strncasecmp */
22 #include <HdfEosDef.h> /* Definition of GDopen */
23 
24 #define MAX_FILENAME 5000
25 #define MAX_FIELDNAME 1000
26 #define MAX_LENGTH 1000
27 #define NUMBER_BAND 4
28 #define NUMBER_CAMERA 9
29 #define OUTPUT_GRIDNAME "L1B2Reproject"
30 
31 /* -------------------------------------------------------------------------*/
32 /* Structure to contain command-line arguments. */
33 /* -------------------------------------------------------------------------*/
34 
35 typedef struct {
36  char *proj_map_file; /* Projection/map info file */
37  char *terrain_file; /* GRP_TERRAIN file*/
38  char *output_basename; /* Output basename*/
39  int band; /* Band to process. -1 = all */
40 } argr_type; /* Argument parse result */
41 
42 #define ARGR_TYPE_INIT {NULL, NULL, NULL, -1}
43 
44 /* -------------------------------------------------------------------------*/
45 /* Local function prototypes */
46 /* -------------------------------------------------------------------------*/
47 
48 int process_args(int argc, char *argv[], argr_type *argr);
49 
50 /* -------------------------------------------------------------------------*/
51 /* Main program. */
52 /* -------------------------------------------------------------------------*/
53 
54 int main( int argc, char *argv[] ) {
55  MTKt_status status; /* Return status */
56  MTKt_status status_code = MTK_FAILURE; /* Return code of this function */
57  argr_type argr = ARGR_TYPE_INIT; /* Command-line arguments */
58  char *band_name[NUMBER_BAND] = {"Blue","Green","Red","NIR"};
59  char *camera_name[NUMBER_CAMERA] = {"Df","Cf","Bf","Af","An",
60  "Aa","Ba","Ca","Da"};
62  /* Target map information. */
63  MTKt_GCTPProjInfo target_proj_info = MTKT_GCTPPROJINFO_INIT;
64  /* Target projection information. */
65  MTKt_Region region = MTKT_REGION_INIT; /* SOM region containing target map. */
66  MTKt_DataBuffer toa_brf_data = MTKT_DATABUFFER_INIT;
67  /* Top-of-atmosphere BRF data */
68  MTKt_MapInfo toa_rad_rdqi_map_info = MTKT_MAPINFO_INIT;
69  /* Map information for terrain RDQI. */
70  MTKt_DataBuffer toa_rad_rdqi = MTKT_DATABUFFER_INIT;
71  /* Top-of-atmosphere radiance data quality indicator */
72  MTKt_DataBuffer toa_brf_mask = MTKT_DATABUFFER_INIT;
73  /* Valid mask for TOA BRF. */
74  MTKt_MapInfo toa_brf_map_info = MTKT_MAPINFO_INIT;
75  /* Map information for terrain-projected radiance. */
77  /* Temporary latitude array for reprojection. */
79  /* Temporary longitude array for reprojection. */
81  /* Temporary line coord array for reprojection. */
82  MTKt_DataBuffer sample_coords = MTKT_DATABUFFER_INIT;
83  /* Temporary sample coord array for reprojection. */
84  MTKt_DataBuffer resampled_toa_brf_data = MTKT_DATABUFFER_INIT;
85  /* Input TOA BRF, resampled to target map. */
86  MTKt_DataBuffer resampled_toa_brf_mask = MTKT_DATABUFFER_INIT;
87  /* Valid mask for final result. */
88  int path; /* Orbit path number. */
89  int camera; /* Camera index. */
90  int iband; /* Loop iterator. */
91  int iline; /* Loop iterator. */
92  int isample; /* Loop iterator. */
93  char outputfile[MAX_FILENAME];
94  int32 fid = FAIL; /* HDF-EOS file identifier. */
95  int32 gid = FAIL; /* HDF-EOS grid identifier. */
96  int32 hstatus; /* HDF-EOS status code */
97  float64 upleft[2]; /* min X, max Y corner of target map. */
98  float64 lowright[2]; /* max X, min Y corner of target map. */
99  char *dimlist_ul_lr = "YDim,XDim";
100  /* HDF-EOS dimension list for origin UL or
101  origin LR maps.*/
102  char *dimlist_ur_ll = "XDim,YDim";
103  /* HDF-EOS dimension list for origin UR or
104  origin LL maps.*/
105  char *dimlist; /* HDF-EOS dimension list. */
106  int32 edge[2]; /* Size of HDF-EOS data to write. */
107  char fieldname[MAX_FIELDNAME]; /* Fieldname to read/write. */
108  char gridname[MAX_FIELDNAME]; /* Gridname to read. */
109  int size_x; /* Size of map along X axis. */
110  int size_y; /* Size of map along Y axis. */
111  int32 tile_rank = 2; /* HDF tile rank */
112  int32 tile_dims[2] = {64,64}; /* Tile dimensions. */
113  int32 comp_code = HDFE_COMP_DEFLATE; /* GZIP compression code. */
114  intn comp_parm[1] = {5}; /* GZIP compression level. */
115  float32 fill_float32 = -9999.0; /* Fill value for float32 fields. */
116 
117  /* ------------------------------------------------------------------ */
118  /* Parse command-line arguments. */
119  /* ------------------------------------------------------------------ */
120 
121  if (process_args(argc, argv, &argr))
123 
124  /* ------------------------------------------------------------------ */
125  /* Read projection / map information for target area. */
126  /* ------------------------------------------------------------------ */
127 
128  status = MtkGCTPProjInfoRead(argr.proj_map_file, &target_proj_info);
129  if (status != MTK_SUCCESS) {
130  printf("\n\nCheck that projection/map info filename is correct: %s\n",argr.proj_map_file);
131  MTK_ERR_MSG_JUMP("Trouble with MtkGCTPProjInfoRead\n");
132  }
133 
134  status = MtkGenericMapInfoRead(argr.proj_map_file, &target_map_info);
135  if (status != MTK_SUCCESS) {
136  MTK_ERR_MSG_JUMP("Trouble with MtkGenericMapInfoRead\n");
137  }
138 
139  /* ------------------------------------------------------------------ */
140  /* Get orbit path number of input file. */
141  /* ------------------------------------------------------------------ */
142 
143  status = MtkFileToPath(argr.terrain_file, &path);
144  if (status != MTK_SUCCESS) {
145  printf("\n\nCheck that input filename is correct: %s\n",argr.terrain_file);
146  MTK_ERR_MSG_JUMP("Trouble with MtkFileToPath(input)\n");
147  }
148 
149  /* ------------------------------------------------------------------ */
150  /* Get camera identifier from terrain input file. */
151  /* ------------------------------------------------------------------ */
152 
153  {
155 
156  status = MtkFileAttrGet(argr.terrain_file,"Camera",&attrbuf);
157  if (status != MTK_SUCCESS) {
158  printf("\n\nCheck that GRP_TERRAIN filename is correct: %s\n",argr.terrain_file);
159  MTK_ERR_MSG_JUMP("Trouble with MtkFileAttrGet(terrain_file)\n");
160  }
161 
162  camera = attrbuf.data.i32[0][0] - 1;
163  }
164 
165  /* ------------------------------------------------------------------ */
166  /* Setup SOM region containing the target map. */
167  /* ------------------------------------------------------------------ */
168 
169  status = MtkSetRegionByGenericMapInfo(&target_map_info,
170  &target_proj_info,
171  path,
172  &region);
173  if (status != MTK_SUCCESS) {
174  MTK_ERR_MSG_JUMP("Trouble with MtkSetRegionByGenericMapInfo\n");
175  }
176 
177  /* ------------------------------------------------------------------ */
178  /* Create HDF-EOS file for result. */
179  /* ------------------------------------------------------------------ */
180 
181  if (target_map_info.origin_code == MTKe_ORIGIN_UL ||
182  target_map_info.origin_code == MTKe_ORIGIN_LR) {
183  dimlist = dimlist_ul_lr;
184  } else {
185  dimlist = dimlist_ur_ll;
186  }
187 
188  edge[0] = target_map_info.size_line;
189  edge[1] = target_map_info.size_sample;
190 
191  upleft[0] = target_map_info.min_x;
192  upleft[1] = target_map_info.max_y;
193  lowright[0] = target_map_info.max_x;
194  lowright[1] = target_map_info.min_y;
195 
196  size_x = (int)floor((target_map_info.max_x - target_map_info.min_x) /
197  target_map_info.resolution_x + 0.5);
198  size_y = (int)floor((target_map_info.max_y - target_map_info.min_y) /
199  target_map_info.resolution_y + 0.5);
200 
201  snprintf(outputfile,MAX_FILENAME,"%s_%s.hdf",argr.output_basename,
202  camera_name[camera]);
203 
204  fid = GDopen(outputfile,DFACC_CREATE);
205  if (fid == FAIL) {
206  MTK_ERR_MSG_JUMP("Trouble with GDopen\n");
207  }
208 
209  hstatus = GDcreate(fid,OUTPUT_GRIDNAME,size_x, size_y,
210  upleft, lowright);
211 
212  gid = GDattach(fid, OUTPUT_GRIDNAME);
213  if (gid == FAIL) {
214  MTK_ERR_MSG_JUMP("Trouble with GDattach\n");
215  }
216 
217  hstatus = GDdeforigin(gid,target_map_info.origin_code);
218  if (hstatus == FAIL) {
219  MTK_ERR_MSG_JUMP("Trouble with GDdeforigin\n");
220  }
221 
222  hstatus = GDdefpixreg(gid,target_map_info.pix_reg_code);
223  if (hstatus == FAIL) {
224  MTK_ERR_MSG_JUMP("Trouble with GDdefpixreg\n");
225  }
226 
227  hstatus = GDdefproj(gid,target_proj_info.proj_code,
228  target_proj_info.zone_code, target_proj_info.sphere_code,
229  target_proj_info.proj_param);
230  if (hstatus == FAIL) {
231  MTK_ERR_MSG_JUMP("Trouble with GDdefproj\n");
232  }
233 
234  /* ------------------------------------------------------------------ */
235  /* Calculate pixel lat/lon locations for target map. */
236  /* ------------------------------------------------------------------ */
237 
238  status = MtkGCTPCreateLatLon(&target_map_info,
239  &target_proj_info,
240  &latitude,
241  &longitude);
242  if (status != MTK_SUCCESS) {
243  MTK_ERR_MSG_JUMP("Trouble with MtkGCTPCreateLatLon\n");
244  }
245 
246  /* ------------------------------------------------------------------ */
247  /* For each band to process... */
248  /* ------------------------------------------------------------------ */
249 
250  for (iband = 0 ; iband < NUMBER_BAND ; iband++) {
251  if (argr.band < 0 || iband == argr.band) {
252 
253  printf("Processing band %d (%s)...\n",iband, band_name[iband]);
254 
255  /* ------------------------------------------------------------------ */
256  /* Read TOA BRF for the target area. */
257  /* ------------------------------------------------------------------ */
258 
259  snprintf(gridname,MAX_FIELDNAME,"%sBand",band_name[iband]);
260  snprintf(fieldname,MAX_FIELDNAME,"%s BRF",band_name[iband]);
261 
262  status = MtkReadData(argr.terrain_file, gridname, fieldname,
263  region, &toa_brf_data, &toa_brf_map_info);
264  if (status != MTK_SUCCESS) {
265  MTK_ERR_MSG_JUMP("Trouble with MtkReadData(Terrain)\n");
266  }
267 
268  /* ------------------------------------------------------------------ */
269  /* Read terrain-projected radiance data quality indicators for the */
270  /* the target area. */
271  /* ------------------------------------------------------------------ */
272 
273  snprintf(gridname,MAX_FIELDNAME,"%sBand",band_name[iband]);
274  snprintf(fieldname,MAX_FIELDNAME,"%s RDQI",band_name[iband]);
275 
276  status = MtkReadData(argr.terrain_file, gridname, fieldname,
277  region, &toa_rad_rdqi, &toa_rad_rdqi_map_info);
278  if (status != MTK_SUCCESS) {
279  MTK_ERR_MSG_JUMP("Trouble with MtkReadData(Terrain)\n");
280  }
281 
282  /* ------------------------------------------------------------------ */
283  /* Generate mask indicating valid TOA BRF. */
284  /* TOA BRF is considered valid where the terrain-projected radiance */
285  /* data quality is less than 2. */
286  /* ------------------------------------------------------------------ */
287 
288  status = MtkDataBufferAllocate(toa_brf_data.nline, toa_brf_data.nsample,
289  MTKe_uint8,&toa_brf_mask);
290  if (status != MTK_SUCCESS) {
291  MTK_ERR_MSG_JUMP("Trouble with MtkDataBufferAllocate(toa_brf_mask)\n");
292  }
293 
294  for (iline = 0; iline < toa_brf_data.nline; iline++) {
295  for (isample = 0; isample < toa_brf_data.nsample; isample++) {
296  if (toa_rad_rdqi.data.u8[iline][isample] < 2) {
297  toa_brf_mask.data.u8[iline][isample] = 1;
298  } else {
299  toa_brf_mask.data.u8[iline][isample] = 0;
300  }
301  }
302  }
303 
304  /* ------------------------------------------------------------------ */
305  /* Free memory. */
306  /* ------------------------------------------------------------------ */
307 
308  MtkDataBufferFree(&toa_rad_rdqi);
309 
310  /* ------------------------------------------------------------------ */
311  /* Reproject TOA BRF to target map. */
312  /* ------------------------------------------------------------------ */
313 
314  status = MtkTransformCoordinates(toa_brf_map_info,
315  latitude,
316  longitude,
317  &line_coords,
318  &sample_coords);
319  if (status != MTK_SUCCESS) {
320  MTK_ERR_MSG_JUMP("Trouble with MtkTransformCoordinates\n");
321  }
322 
323  status = MtkResampleCubicConvolution(&toa_brf_data,
324  &toa_brf_mask,
325  &line_coords,
326  &sample_coords,
327  -0.5,
328  &resampled_toa_brf_data,
329  &resampled_toa_brf_mask);
330  if (status != MTK_SUCCESS) {
331  MTK_ERR_MSG_JUMP("Trouble with MtkResampleCubicConvolution\n");
332  }
333 
334  /* ------------------------------------------------------------------ */
335  /* Free memory */
336  /* ------------------------------------------------------------------ */
337 
338  MtkDataBufferFree(&resampled_toa_brf_mask);
339  MtkDataBufferFree(&toa_brf_mask);
340  MtkDataBufferFree(&toa_brf_data);
341 
342  /* ------------------------------------------------------------------ */
343  /* Free memory */
344  /* ------------------------------------------------------------------ */
345 
346  MtkDataBufferFree(&line_coords);
347  MtkDataBufferFree(&sample_coords);
348 
349  /* ------------------------------------------------------------------ */
350  /* Write input TOA BRF to HDF-EOS file. */
351  /* ------------------------------------------------------------------ */
352 
353  snprintf(fieldname,MAX_FIELDNAME,"TOA_BRF_%s_%s",
354  camera_name[camera], band_name[iband]);
355 
356  hstatus = GDdeffield(gid, fieldname, dimlist, DFNT_FLOAT32, 0);
357  if (hstatus == FAIL) {
358  MTK_ERR_MSG_JUMP("Trouble with GDdeffield\n");
359  }
360 
361  hstatus = GDsetfillvalue(gid, fieldname, &fill_float32);
362  if (hstatus == FAIL) {
363  MTK_ERR_MSG_JUMP("Trouble with GDsetfillvalue()\n");
364  }
365 
366  hstatus = GDsettilecomp(gid, fieldname, tile_rank,
367  tile_dims, comp_code, comp_parm);
368  if (hstatus == FAIL) {
369  MTK_ERR_MSG_JUMP("Trouble with GDsettilecomp()\n");
370  }
371 
372  hstatus = GDwritefield(gid, fieldname, NULL, NULL, edge,
373  resampled_toa_brf_data.dataptr);
374  if (hstatus == FAIL) {
375  MTK_ERR_MSG_JUMP("Trouble with GDwritefield\n");
376  }
377 
378  /* ------------------------------------------------------------------ */
379  /* Free memory. */
380  /* ------------------------------------------------------------------ */
381 
382  MtkDataBufferFree(&resampled_toa_brf_data);
383 
384  /* ------------------------------------------------------------------ */
385  /* End loop for each band to process. */
386  /* ------------------------------------------------------------------ */
387 
388  }
389  }
390 
391  /* ------------------------------------------------------------------ */
392  /* Free memory. */
393  /* ------------------------------------------------------------------ */
394 
395  MtkDataBufferFree(&latitude);
396  MtkDataBufferFree(&longitude);
397 
398  /* ------------------------------------------------------------------ */
399  /* Close HDF-EOS file. */
400  /* ------------------------------------------------------------------ */
401 
402  hstatus = GDdetach(gid);
403  if (hstatus == FAIL) {
404  MTK_ERR_MSG_JUMP("Trouble with GDdetach\n");
405  }
406  gid = FAIL;
407 
408  hstatus = GDclose(fid);
409  if (hstatus == FAIL) {
410  MTK_ERR_MSG_JUMP("Trouble with GDclose\n");
411  }
412  fid = FAIL;
413 
414  printf("Wrote output to %s\n",outputfile);
415  printf("Completed normally.\n");
416  return 0;
417 
418 ERROR_HANDLE:
419  if (gid != FAIL) {
420  hstatus = GDdetach(gid);
421  }
422  if (fid != FAIL) {
423  hstatus = GDclose(fid);
424  }
425 
426  MtkDataBufferFree(&resampled_toa_brf_mask);
427  MtkDataBufferFree(&resampled_toa_brf_data);
428  MtkDataBufferFree(&latitude);
429  MtkDataBufferFree(&longitude);
430  MtkDataBufferFree(&toa_brf_mask);
431  MtkDataBufferFree(&toa_rad_rdqi);
432  MtkDataBufferFree(&toa_brf_data);
433  MtkDataBufferFree(&line_coords);
434  MtkDataBufferFree(&sample_coords);
435 
436  printf("Failed: status code = %d\n",status_code);
437 
438  return status_code;
439 }
440 
441 void usage(char *func) {
442  fprintf(stderr,
443 "\nUsage: %s [--help] [--band=<band number>] \n"
444 " <projection/map info file> <GRP_TERRAIN file>\n"
445 " <output basename>\n",
446  func);
447 
448  fprintf(stderr,
449 "\n"
450 "Perform reproject L1B2 terrain data to given map projection.\n"
451 "\n"
452 "Result is written to an HDF-EOS file in the following fields:\n"
453 " TOA_BRF_<cam>_<band> Input TOA BRF from GRP_TERRAIN file (reprojected).\n"
454 "\n"
455 "All output fields have identical map projection and size.\n"
456 "\n"
457  );
458 
459  fprintf(stderr,
460 "COMMAND-LINE OPTIONS\n"
461 "\n"
462 "--help\n"
463 " Returns this usage info.\n"
464 "\n"
465 "--band=<band number>\n"
466 " Specifies the band to process. Bands are identified by integer values as\n"
467 " follows: 0 = blue 1 = green 2 = red 3 = nir\n"
468 "\n"
469  );
470 
471  fprintf(stderr,
472 "COMMAND-LINE ARGUMENTS\n"
473 "\n"
474 "<projection/map info file>\n"
475 " Text file specifying map projection for the output. Parameters are\n"
476 " specified as name = value pairs. Parameter names are as follows:\n"
477 "\n"
478 " proj_code is the GCTP projection code.\n"
479 " utm_zone is the UTM zone number for UTM projections only.\n"
480 " sphere_code is GCTP spheroid code.\n"
481 " proj_param(n) is the nth GCTP projection parameter. (1 <= n <= 15)\n"
482 " min_corner_x is the minimum X coordinate at the edge of the map.\n"
483 " min_corner_y is the minimum Y coordinate at the edge of the map.\n"
484 " resolution_x is the size of a pixel along the X-axis.\n"
485 " resolution_y is the size of a pixel along the Y-axis.\n"
486 " number_pixel_x is the size of the map in pixels, along the X-axis.\n"
487 " number_pixel_y is the size of the map in pixels, along the Y-axis.\n"
488 " origin_code defines the corner of the map at which pixel 0,0 is located.\n"
489 " pix_reg_code defines whether a pixel value is related to the corner or\n"
490 " center of the corresponding area of that pixel on the map. If the\n"
491 " corner is used, then it is always the corner corresponding to the\n"
492 " corner of the origin.\n"
493 "\n"
494 " Possible values for origin_code are:\n"
495 " UL - Upper Left (min X, max Y); Line=Y, Sample=X\n"
496 " UR - Upper Right (max X, max Y); Line=X, Sample=Y\n"
497 " LL - Lower Left (min X, min Y); Line=X, Sample=Y\n"
498 " LR - Lower Right (max X, min Y); Line=Y, Sample=X\n"
499 "\n"
500 " Possible values for pix_reg_code are:\n"
501 " CENTER - Center\n"
502 " CORNER - Corner\n"
503 "\n"
504 " Unrecognized parameter names are ignored.\n"
505 " Lines starting with a '#' character are ignored.\n"
506 " Anything after the name = value pair on a line is ignored.\n"
507 "\n"
508 " Example projection/map info file:\n"
509 " # Albers equal-area conic projection parameters\n"
510 " proj_code = 3 # Albers equal-area conic\n"
511 " sphere_code = 8 # GRS80\n"
512 " proj_param(3) = 29030000.0 # Latitude of the first standard parallel\n"
513 " proj_param(4) = 45030000.0 # Latitude of the second standard parallel\n"
514 " proj_param(5) = -96000000.0 # Longitude of the central meridian\n"
515 " proj_param(6) = 23000000.0 # Latitude of the projection origin\n"
516 " # Map information\n"
517 " min_corner_x = 1930612.449614\n"
518 " min_corner_y = 2493633.488881\n"
519 " resolution_x = 250.0\n"
520 " resolution_y = 250.0\n"
521 " number_pixel_x = 1311\n"
522 " number_pixel_y = 2078\n"
523 " origin_code = UL\n"
524 " pix_reg_code = CENTER\n"
525 "\n"
526 "\n"
527 "<GRP_TERRAIN>\n"
528 " MISR Terrain-projected Radiance Product (GRP_TERRAIN).\n"
529 "\n"
530 "<output basename>\n"
531 " Basename for output file.\n"
532 "\n"
533 "Examples:\n"
534 "\n"
535 " MtkL1B2Reproject --band=2 proj_map_info.txt \\\n"
536 " MISR_AM1_GRP_TERRAIN_GM_P011_O013824_DF_F03_0024.b52-56.hdf \\\n"
537 " BRF_O013824_maine\n"
538 "\n"
539 " MtkL1B2Reproject \\\n"
540 " proj_map_info.txt \\\n"
541 " MISR_AM1_GRP_TERRAIN_GM_P011_O013824_DF_F03_0024.b52-56.hdf \\\n"
542 " BRF_O013824_maine\n"
543 "\n"
544  );
545 }
546 
547 int process_args(int argc, char *argv[], argr_type *argr) {
548 
549  MTKt_status status_code = MTK_FAILURE;
550  extern char *optarg;
551  extern int optind;
552  int ch;
553  argr->band = -1;
554 
555  /* options descriptor */
556  static struct option longopts[] = {
557  { "band", required_argument, 0, 'b' },
558  { "help", no_argument, 0, 'h' },
559  { 0, 0, 0, 0 }
560  };
561 
562  while ((ch = getopt_long(argc, argv, "b:h", longopts, NULL)) != -1) {
563 
564  switch(ch) {
565  case 'h':
567  break;
568  case 'b' :
569  argr->band = (int)atol(optarg);
570  break;
571  default:
572  MTK_ERR_MSG_JUMP("Invalid arguments");
573  }
574  }
575 
576  if (argc-optind != 3) MTK_ERR_CODE_JUMP(MTK_OUTBOUNDS);
577 
578  argr->proj_map_file = argv[optind++];
579  argr->terrain_file = argv[optind++];
580  argr->output_basename = argv[optind++];
581 
582  return MTK_SUCCESS;
583  ERROR_HANDLE:
584  usage(argv[0]);
585  return status_code;
586 }
587 
intn GDdefpixreg(int32, int32)
MTKt_status MtkGCTPProjInfoRead(const char *Filename, MTKt_GCTPProjInfo *Proj_info)
Initialize a MTKt_GCTPProjInfo structure using data from an external file.
MTKt_PixRegCode pix_reg_code
Definition: MisrMapQuery.h:116
MTKt_status MtkDataBufferAllocate(int nline, int nsample, MTKt_DataType datatype, MTKt_DataBuffer *databuf)
Allocate Data Buffer.
int32 GDattach(int32, char *)
#define NUMBER_BAND
MTKt_status MtkSetRegionByGenericMapInfo(const MTKt_GenericMapInfo *Map_info, const MTKt_GCTPProjInfo *Proj_info, int Path, MTKt_Region *Region)
Create an MtkRegion structure that contains the given map.
MTKt_OriginCode origin_code
Definition: MisrMapQuery.h:115
Generic map information.
Definition: MisrMapQuery.h:98
MTKt_DataBufferType data
Definition: MisrUtil.h:104
intn GDclose(int32)
int process_args(int argc, char *argv[], argr_type *argr)
#define MTKT_MAPINFO_INIT
Definition: MisrMapQuery.h:79
GCTP projection information.
Definition: MisrMapQuery.h:123
MTKt_status MtkTransformCoordinates(MTKt_MapInfo mapinfo, MTKt_DataBuffer latbuf, MTKt_DataBuffer lonbuf, MTKt_DataBuffer *linebuf, MTKt_DataBuffer *samplebuf)
Transforms latitude/longitude coordinates into line/sample coordinates for a given mapinfo...
#define MTKT_REGION_INIT
Definition: MisrSetRegion.h:46
#define MTK_ERR_CODE_JUMP(code)
Definition: MisrError.h:175
Map Information.
Definition: MisrMapQuery.h:65
#define ARGR_TYPE_INIT
char * terrain_file
intn GDdetach(int32)
intn GDdeforigin(int32, int32)
JCOPY_OPTION option
Definition: transupp.h:131
2-dimensional Data Buffer
Definition: MisrUtil.h:98
int main(int argc, char *argv[])
#define NUMBER_CAMERA
#define MTKT_DATABUFFER_INIT
Definition: MisrUtil.h:109
int32 GDcreate(int32, char *, int32, int32, float64 [], float64 [])
void * dataptr
Definition: MisrUtil.h:106
MTKt_status MtkDataBufferFree(MTKt_DataBuffer *databuf)
Free data buffer.
MTKt_status MtkGCTPCreateLatLon(const MTKt_GenericMapInfo *Map_info, const MTKt_GCTPProjInfo *Proj_info, MTKt_DataBuffer *Latitude, MTKt_DataBuffer *Longitude)
Create an array of latitude and longitude values corresponding to each pixel in the given map...
MTKt_uint8 ** u8
Definition: MisrUtil.h:86
MTKt_status MtkFileAttrGet(const char *filename, const char *attrname, MTKt_DataBuffer *attrbuf)
Get a file attribute.
MTKt_status MtkResampleCubicConvolution(const MTKt_DataBuffer *Source, const MTKt_DataBuffer *Source_mask, const MTKt_DataBuffer *Line, const MTKt_DataBuffer *Sample, float A, MTKt_DataBuffer *Resampled, MTKt_DataBuffer *Resampled_mask)
Resample source data at the given coordinates using interpolation by cubic convolution.
intn GDdefproj(int32, int32, int32, int32, float64 [])
char * proj_map_file
#define MAX_FIELDNAME
MTKt_status MtkReadData(const char *filename, const char *gridname, const char *fieldname, MTKt_Region region, MTKt_DataBuffer *databuf, MTKt_MapInfo *mapinfo)
Reads any grid/field from any MISR product file and performs unpacking or unscaling. It also reads any MISR conventional product file.
Definition: MtkReadData.c:62
double proj_param[15]
Definition: MisrMapQuery.h:127
char * output_basename
intn GDsettilecomp(int32, char *, int32, int32 *, int32, intn *)
#define DFNT_FLOAT32
Definition: hntdefs.h:36
#define MTK_ERR_MSG_JUMP(msg)
Definition: MisrError.h:169
intn GDsetfillvalue(int32, char *, VOIDP)
MTKt_status MtkGenericMapInfoRead(const char *Filename, MTKt_GenericMapInfo *Map_info)
Initialize a MTKt_GenericMapInfo structure using data from an external file.
intn GDdeffield(int32, char *, char *, int32, int32)
intn GDwritefield(int32, char *, int32 [], int32 [], int32 [], VOIDP)
#define HDFE_COMP_DEFLATE
Definition: HdfEosDef.h:78
MTKt_int32 ** i32
Definition: MisrUtil.h:89
void usage(char *func)
MTKt_status
Definition: MisrError.h:11
#define MTKT_GENERICMAPINFO_INIT
Definition: MisrMapQuery.h:120
Region of interest.
Definition: MisrSetRegion.h:41
int32 GDopen(char *, intn)
#define OUTPUT_GRIDNAME
#define DFACC_CREATE
Definition: hdf.h:46
#define MTKT_GCTPPROJINFO_INIT
Definition: MisrMapQuery.h:130
#define MAX_FILENAME
MTKt_status MtkFileToPath(const char *filename, int *path)
Read path number from file.
Definition: MtkFileToPath.c:35
#define FAIL
Definition: hdf.h:94

MISR Toolkit - Copyright © 2005 - 2020 Jet Propulsion Laboratory
Generated on Fri Jun 19 2020 22:49:51