0

This question already has an answer here:

I have lots of .txt files (point cloud) which are raw data acquired from from LIDAR and containing XYZI values. I want to convert them to shapefile.

Is there a way I can do that instead of adding XY data first and exporting to shapefile one after the other?

marked as duplicate by Andre Silva, Hornbydd, BERA, whyzar, Vince Jun 7 '18 at 15:00

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Please Edit the question to define what you mean by "point file". There are a number of ways to do this, but most require more familiarity with Python than your question suggests. – Vince Aug 9 '17 at 10:48
  • That doesn't make much sense -- a DEM is a raster model, which really ought not be stored in a vector format like shapefile without a great deal of processing. – Vince Aug 9 '17 at 10:59
  • It's the raw data acquired from from LIDAR containing XYZI . I need to carry out some processes to generate the raster – lloyd Aug 9 '17 at 11:01
  • are you familiar with python (arcpy)? this process could be automated easily through the use of a script tool i.e. – dru87 Aug 9 '17 at 11:03
  • 1
    Can you post a screenshot of the .txt file you are working with so we can get a better feel for the dataset? – Map Man Aug 9 '17 at 14:42
1
import arcpy

newfcName ="532724.shp"
outpath = r"C:/FLOOD/IKEJA AND KOSOFE"

# Declaration
arcpy.env.overwriteOutput=True
arcpy.env.workspace= outpath


# Create new Shapefile and add FIELDS
newfc = arcpy.CreateFeatureclass_management(outpath, newfcName, "Point")
arcpy.AddField_management(newfc, "X", "STRING", field_length = 50)
arcpy.AddField_management(newfc, "Y", "STRING", field_length = 50)
arcpy.AddField_management(newfc, "Z", "STRING", field_length = 50)
arcpy.AddField_management(newfc, "I", "FLOAT", field_length = 50)

# Reference Cursors
cursor=arcpy.da.InsertCursor(newfc, [ "SHAPE@XY", "X", "Y", "Z", "I"])

# Read File 
a = open("C:/FLOOD/IKEJA AND KOSOFE/DEM/532724.txt","r")
inputF = a.readlines()

for line in inputF:
xCoordinate, yCoordinate, zValue, iValue = line.split(" ")
xy = (float(xCoordinate), float(yCoordinate))
newRow = (xy, str(xCoordinate), str(yCoordinate), str(zValue), float(iValue))
cursor.insertRow(newRow)

a.close()
infc = r"C:/FLOOD/IKEJA AND KOSOFE/532724.shp"
sr = arcpy.SpatialReference("Minna UTM Zone 31N")
arcpy.DefineProjection_management(infc, sr)

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