sing ArcGIS 10.2 for Desktop, I have some Shapefiles which I have no idea why their Geometry column (shape) contain ZM! now I need to remove all those ZM
and get a clean polygon instead.
I thought I can use the FeatureClassToShapefile_conversion()
but not sure how to disabled
both Output has Z Values
and Output has M Values
through following ArcPy
# Import system modules
import arcpy from arcpy import env
# Set environment settings env.workspace = "C:/data"
# Set local variables
inFeature = ["climate.shp"] outLocation = "C:/output"
arcpy.FeatureClassToShapefile_conversion(inFeatures, outLocation)
Solved! Go to Solution.
Your parameters for arcpy.FeatureClassToFeatureClass are incorrect. Your are providing two parameters but you need at least three. Please take a look at
This will work:
import arcpy from arcpy import env env.workspace = "E:\\GIS\\Data" inFeature = "band-tailed_pigeon.shp" outFeature = "band-tailed_pigeon-NOZM.shp" env.outputZFlag = "DISABLED" env.outputMFlag = "DISABLED" arcpy.FeatureClassToFeatureClass_conversion(inFeature, env.workspace, outFeature)
or as an alternative you can use arcpy.CopyFeatures_management.
Your input "climate.shp" is a shapefile not a feature class (a dataset inside a geodatabase).
I would recommend that you actually get all of your data into geodatabases first.
Use arcpy.FeatureClassToFeatureClass_conversion or arcpy.CopyFeatures_management to copy the input to the output and disable Z & M geometries using the flags available in environment settings:
See here :
ArcGIS Help (10.2, 10.2.1, and 10.2.2)
ArcGIS Help (10.2, 10.2.1, and 10.2.2)
So your code might look like this :
import arcpy from arcpy import env env.workspace = "c:/Data/AGeodatabase.gdb" inFeature = "climate" outFeature = "climate2" env.outputZFlag = "Disabled" env.outputMFlag = "Disabled" arcpy.FeatureClassToFeatureClass_conversion(inFeature, outFeature)
Thanks Neil but I have every thing in `.shp` and not `gdb` format. In that case how I can set the env workspace?
I mean In case of having the original file in directory "C:\\GIS\\ROR" and if I want to save the output in "D:\\Data\\Final\\" Do I have to set two env.workspace for both input and out puts?
I tried both this methods
import arcpy
from arcpy import env
env.workspace = "E:\\GIS\\Data"
inFeature = "band-tailed_pigeon.shp"
outFeature = "E:\\GIS\\Data\\band-tailed_pigeon-NOZM.shp"
env.outputZFlag = "Disabled"
env.outputMFlag = "Disabled"
arcpy.FeatureClassToFeatureClass_conversion(inFeature, outFeature)
import arcpy
from arcpy import env
env.workspace = "E:\\GIS\\Data"
inFeature = "band-tailed_pigeon.shp"
outFeature = "band-tailed_pigeon-NOZM.shp"
env.outputZFlag = "Disabled"
env.outputMFlag = "Disabled"
arcpy.FeatureClassToFeatureClass_conversion(inFeature, outFeature)
but I am getting this error in both case
FeatureClassToFeatureClass C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\conversion.py 1675 ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000732: Output Location: Dataset E:\GIS\Data\band-tailed_pigeon-NOZM.shp does not exist or is not supported
ERROR 000735: Output Feature Class: Value is required
Failed to execute (FeatureClassToFeatureClass).
Can you please let me know what I am doing wrong?
Re: your code above, the following will work to copy the shape, but not sure if it will do anything for your original question about removing the Z and M. You can use FeatureClassToShapefile of the FeatureClassToFeatureClass, but I remove the dashes and replaced with _ for the output of the FC2FC version.
import arcpy from arcpy import env theWorkspace = r"D:\Data\Final" env.workspace = theWorkspace env.overwriteOutput inFeature = r"c:\GIS\ROR\"band-tailed_pigeon.shp" outFeature = "band_tailed_pigeon_NOZM.shp" #either of the next two will work to copy to new location... #not sure if it will do anything for you ZM question #arcpy.FeatureClassToShapefile_conversion(inFeature, theWorkspace) arcpy.FeatureClassToFeatureClass_conversion(inFeature, theWorkspace, outFeature)
Your parameters for arcpy.FeatureClassToFeatureClass are incorrect. Your are providing two parameters but you need at least three. Please take a look at
This will work:
import arcpy from arcpy import env env.workspace = "E:\\GIS\\Data" inFeature = "band-tailed_pigeon.shp" outFeature = "band-tailed_pigeon-NOZM.shp" env.outputZFlag = "DISABLED" env.outputMFlag = "DISABLED" arcpy.FeatureClassToFeatureClass_conversion(inFeature, env.workspace, outFeature)
or as an alternative you can use arcpy.CopyFeatures_management.