Select to view content in your preferred language

Bathymetry .xyz data to raster

10929
3
08-14-2012 03:54 AM
JoshuaCoates
Deactivated User
I received some bathymetry data in .xyz format and am trying to figure out how to convert it to a DEM or raster of some sort. I need to generate some bathymetry profile graphs for a client. When I opened the text file to view the data, it is just one field with x,y,z data all together. The x,y data is in State Plane and the Z data is in NAVD88. The file is rather large (13.2mb) and when I tried to copy and paste the data into Excel to try and separate the data into separate fields, I received an error that not all of the data was copied (which I assume is because the file is too large?) Can anyone let me know how to convert this file into a raster?
Tags (1)
0 Kudos
3 Replies
EricRice
Esri Regular Contributor
Hi Joshua,

Have you tried the ASCII 3D to Feature Class tool?  This will get you points that you can convert to raster or use to interpolate a raster.

Best,
Eric
0 Kudos
JakubSisak
Honored Contributor
There is an old 9.1 script available here: http://arcscripts.esri.com/details.asp?dbid=12876
There are also numerous discussions on this topic in the old forums.

I used to used the tool often a few years ago for all of my LiDAR and bathymetry XYZ to ASCII Grid conversions and it worked well.  I also used it only a few weeks ago with version 10.0 to convert extremely large Lidar Full Feature XYZ files to ASCII grid raster files and it worked just fine.  It did through an error when attempting to convert ASCCI Grid files to ESRI Grid but that step is not needed since ArcGIS displays ASCII grid raster files natively. I have never tried running the slope and contours operations (the tool has options for those) because those steps can be easily done with the Spatial Analyst.
0 Kudos
RaphaelR
Deactivated User
I recently had do something similar, convert rather large xyz files (up to 1.2GB) to rasters. Since the old script never really worked for me, i tried something with python/numpy. Making things a bit more complicated was the fact that in the xyz file records with no-data were simply omitted.

import numpy as np
import arcpy

# Inputs
xyzfile = "e:/file.xyz"
outname = "e:/raster.asc"
skiprows = 1
delimiter = ","

ncols = 5974
nrows = 5505
xllcorner = 682000
yllcorner = 205000
cellsize = 1.0
nodataval = -9999

zgrid = np.zeros((nrows,ncols), dtype=np.float32)
zgrid.fill(nodataval)

# process the xyz file
with open(xyzfile) as f:
        
        # if header found in xyz file, skip line 1
        if skiprows == 1: 
            next(f)
            
        # put all available xyz values into correct positions on the zeros grid, 
        # all other positions keep the nodatavalue    
        for line in f:
                
            item = line.rstrip().split(delimiter)
            #print item 
            idx = (float(item[0])-xllcorner) / cellsize
            idy = (float(item[1])-yllcorner) / cellsize
            
            zgrid[idy,idx] = item[2]

# write the header and grid to an ascii file
with open(outname, "w") as outfile:
            
        # write ascii raster header
        outfile.write("ncols " + str(int(ncols))+ "\n")
        outfile.write("nrows " + str(int(nrows))+ "\n")
        outfile.write("xllcorner " + str(xllcorner) + "\n")
        outfile.write("yllcorner " + str(yllcorner) + "\n")
        outfile.write("cellsize " + str(cellsize) + "\n")
        outfile.write("nodata " + str("%.2f" % float(nodataval)) + "\n" + "\n")
        
        # write grid to outfile
        np.savetxt(outfile,zgrid[::-1], fmt="%.2f", delimiter= " ")
0 Kudos