1

I am trying to convert XYZ-data to a point feature class. I've done this successfully in ArcMap, however, when I copy the python snippet, I get a RuntimeError.

I did make some minor changes to make the code more readable, and to loop through a series of files. Anyway, the same problems arose when I used the original python snippet.

This is my code - for the sake of brevity I have replaced some of the long path names by variables:

import os                    # enables interaction with operating system
import arcpy                 # enables use of tools within the arcpy package
arcpy.CheckOutExtension('3D')

RDnew = "PROJCS['RD_New',GEOGCS['GCS_Amersfoort',DATUM['D_Amersfoort',SPHEROID['Bessel_1841',6377397.155,299.1528128]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Double_Stereographic'],PARAMETER['False_Easting',155000.0],PARAMETER['False_Northing',463000.0],PARAMETER['Central_Meridian',5.38763888888889],PARAMETER['Scale_Factor',0.9999079],PARAMETER['Latitude_Of_Origin',52.15616055555555],UNIT['Meter',1.0]]","#","#","DECIMAL_POINT"
#this is just the coordinate system copied from the python snippet to make it more readible.

for fn in os.listdir('.'):
    if (fn[-4:] == '.pts' or fn[-4:] == '.txt'):
        print fn + ' is processing.'
        print 'Converting XYZ-data to point feature class.'
        pts_shp = fn[0:7] + '.shp'      # using fn[0:7] to get rid of the .pts or .txt extension of the input file
        arcpy.ASCII3DToFeatureClass_3d(fn,'XYZ','shp_points/' + pts_shp,'POINT','1',RDnew,"#","#","DECIMAL_POINT")

This last line is where I get the error.

I had some errors before (among which the infamous Error 999999, which I managed to get rid off. and 'failed to execute function', which has also been solved), but I don't see what else is wrong with my code here.

Could anyone help me out and explain to me what is going wrong?

I already checked for spaces and dots in the paths and file names. My best guess would be the input or output path, but I don't see the problem.

2

Check your RDNew string. The extra double quotes around the # may be throwing things off. If they're meant to be in the string escape them with a backslash.

If looks like the variable has the extra ,"#","#","DECIMAL_POINT" in it from the parameters in your arcpy.ASCII3DToFeatureClass_3d call.

  • YES!!! Changing the double quotes around the # into single quotes worked! Even though the "#" were copied directly from the snippet. Thanks a lot. Out of curiosity: what do you mean by 'escape them with a backslash'? – Renée Sep 18 '15 at 17:52
  • 1
    Look at learnpythonthehardway.org/book/ex10.html and docs.python.org/2.0/ref/strings.html. Basically, there are characters that tell the language parser to ignore characters that follow. So a backslash would ignore the " and not break the string. – Branco Sep 18 '15 at 18:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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