TransWikia.com

Exporting pandas dataframe as shapefile using ArcPy gives ERROR 000732

Geographic Information Systems Asked by JNN on June 28, 2021

I’m trying to export my dataframe as a CSV file and as a shapefile. I’m able to export it as a CSV but get the following error on the last line:

ERROR 000732: Input Features: Dataset in_memoryx37C54D46_4BEE_4D63_B0B5_7EF0B54FEE74x does not exist or is not supported
Failed to execute (FeatureClassToFeatureClass).

Any idea why it doesn’t recognize my dataframe?

Is there another way I can export it as a shapefile?

outDir = r"C:UsersTest"
now = datetime.datetime.now()
currentDate = str(now.month) + "_" + str(now.day) + "_" + str(now.year)
sdf = pd.DataFrame.spatial.from_featureclass(fc)

#Add fields to point
sdf['NADatum'] = 'WGS84'
sdf['Shape Type'] = 'Point'
sdf['Method'] = 'GPS'

#Pull only the necessary fields
sdf = sdf[['REPORTER','RECOWNER','SCINAME','COMNAME','RECBASIS','GlobalID','OCCSTATUS','MANAGESTAT','POPSTAT','OBSDATE','COUNTRY','STATE','COUNTY','PRIVATE','ESRIGNSS_LATITUDE','ESRIGNSS_LONGITUDE','NADatum','Method','Shape Type','ABUNDANCE','INFESTAREA','INFESTUNIT','PCTCOVER','VISITTYPE','COMMENTS']]

sdf.columns =['Reporter','ReportOwnershipID','ScientificName','CommonName','Recordbasis','UUID','OccurenceStatus','ManagementStatus','PopulationStatus','ObservationDate','Country','State','County','Private','Latitude_Decimal','Longitude_Decimal','NADatum','Method','ShapeType','Abundance','InfestedArea','InfestedAreaUnits','PercentCover','VisitType','Comments']
#Export point as CSV
outputCSV = os.path.join(outDir, "Points_" + currentDate + ".csv")
sdf.to_csv(outputCSV, index = False, header=True)
outFeatureClass = "Points_"
arcpy.FeatureClassToFeatureClass_conversion(sdf, outDir,outFeatureClass)

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP