23 #include <HdfEosDef.h> 25 #define MAX_FILENAME 5000 26 #define MAX_FIELDNAME 1000 27 #define MAX_LENGTH 1000 28 #define GP_GMP_GRID_NAME "GeometricParameters" 29 #define OUTPUT_GRIDNAME "GeometricParameters" 30 #define NUMBER_FIELD 20 31 #define NUMBER_CAMERA 9 43 #define ARGR_TYPE_INIT {NULL, NULL, NULL} 55 int main(
int argc,
char *argv[] ) {
86 char *dimlist_ul_lr =
"YDim,XDim";
89 char *dimlist_ur_ll =
"XDim,YDim";
119 int32 tile_dims[2] = {64,64};
121 intn comp_parm[1] = {5};
122 float32 fill_float32 = -9999.0;
169 dimlist = dimlist_ul_lr;
171 dimlist = dimlist_ur_ll;
177 upleft[0] = target_map_info.
min_x;
178 upleft[1] = target_map_info.
max_y;
179 lowright[0] = target_map_info.
max_x;
180 lowright[1] = target_map_info.
min_y;
182 size_x = (int)floor((target_map_info.
max_x - target_map_info.
min_x) /
184 size_y = (int)floor((target_map_info.
max_y - target_map_info.
min_y) /
201 if (hstatus ==
FAIL) {
206 if (hstatus ==
FAIL) {
213 if (hstatus ==
FAIL) {
238 printf(
"Processing %s...\n",fieldnames[ifield]);
245 region, &geom_data_float64, &map_info);
260 for (iline = 0; iline < geom_data.
nline; iline++) {
261 for (isample = 0; isample < geom_data.
nsample; isample++) {
262 geom_data.
data.
f[iline][isample] = geom_data_float64.
data.
d[iline][isample];
282 &resampled_geom_data);
292 if (hstatus ==
FAIL) {
297 if (hstatus ==
FAIL) {
302 tile_dims, comp_code, comp_parm);
303 if (hstatus ==
FAIL) {
307 hstatus =
GDwritefield(gid, fieldnames[ifield], NULL, NULL, edge,
309 if (hstatus ==
FAIL) {
341 if (hstatus ==
FAIL) {
347 if (hstatus ==
FAIL) {
353 printf(
"Completed normally.\n");
372 printf(
"Failed: status code = %d\n",status_code);
379 "\nUsage: %s [--help] <projection/map info file>\n" 380 " <GP_GMP file> <output filename>\n",
385 "Reproject MISR geometric parameters to the given map projection.\n" 386 "Resampling is by nearest-neighbor.\n" 388 "Result is written to an HDF-EOS file in the following fields:\n" 389 " SolarAzimuth Solar azimuth angle.\n" 390 " SolarZenith Solar zenith angle.\n" 391 " <cam>Azimuth View azimuth angle for this camera.\n" 392 " <cam>Zenith View zenith angle for this camera.\n" 394 "All output fields have identical map projection and size.\n" 399 "COMMAND-LINE OPTIONS\n" 402 " Returns this usage info.\n" 407 "COMMAND-LINE ARGUMENTS\n" 409 "<projection/map info file>\n" 410 " Text format file map projection for the output file. Parameters are\n" 411 " specified as name = value pairs. Parameter names are as follows:\n" 413 " proj_code is the GCTP projection code.\n" 414 " utm_zone is the UTM zone number for UTM projections only.\n" 415 " sphere_code is GCTP spheroid code.\n" 416 " proj_param(n) is the nth GCTP projection parameter. (1 <= n <= 15)\n" 417 " min_corner_x is the minimum X coordinate at the edge of the map.\n" 418 " min_corner_y is the minimum Y coordinate at the edge of the map.\n" 419 " resolution_x is the size of a pixel along the X-axis.\n" 420 " resolution_y is the size of a pixel along the Y-axis.\n" 421 " number_pixel_x is the size of the map in pixels, along the X-axis.\n" 422 " number_pixel_y is the size of the map in pixels, along the Y-axis.\n" 423 " origin_code defines the corner of the map at which pixel 0,0 is located.\n" 424 " pix_reg_code defines whether a pixel value is related to the corner or\n" 425 " center of the corresponding area of that pixel on the map. If the\n" 426 " corner is used, then it is always the corner corresponding to the\n" 427 " corner of the origin.\n" 429 " Possible values for origin_code are:\n" 430 " UL - Upper Left (min X, max Y)\n" 431 " UR - Upper Right (max X, max Y)\n" 432 " LL - Lower Left (min X, min Y)\n" 433 " LR - Lower Right (max X, min Y)\n" 435 " Possible values are:\n" 439 " Unrecognized parameter names are ignored.\n" 440 " Lines starting with a '#' character are ignored.\n" 441 " Anything after the name = value pair on a line is ignored.\n" 443 " Example projection/map info file:\n" 444 " # Albers equal-area conic projection parameters\n" 445 " proj_code = 3 # Albers equal-area conic\n" 446 " sphere_code = 8 # GRS80\n" 447 " proj_param(3) = 29030000.0 # Latitude of the first standard parallel\n" 448 " proj_param(4) = 45030000.0 # Latitude of the second standard parallel\n" 449 " proj_param(5) = -96000000.0 # Longitude of the central meridian\n" 450 " proj_param(6) = 23000000.0 # Latitude of the projection origin\n" 451 " # Map information\n" 452 " min_corner_x = 1930612.449614\n" 453 " min_corner_y = 2493633.488881\n" 454 " resolution_x = 250.0\n" 455 " resolution_y = 250.0\n" 456 " number_pixel_x = 1311\n" 457 " number_pixel_y = 2078\n" 458 " origin_code = UL # Min x, Max y; Line=Y, Sample=X\n" 459 " pix_reg_code = CENTER\n" 463 " MISR Geometric parameters (GP_GMP).\n" 465 "<output filename>\n" 466 " Filename for output file.\n" 470 " MtkResampleGeom proj_map_info.txt \\\n" 471 " MISR_AM1_GP_GMP_P011_O013842_F03_0013.hdf \\\n" 472 " GEOM_O013824_maine.hdf\n" 485 static struct option longopts[] = {
486 {
"help", no_argument, 0,
'h' },
490 while ((ch = getopt_long(argc, argv,
"h", longopts, NULL)) != -1) {
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
MTKt_status MtkDataBufferAllocate(int nline, int nsample, MTKt_DataType datatype, MTKt_DataBuffer *databuf)
Allocate Data Buffer.
int32 GDattach(int32, char *)
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
#define MTKT_MAPINFO_INIT
GCTP projection information.
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...
int main(int argc, char *argv[])
#define MTK_ERR_CODE_JUMP(code)
intn GDdeforigin(int32, int32)
2-dimensional Data Buffer
#define MTKT_DATABUFFER_INIT
int32 GDcreate(int32, char *, int32, int32, float64 [], float64 [])
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...
intn GDdefproj(int32, int32, int32, int32, float64 [])
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.
int process_args(int argc, char *argv[], argr_type *argr)
intn GDsettilecomp(int32, char *, int32, int32 *, int32, intn *)
#define MTK_ERR_MSG_JUMP(msg)
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
MTKt_status MtkResampleNearestNeighbor(MTKt_DataBuffer srcbuf, MTKt_DataBuffer linebuf, MTKt_DataBuffer samplebuf, MTKt_DataBuffer *resampbuf)
Perform nearest neighbor resampling.
#define MTKT_GENERICMAPINFO_INIT
int32 GDopen(char *, intn)
#define MTKT_GCTPPROJINFO_INIT
MTKt_status MtkFileToPath(const char *filename, int *path)
Read path number from file.