4

My colleague has several hundred xyz files (*.xyz) and wants to make a DEM to use it in ArcMap. Files have three columns witohut first lane (variable names).

I suggested her:

  1. to add first line with x, y and z column names (i know just manual way)
  2. to convert xyz to dbf or similar
  3. to add it in arcmap (as add x y data)
  4. finally to use point to raster tool

I would probably know how to make a script for step 3 and 4, but i don't have any ideas how to solve step 1 and 2.

Or maybe there is an easier way (a tool,script) for direct conversion from xyz to dem?

2 Answers 2

8

This was my final solution. There are basicaly two tools that are needed to convert *.xyz to arcmap friendly raster format. You can use this script when adding a script tool to arcmap toolbox. Some parameters are set for my example (e.g. resolution is 5 m).

import arcpy
arcpy.CheckOutExtension("3D")

workspace=arcpy.GetParameterAsText(0)
arcpy.env.workspace = workspace

projection=arcpy.GetParameterAsText(1)

suffix = arcpy.GetParameterAsText(2)

xyz_list=arcpy.ListFiles()

for xyz in xyz_list:
    shape_name = str(xyz[:-4])+".shp"
    raster_name = str(xyz[:-4])+"."+str(suffix)
    arcpy.ASCII3DToFeatureClass_3d(xyz, "XYZ", shape_name, "POINT", "1", projection, "5", "","DECIMAL_POINT")
    arcpy.PointToRaster_conversion(shape_name, "Shape.Z", raster_name, "MEAN", "NONE", "5")
2
  • could you plz explain what is the meaning of "suffix = arcpy.GetParameterAsText(2)". thx Sep 30, 2015 at 7:48
  • the name of raster file is generated automatically form xyz file name. 'suffix' let's you to select (or better say write) file type (tif, img ...).
    – Rok
    Oct 1, 2015 at 13:05
2
  • concatenate all your xyz files together
  • use a csv2dbf converter, because your xyz file is a form of csv file. There are tons of those available by googling. I found python source code at https://github.com/fitnr/census2dbf/blob/master/census2dbf.py , which seems to be a generic csv2dbf python module, despite the name.
  • import this big dbf into arcgis

or

  • concatenate all your xyz files together
  • import directly to arcGIS using import xy data

edit: I assume by ".xyz file" you mean a simple ascii file of the following format (for x y and z values):

x1 y1 z1
x2 y2 z2
x3 y3 z3
x4 y4 z4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.