[gradsusr] 回復: How to read latitude/longitude data from background map
yaqiang.wang at gmail.com
yaqiang.wang at gmail.com
Fri Aug 15 04:59:37 EDT 2014
The following is Java code to read GrADS map data, which should be useful for understanding the format.
String fileName = "../hires"
DataInputStream br = new DataInputStream(new BufferedInputStream(new FileInputStream(new File(fileName))));
int i, lineNum;
byte b;
short N, lType;
double lon, lat;
byte[] bytes;
lineNum = 0;
do {
b = br.readByte(); // 1-data, 2-skip
if ("2".equals(Byte.toString(b))) {
br.skipBytes(18);
continue;
}
b = br.readByte(); // Line type: country, river ...
lType = (short) DataConvert.byte2Int(b);
b = br.readByte(); // Point number
N = (short) DataConvert.byte2Int(b);
for (i = 0; i < N; i++) {
bytes = new byte[3];
br.read(bytes); //Longitude
int val = 0;
for (int bb = 0; bb < 3; bb++) {
val <<= 8;
val |= (int) bytes[bb] & 0xFF;
}
lon = val / 10000.0;
bytes = new byte[3];
br.read(bytes); //Latitude
val = 0;
for (int bb = 0; bb < 3; bb++) {
val <<= 8;
val |= (int) bytes[bb] & 0xFF;
}
lat = val / 10000.0 - 90.0;
}
lineNum++;
} while (br.available() > 0);
br.close();
Regards
Yaqiang
*************************************************
Dr. Yaqiang Wang
Chinese Academy of Meteorological Sciences (CAMS)
46, Zhong-Guan-Cun South Avenue
Beijing, 100081
China
yaqiang.wang at gmail.com
http://www.meteothinker.com
**************************************************
發件人: Tsai Ray
發送時間: 2014-08-15 03:06
收件人: gradsusr at gradsusr.org
主題: [gradsusr] How to read latitude/longitude data from background map
Dear GrASD users,
I already have a high-resolution regional backgruond map data(same formation as hires and lowres), and
now I'm trying to read the latitude/longitude from it by fortran program.
But I'm not sure about the formation of background map data, and still can't get the correct latitude/longitude information.
Is there any way to solve this problem, please~~~~
Thanks,
Ray
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20140815/7209b3a0/attachment-0001.html
More information about the gradsusr
mailing list