阅读:1904回复:3
如何编程实现Raster to ASCII?
<P>如主题,在ARCMAP里面提供了toolbox可以直接实现Raster to ASCII,我现在需要在AE中实现,如何实现呢?需要各位的帮忙啊,谢谢~</P>
|
|
1楼#
发布于:2005-10-14 12:01
<P>下面是一个程序,不过数据很大的时候,会比较慢</P>
<P>程序可以:转换 raster (GRID or image) 到 ASCII delimited text file of X,Y, and Z values</P> <P><a href="attachment/2005-10/200510141201798837.rar">2005-10/200510141201798837.rar</a><BR></P> |
|
|
2楼#
发布于:2005-10-14 12:03
<P>另外有个别人写的,听说p4上速度可达到10000个/second,</P><PRE>#
# Asc2XYZ.AWK # Convert an ESRI ASCII grid to an XYZ Ascii format. # # Quantitative Decisions, Merion Station, PA. # # 10 Jan 2000 # 5 Jan 2004: Modified to handle long lines. Status() implemented. # No error checking. # Assumes the header portion contains a "nodata_value" record at its end. # Example of header: # #ncols 480 #nrows 450 #xllcorner 378923 #yllcorner 4072345 #cellsize 30 #nodata_value -32768 #---------------------------------------------------------------------------------------------# BEGIN { N = -1 # Index of the current data item (will start with 0). if (ARGC <= 1) { print "ASC2XYZ v. 1.0, 5 Jan 2004, by Quantitative Decisions." >> "/dev/tty" print "Converts ESRI ASCII grid files to XYZ ASCII formats." >> "/dev/tty" print "Usage: ASC2XYZ [name of input file] > [name of output file]" >> "/dev/tty" exit } FALSE = 0 TRUE = !FALSE OFS = "\t" # Output delimiter print "X", "Y", "Z" nDisplayIncrement = 1000 nDisplayLimit = 1000 InData = FALSE } #---------------------------------------------------------------------------------------------# # # Process the data. # InData ;; $0 !~ /^[ \t]*$/ { # We need to skip the last line, which is blank for (i=1; i<=NF; i++) { IRow = int((N+i)/ncols) JCol = N+i - IRow*ncols X = xllcorner + cellsize*(JCol+0.5) Y = yllcorner + cellsize*(nrows-0.5-IRow) Z = $i print X, Y, Z } N+=NF if (N >= nDisplayLimit) { Status(N+1); nDisplayLimit = N+nDisplayIncrement } next } # # Read the header. # {$1 = tolower($1)} $1 == "ncols" {ncols = $2+0; next} $1 == "nrows" {nrows = $2+0; next} $1 == "xllcorner" {xllcorner = $2+0; next} $1 == "yllcorner" {yllcorner = $2+0; next} $1 == "cellsize" {cellsize = $2+0; next} $1 == "nodata_value" {nodata = $2+0 printf("Rows: %9d\nCols: %9d\n", nrows, ncols) >> "/dev/tty" RS = " " # Treat each field as a record, to avoid limit on NF InData = TRUE } #---------------------------------------------------------------------------------------------# END { if (N >= 0) { Status(N+1) print "\nDone." >> "/dev/tty" } } #---------------------------------------------------------------------------------------------# function Status(n) { printf("\r%9d cells", n) >> "/dev/tty" } # Status() ### end of file ###</PRE> |
|
|
3楼#
发布于:2005-10-14 12:51
对我来说,真的非常有用,谢谢gis!<img src="images/post/smile/dvbbs/em02.gif" />
|
|