1

Using the Make XY Event Layer tool I converted a table to a layer.

I am trying to convert the newly created layer to a feature class in my file geodatabase.

I have been able to do this in ModelBuilder but when I exported the model to a script and ran that it failed to complete - see Export as Python script from ModelBuilder never completes?.

When run from its tool dialog it makes no progress and does not give an error (while in ModelBuilder it takes about 7.5 seconds for it to run).

I tried to convert the layer to a shapefile with ConversionTools>ToShapefile and get the same result.

Finally I right clicked the layer I created with MakeXYEventLayer and performed Date>ExportData>Exported it to my file geodatabase and it worked.

How do I get this to work via the tool dialog (so that it will then work in the Python script)?

  • Interesting, for a start you can skip ', "", "0", "0", "0"' in copyfeatures, if they're not populated just leave them out, if that doesn't work you could create the feature class manually and Append the events or Select, or Feature class to shapefile.. there's a few ways. Did you get an error message? – Michael Stimson Mar 4 '15 at 23:13
  • I removed the ', "", "0", "0", "0"' and get the same results I'm looking for a solution that allows me to automate this work flow. – risail Mar 4 '15 at 23:18
  • There are a few options to go from a layer to a feature class, for this one wells has no extension, you could try putting '.shp' on the end of it.. but it would help if there was an error message to see why it's failing, in these cases the problem is most likely in the CSV and not the tool.. Try FeatureClassToShapefile resources.arcgis.com/en/help/main/10.2/index.html#/… or Select resources.arcgis.com/en/help/main/10.2/index.html#//… with no query. – Michael Stimson Mar 4 '15 at 23:22
  • This looks like a duplicate of gis.stackexchange.com/questions/137712/… - I think for this not to be a duplicate it needs to be edited to focus on just running the two steps from their tool dialogs as suggested (perhaps not clearly enough) in a comment on its earlier incarnation. – PolyGeo Mar 4 '15 at 23:26
  • 1
    @MichaelMiles-Stimson I've edited the question to try and separate the problem of the tool not completing from its dialog from the tool not completing from within a script. The former will be what causes the latter so I'm trying to help the asker by teasing the source of the problem out from where its manifestation was first observed. I'm not sure if you were aware of the earlier Q&A. – PolyGeo Mar 4 '15 at 23:43
1

There has to be a problem with the CSV file.

Possibilities include (but are not limited to):

  • Spaces and/or non-alphanumeric characters in field names, or starting with underscore.
  • Bad data in cells. Esri only reads the first few lines to decide the data type, if the first dozen or so are numbers it calls the field integer, if there's later a value like 'N/A' in the field then it has a spit!
  • Duplicated field names, when shortened to 10 characters.
  • 'reserved' field names: FID, SHAPE etc..
  • Permission denied by OS

I have tested this on a table:

x,y,z,h,r,p,t
152.75815,-28.34317,2467.171222,204.403864,-0.215472,-4.31432,540751.6635
152.758058,-28.343492,2467.048023,204.305248,-2.287749,-4.916747,540752.2636
152.757997,-28.343707,2466.870526,204.225232,-3.082666,-5.08145,540752.6637
152.757951,-28.343868,2466.693121,204.137175,-3.269405,-5.160663,540752.9637
152.757921,-28.343976,2466.551302,204.07381,-3.172274,-5.225498,540753.1638
152.757891,-28.344084,2466.390267,204.015868,-2.910663,-5.244445,540753.3638
152.757847,-28.344247,2466.137704,203.965636,-2.264,-5.294325,540753.6639
152.757772,-28.344518,2465.655387,203.89813,-1.057936,-5.344787,540754.164
152.757699,-28.34479,2465.164517,203.946887,-0.757532,-5.433305,540754.6641
152.757639,-28.345007,2464.784946,203.900885,-0.882926,-5.508097,540755.0642
152.75755,-28.345335,2464.12202,203.710554,-1.899527,-5.6251,540755.6643

with the code:

import arcpy
inCSV=r'D:\some\path\OneRun_with_Header.csv'
outShp = r'D:\some\path\test'
arcpy.MakeXYEventLayer_management(inCSV,"x","y","Lyr")
arcpy.CopyFeatures_management("Lyr",outShp)

and it works just fine. Have a closer look at your tabular data, there's bound to be a problem there. I did notice on your previous post:

arcpy.MakeXYEventLayer_management(Wells_csv, "Surface_Longitude", "Surface_Longitude", Wells_Layer,

has "Surface_Longitude" for X and Y - this doesn't affect the tool too much but you'll end up with all your features on a 45degree slope with the same X and Y.

  • I thought the same thing except it creates a layer and works in model builder and it works with right clicking export...the csv is good – risail Mar 5 '15 at 1:08
  • you're absolutely sure of that? There's nothing that's been 'fixed' in the layers by those other tools that you haven't checked? You've also changed the duplication of the X field? I feel that there are some field names that, when shortened to the max length of the shape file fields, are identical. What field names do you have in the CSV? – Michael Stimson Mar 5 '15 at 1:14
  • Yes..My headers are API,Well_Name,Well_Suf,Op_Num,Btm_Fld,Spd_Dt,Btm_Ls_Num,RKB_Elv,BH_Total,Tr_Vrt_Dp,Srf_N_S_Ds,Srf_N_S_Cd,Srf_E_W_Ds,Srf_E_W_Cd,Srf_Area,Srf_Blk,Btm_N_S_Ds,Btm_N_S_Cd,Btm_E_W_Ds,Bt_E_W_Cd,Btm_Area,Btm_Blk,Ttl_Dp_Dt,St_Dt,Type_Code,Distr_Code,Stat_Code,Wtr_Dpth,Surf_Lon,Surf_Lat,Btm_Lon,Btm_Lat,Surf_Lse,Cmplx_ID,Strut_Num – risail Mar 5 '15 at 14:45
  • Where's surface_lonitude (and presumably surface_latitude)? It seems to me that your fields don't exist hence your error. In this table it's surf_Lat and surf_Lon. – Michael Stimson Mar 5 '15 at 21:30
  • Surf_Lon,Surf_Lat I modified it slightly. I spoke with ESRI tech support and they had me disable the Background Processing under Geoprocessing Options and it now works manually but they are still unsure why the script is not working (yes, I tried copying the python snippets), the problem is not in the CSV – risail Mar 5 '15 at 21:34

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.