[Mapserver-users] ESRI Ascii grid format...
Delfos, Jacob
jacob.delfos at maunsell.com
Tue Jun 22 17:49:23 PDT 2004
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_000_01C458BB.ED6B0900
Content-Type: text/plain
It's a bit tricky. You cannot always go on a 'line by line' basis. It tells
you how many values per line, and after that it just dumps the values in
consecutive order. It's for you to decide when to go to the new line (based
on the number of values per line). I think the linefeed comes after a fixed
number of values, irrespective of whether it's reached the end of the data
row yet.
I had a headache with this once, so I wrote a JAVA program to convert it to
XYZ delimited ascii. Just type "java Contour [inputfile] [outputfile]" at
the commandline.
Regards,
Jacob
-----Original Message-----
From: Bruce Raup [mailto:braup at nsidc.org]
Sent: Wednesday, 23 June 2004 7:19 AM
To: Jason M. Nielsen
Cc: mapserver-users at lists.gis.umn.edu
Subject: Re: [Mapserver-users] ESRI Ascii grid format...
On 2004-06-22 15:13 -0600, Jason M. Nielsen wrote:
> I have some ascii files dumped as the AAIGRID format from gdal. These
> are esri ascii grids.
>
> The format appears simple:
> ncols 98
> nrows 172
> xllcorner 1044355.808370659710
> yllcorner 10042832.567399607971
> cellsize 91.442854747403
> *then the z values are listed for each line*
>
> Problem is I dont know which friggin way these go. I tried left to
> right starting lower left and incrementing x and y. I end up with
> skewed data.
>
> Does anyone know where I can get the specs on this format that
> explicitly explain in thorough detail how its formated?
I'm pretty sure the first z-value is the upper-left corner of the grid, and
that it proceeds left-to-right, then down. I have used GMT (Generic Mapping
Tools (http://gmt.soest.hawaii.edu/)) to handle such files, and had success
using these assumptions. Sorry, but I don't know where the specs are.
Bruce
--
Bruce Raup Phone:
303-492-8814
National Snow and Ice Data Center, U. of Colorado, 449 UCB, Boulder, CO
80309 http://cires.colorado.edu/~braup/
_______________________________________________
Mapserver-users mailing list
Mapserver-users at lists.gis.umn.edu
http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
------_=_NextPart_000_01C458BB.ED6B0900
Content-Type: application/octet-stream;
name="Contour.java"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="Contour.java"
import java.io.*;
import java.util.*;
public class Contour
{
public static double leftX;
public static double lowY;
public static double rightX;
public static double highY;
public static int numRows;
public static int numCols;
public static String inFile;
public static String outFile;
public static double [][] datagrid;
public static double Xspacing;
public static double Yspacing;
public static void main (String args[])
{
try
{
inFile =3D args[0];
outFile =3D args[1];
//leftX =3D Double.parseDouble(args[2]);
//lowY =3D Double.parseDouble(args[3]);
//rightX =3D Double.parseDouble(args[4]);
//highY =3D Double.parseDouble(args[5]);
readFile();
writeFile();
}
catch (Exception e)
{
System.out.println("Usage: \n\n java Contour [inputfile] =
[outputfile] ");
}
}
public static void readFile ()
{
String readString =3D "";
StringTokenizer token;
String dataOutput =3D "";
String tempNum =3D "";
try
{
RandomAccessFile inputFile =3D new RandomAccessFile (inFile,"r");
//inputFile.readLine();
System.out.println("opened file");
readString =3D inputFile.readLine();
token =3D new StringTokenizer(readString, "\n\r ");
token.nextToken();
numCols =3D Integer.parseInt(token.nextToken());
readString =3D inputFile.readLine();
token =3D new StringTokenizer(readString, "\n\r ");
token.nextToken();
numRows =3D Integer.parseInt(token.nextToken());
System.out.println(numCols);
System.out.println(numRows);
readString =3D inputFile.readLine();
token =3D new StringTokenizer(readString, "\n\r ");
token.nextToken();
leftX =3D Double.parseDouble(token.nextToken());
readString =3D inputFile.readLine();
token =3D new StringTokenizer(readString, "\n\r ");
token.nextToken();
lowY =3D Double.parseDouble(token.nextToken());
readString =3D inputFile.readLine();
token =3D new StringTokenizer(readString, "\n\r ");
token.nextToken();
Xspacing =3D Double.parseDouble(token.nextToken());
Yspacing =3D Xspacing;
inputFile.readLine();
rightX =3D leftX + (numCols-1) * Xspacing;
highY =3D lowY + (numRows-1) * Yspacing;
System.out.println(numCols);
System.out.println(numRows);
while ((readString=3DinputFile.readLine()) !=3D null)
{
dataOutput +=3D readString;
}
//System.out.println(dataOutput);
System.out.println(leftX + "\n" + lowY + "\n" + rightX + "\n" + =
highY);
datagrid =3D new double[numRows][numCols];
token =3D new StringTokenizer(dataOutput, "\n\r ");
for (int i =3D 0; i < numRows; i++)
{
for (int a =3D 0; a < numCols; a++)
{ =20
tempNum =3D token.nextToken();
//System.out.println(tempNum);
datagrid[i][a] =3D Double.parseDouble(tempNum);
//System.out.print(i + ", " + a + " ");
//System.out.println(datagrid[i][a]);
}
}
=20
}
catch (IOException e)
{
System.err.println("IO ERROR");
System.exit(0);
}
}
public static void writeFile()
{
//double Xspacing;
//double Yspacing;
double Xcord;
double Ycord;
//Xspacing =3D ((double) rightX - (double) leftX) / (numCols-1);
//Yspacing =3D ((double) highY - (double) lowY) / (numRows-1);=20
try
{
RandomAccessFile outputFile =3D new RandomAccessFile (outFile, =
"rw");
outputFile.writeBytes("X,Y,Z\r\n");
for (int i =3D (numRows-1); i >=3D 0; i--)
{
for (int a =3D 0; a < numCols; a++)
{=20
Xcord =3D leftX + (Xspacing * (double) a);
Ycord =3D highY - (Yspacing * (double) i);
outputFile.writeBytes( (new Double(Xcord)).toString() + ',' + =
(new Double (Ycord)).toString() + ',' + (new =
Double(datagrid[i][a])).toString() + '\r' + '\n');
}
}
}
catch (IOException e)
{
System.err.println("IO ERROR");
System.exit(0);
}
}
}
------_=_NextPart_000_01C458BB.ED6B0900
Content-Type: application/octet-stream;
name="Contour.class"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="Contour.class"
yv66vgAAAC4AmAoAMwBNCQAyAE4JADIATwoAMgBQCgAyAFEHAFIJAFMAVAgAVQoAVgBXCABYBwBZ
CABaCgALAFsIAFwKAAsAXQcAXggAXwoAEABbCgAQAGAKAGEAYgkAMgBjCQAyAGQKAFYAZQoALgBm
CQAyAGcJADIAaAkAMgBpCQAyAGoJADIAawkAMgBsBwBtCgAfAE0KAB8AbgoAHwBvCgAfAHAIAHEH
AEAJADIAcgcAcwkAUwB0CAB1CgBTAHYIAHcIAHgKAAsAeQcAegoALgB7CgAuAG8KAB8AfAcAfQcA
fgEABWxlZn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CzALYAtAC5ALUAAQBLAAAAAgBM
------_=_NextPart_000_01C458BB.ED6B0900--
More information about the MapServer-users
mailing list