31 double lat_dd = 32.2, lon_dd = -114.5;
33 double lat_extent = 200, lon_extent = 100;
38 float blk_line, blk_sample;
40 int latdeg, londeg, latmin, lonmin;
41 double latsec, lonsec;
57 if( getenv(
"MTKHOME") ) {
58 strcpy(testroot, getenv(
"MTKHOME"));
59 strcat(testroot,
"/../Mtk_testdata");
61 printf(
"MTKHOME environment variable not found.\n" \
62 "Please enter the path to Mtk_testdata directory" \
63 "(e.g. C:\\Mtk_testdata or /tmp/Mtk_testdata ):");
72 lat_extent, lon_extent,
"km", ®ion);
75 printf(
"region center lat/lon (dd) = (%f, %f)\n",
77 printf(
" region extent (m) = (%f, %f)\n",
86 strcpy(filename,testroot);
87 strcat(filename,
"/in/");
88 strcat(filename,
"MISR_AM1_GRP_ELLIPSOID_GM_P037_O029058_AA_F03_0024.hdf");
89 strcpy(gridname,
"RedBand");
90 strcpy(fieldname,
"Red Brf");
92 status =
MtkReadData(filename, gridname, fieldname, region,
93 &brf_databuf, &brf_mapinfo);
96 status =
MtkLatLonToLS(brf_mapinfo, lat_dd, lon_dd, &line, &sample);
100 s = (int)round(sample);
109 &block, &blk_line, &blk_sample);
112 status =
MtkLSToLatLon(brf_mapinfo, line, sample, &lat, &lon);
121 status =
MtkLSToSomXY(brf_mapinfo, line, sample, &somx, &somy);
130 printf(
"\n Reading file = %s\n",filename);
131 printf(
" Reading grid = %s\n",gridname);
132 printf(
" Reading field = %s\n",fieldname);
133 printf(
" number of lines/samples = (%d, %d)\n",
135 printf(
" input lat/lon (dd) = (%f, %f)\n", lat_dd, lon_dd);
136 printf(
" line/sample = (%f, %f)\n", line, sample);
137 printf(
" Brf[%d][%d] = %f\n", l, s, brf_databuf.
data.
f[l][s]),
138 printf(
" block/line/sample = (%d, %f, %f)\n",
139 block, blk_line, blk_sample);
140 printf(
" lat/lon (dd) = (%f, %f)\n", lat, lon);
141 printf(
" lat/lon (dms) = (%d:%d:%f, %d:%d:%f)\n",
142 latdeg, latmin, latsec, londeg, lonmin, lonsec);
143 printf(
" SOM x/y = (%f, %f)\n", somx, somy);
144 printf(
" pixel time[%d][%d] = %s\n", l, s, datetime);
154 strcpy(filename,testroot);
155 strcat(filename,
"/in/");
156 strcat(filename,
"MISR_AM1_AS_LAND_P037_O029058_F06_0017.hdf");
157 strcpy(gridname,
"SubregParamsLnd");
158 strcpy(fieldname,
"LandHDRF[3][4]");
160 status =
MtkReadData(filename, gridname, fieldname, region,
161 &hdrf_databuf, &hdrf_mapinfo);
164 status =
MtkLatLonToLS(hdrf_mapinfo, lat_dd, lon_dd, &line, &sample);
167 l = (int)round(line);
168 s = (int)round(sample);
177 &block, &blk_line, &blk_sample);
180 status =
MtkLSToLatLon(hdrf_mapinfo, line, sample, &lat, &lon);
192 printf(
"\n Reading file = %s\n",filename);
193 printf(
" Reading grid = %s\n",gridname);
194 printf(
" Reading field = %s\n",fieldname);
195 printf(
" number of lines/samples = (%d, %d)\n",
197 printf(
" input lat/lon (dd) = (%f, %f)\n", lat_dd, lon_dd);
198 printf(
" line/sample = (%f, %f)\n", line, sample);
199 printf(
" HDRF[%d][%d] = %f\n", l, s, hdrf_databuf.
data.
f[l][s]),
200 printf(
" block/line/sample = (%d, %f, %f)\n",
201 block, blk_line, blk_sample);
202 printf(
" lat/lon (dd) = (%f, %f)\n", lat, lon);
203 printf(
" lat/lon (dms) = (%d:%d:%f, %d:%d:%f)\n",
204 latdeg, latmin, latsec, londeg, lonmin, lonsec);
205 printf(
" SOM x/y = (%f, %f)\n", somx, somy);
211 printf(
"Error: %s\n",err_msg[status_code]);
MTKt_status MtkLatLonToBls(int path, int resolution_meters, double lat_dd, double lon_dd, int *block, float *line, float *sample)
Convert decimal degrees latitude and longitude to block, line, sample.
#define MTKT_TIME_METADATA_INIT
#define MTKT_MAPINFO_INIT
MTKt_status MtkLSToLatLon(MTKt_MapInfo mapinfo, float line, float sample, double *lat_dd, double *lon_dd)
Convert line, sample to decimal degrees latitude and longitude.
MTKt_status MtkLSToSomXY(MTKt_MapInfo mapinfo, float line, float sample, double *som_x, double *som_y)
Convert line, sample to SOM X, SOM Y.
MTKt_status MtkLatLonToLS(MTKt_MapInfo mapinfo, double lat_dd, double lon_dd, float *line, float *sample)
Convert decimal degrees latitude and longitude to line, sample.
2-dimensional Data Buffer
#define MTKT_DATABUFFER_INIT
MTKt_status MtkDataBufferFree(MTKt_DataBuffer *databuf)
Free data buffer.
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.
MTKt_status MtkSetRegionByLatLonExtent(double ctr_lat_dd, double ctr_lon_dd, double lat_extent, double lon_extent, const char *extent_units, MTKt_Region *region)
Select region by latitude, longitude in decimal degrees, and extent in specified units of degrees...
MTKt_status MtkTimeMetaRead(const char *filename, MTKt_TimeMetaData *time_metadata)
Read time metadata from L1B2 Ellipsoid product file.
MTKt_status MtkPixelTime(MTKt_TimeMetaData time_metadata, double som_x, double som_y, char pixel_time[MTKd_DATETIME_LEN])
Given SOM Coordinates compute pixel time.
MTKt_status MtkDdToDegMinSec(double dd, int *deg, int *min, double *sec)
Convert decimal degrees to unpacked degrees, minutes, seconds.
#define MTK_ERR_COND_JUMP(code)
MTKt_status MtkFileToPath(const char *filename, int *path)
Read path number from file.
#define MTKd_DATETIME_LEN
MTKt_status MtkLatLonToSomXY(int path, double lat_dd, double lon_dd, double *som_x, double *som_y)
Convert decimal degrees latitude and longitude to SOM X, SOM Y.
MTKt_status MtkFileGridToResolution(const char *filename, const char *gridname, int *resolution)
Get resolution of a particular grid.