Geographic Information Systems Asked on September 30, 2021
I have a point SHP in WGS84 (EPSG 4326) and I am trying to tabulate the distances to the nearest point in meters. I need to do the analysis using ArcPy, but I want to get the results in a Pandas dataframe to do other things.
I’m stuck on getting the GenerateNearTable_analysis()
in an in-memory format (throws the error below). And then from there, I actually don’t know how to pass it into a dataframe.
import arcpy
import pandas as pd
filein = [
r'D:mypathtest1.shp',
r'D:mypathtest2.shp',
]
for f in filein:
fout = f.replace(".shp", "")
TempTab = 'in_memory{}_Table'.format(fout)
arcpy.GenerateNearTable_analysis(f, f, TempTab, method='GEODESIC')
Above throws this error:
arcgisscripting.ExecuteError: ERROR 000210: Cannot create output in_memoryD:mypathtest_Table
Failed to execute (GenerateNearTable).
I also tried arcpy.GenerateNearTable_analysis(f, TempTab, "memory", method='GEODESIC')
as suggested in this answer, and got the following error: arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid. ERROR 000732: Near Features: Dataset 'in_memoryD:mypathtest_Table' does not exist or is not supported Failed to execute (GenerateNearTable).
Using ArcMap 10.7
You need to get rid of the directory as well as the file extension.
import os
import arcpy
import pandas as pd
filein = [
r'D:mypathtest1.shp',
r'D:mypathtest2.shp',
]
for f in filein:
fout = os.path.splitext(os.path.basename(f))[0] #<=== strip file extension and path
TempTab = 'in_memory{}_Table'.format(fout)
arcpy.GenerateNearTable_analysis(f, f, TempTab, method='GEODESIC')
Correct answer by user2856 on September 30, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP