Feature Class to Feature Class in ArcGIS Pro

387
6
Jump to solution
02-11-2019 02:49 PM
HectorNavarro
New Contributor III

Good day everyone.  I am running this code in ArcPro and receive the following error:

It tells me that my input feature does not exist or is not supported.  I have ran this script in python 2.7 and it all works fine.  Thank all of you in advance.

#Import ArcPy modules
import arcpy
from arcpy import env

# Set the workspace
arcpy.env.workspace = "Database Connections/ADMIN Edit.sde/CustomerServiceFeatures"
ArcSDE = arcpy.env.workspace
env.overwriteOutput = True

# Set local variables
inFeatures = "GPS_Meter_CustomerServiceFieldCrew"
outputLocation = "X:/Planning/GIS/Meter GPS/GPS Meter Collection/Customer Service/GPS CC&B Joins"
outputFolderName = "00_00_19"
outputFolderLocation = "X:/Planning/GIS/Meter GPS/GPS Meter Collection/Customer Service/GPS CC&B Joins/00_00_19"
outputDatabase = "CC&B iPad Meters.gdb"
outputDatabaseLocation = "X:/Planning/GIS/Meter GPS/GPS Meter Collection/Customer Service/GPS CC&B Joins/00_00_19/CC&B iPad Meters.gdb"
outputFeatureClass = "GPS_Meter_CS"
expression = "SERVICEPOINTID IS NULL"

# Create folder
## UPDATE outputFolderName, outputFolderLocation, AND outputDatabaseLocation
## VARIABLE EVERYTIME THIS PROCESS RUNS WITH CURRENT DATE (MM_DD_YY).
print("Creating folder.")
arcpy.CreateFolder_management(outputLocation, outputFolderName)

# Create new .gdb
print("Creating geodatabase.")
arcpy.CreateFileGDB_management(outputFolderLocation, outputDatabase)

# Allow database to accept attachments.
print('Allowing attachments')
arcpy.env.maintainAttachments = True

# Export feature class geodatabase
print("Exporting feature class to feature class")
arcpy.FeatureClassToFeatureClass_conversion(inFeatures, outputDatabaseLocation, outputFeatureClass, expression)

# Finish
print("Done")‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos
1 Solution

Accepted Solutions
CCWeedcontrol
Regular Contributor

It could have to do with your your workspace. Pro doesn't like the database connection links from what i gather.

You have to use C:\\Users\\***\\AppData\\Roaming\\Esri\\ArcGISPro\\Favorites\\**sde database**\\**Featuredataset**\\**feature class**. In Pro contents window navigate to the feature class then open Pro paython window drag the feature class to the very bottom python window and that should give you the path and use that for your layer paths.

Aslo you need to use the following below to set paths.

Python treats a backslash (\) as an escape character. I know it worked in 2.7 but not in 3.6 at least that what i have found.

"c:/temp/streams.shp
"c:\\temp\\streams.gdb"
"r"c:\temp\

View solution in original post

0 Kudos
6 Replies
CCWeedcontrol
Regular Contributor

It could have to do with your your workspace. Pro doesn't like the database connection links from what i gather.

You have to use C:\\Users\\***\\AppData\\Roaming\\Esri\\ArcGISPro\\Favorites\\**sde database**\\**Featuredataset**\\**feature class**. In Pro contents window navigate to the feature class then open Pro paython window drag the feature class to the very bottom python window and that should give you the path and use that for your layer paths.

Aslo you need to use the following below to set paths.

Python treats a backslash (\) as an escape character. I know it worked in 2.7 but not in 3.6 at least that what i have found.

"c:/temp/streams.shp
"c:\\temp\\streams.gdb"
"r"c:\temp\

View solution in original post

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

Your last example should be

r"c:\temp\"

don't enclose the r in quotes, r precedes the first quote, whether single or double

HectorNavarro
New Contributor III

Thank you all for your help and input.

0 Kudos
KrishanPareek
New Contributor III

Hey everyone, whenever I am trying to convert one feature class to another feature class I am getting an error (showed in image).Is it because of Chinese character that is not valid or what. I am bit new to these need help!!!

Thanks in advance

0 Kudos
HectorNavarro
New Contributor III

Krishan,

Try removing the space in your output feature class. Instead of "bridge location" try "bridgelocation" or "bridge_location".  Hope this helps.

KrishanPareek
New Contributor III

Thanks Hector, your solution works..

0 Kudos