RuntimeError: Object: Error in executing tool (in XYTableToPoint)

3354
5
Jump to solution
03-21-2021 09:21 PM
NabilaChaudhry
New Contributor

This is the code I write and it gives me following error. 

# reading the csv file containing wildfire data
fires_dataset=pd.read_csv(r'D:/UCALGARY/urbanGIS/lab4/lab4data/fires_data.csv',encoding='mac_roman')

# specify the location you want the store your point features after running the XY to Point tool.
fire_data_output = r'D:/UCALGARY/urban GIS/lab4/lab4ugis/lab4ugis.aprx'

fires_data = arcpy.management.XYTableToPoint(fires_dataset,fire_data_output, 'fire_location_longitude', 'fire_location_latitude')

Error

RuntimeError                              Traceback (most recent call last)
In  [7]:
Line 9:     fires_data = arcpy.management.XYTableToPoint(fires_dataset,fire_data_output, 'fire_location_longitude', 'fire_location_latitude')

File c:\program files\arcgis\pro\Resources\arcpy\arcpy\management.py, in XYTableToPoint:
Line 4151:  raise e

File c:\program files\arcgis\pro\Resources\arcpy\arcpy\management.py, in XYTableToPoint:
Line 4148:  retval = convertArcObjectToPythonObject(gp.XYTableToPoint_management(*gp_fixargs((in_table, out_feature_class, x_field, y_field, z_field, coordinate_system), True)))

File c:\program files\arcgis\pro\Resources\arcpy\arcpy\geoprocessing\_base.py, in <lambda>:
Line 511:   return lambda *args: val(*gp_fixargs(args, True))

RuntimeError: Object: Error in executing tool

 

0 Kudos
1 Solution

Accepted Solutions
DavidPike
MVP Notable Contributor

I don't think a pandas dataframe is an allowed input.  I would just reference the path to the csv in arcpy.management.XYTableToPoint and do away with any pandas.

View solution in original post

5 Replies
Luke_Pinner
MVP Regular Contributor

You need to pass a feature class not an ArcGIS Pro aprx file as the output.

 

0 Kudos
mody_buchbinder
Frequent Contributor

Hi

The second parameter should be a new feature class name (something like r'D:\temp\abc.gdb\fc') and not an aprx.

 

Have fun

Mody

0 Kudos
NabilaChaudhry
New Contributor

Hi, I did try what you said but it is giving me the same error. 

0 Kudos
DavidPike
MVP Notable Contributor

I don't think a pandas dataframe is an allowed input.  I would just reference the path to the csv in arcpy.management.XYTableToPoint and do away with any pandas.

LReis
by
New Contributor

For anyone else who has run into this error (and this page) and wants to go between a pandas dataframe and feature class, I was able to use arcpy.management.XYTableToPoint for this. The trick is you first need to import the GeoAccessor with the following code (I don't know if the GeoSeriesAccessor is strictly necessary, but I've usually seen them together):

from arcgis.features import GeoAccessor, GeoSeriesAccessor

If you need to do some spatial operations first, you can use pd.DataFrame.spatial.from_xy (Esri example here) and then df.spatial.to_featureclass (with your own dataframe variable as the first part) to move the final dataframe to a database.

I agree with this response that using arcpy.management.XYTableToPoint and pointing to the csv is better in the original situation, but perhaps this information will be useful to others who run into the same error.

0 Kudos