Wednesday, 10 June 2015

Shapefile Naming conventions in ArcPy?


I have shapefile named `band-tailed_pigeon.shp which is fine and no problem on displaying or geoprocessing on Desktop but in ArcPy when I try to merge some layes to it I am getting this error


enter image description here



ExecuteError: ERROR 000354: The name contains invalid characters


Failed to execute (Merge).



I tried to do the proccess with a simple name like sample.shp which it works but I HAVE TO keep the same name as we are using them in several projects.


Here is the code which I have



FinaloutLocation = "E:\\GIS\\Data\\Final\\band-tailed_pigeon.shp"
inFeaturesToMerge = [dissolve_1, dissolve_2, dissolve_3, dissolve_4, dissolve_5]
arcpy.Merge_management(inFeaturesToMerge, FinaloutLocation)

Answer



The problem is with the dash (-) in the shapefile name. This restriction is from geoprocessing tool and not the shapefile name since you can have dashes in your shapefile name.


Some Geoprocessing methods allow you to validate table (feature class) and field names. Consider using either the ValidateTableName or ValidateFieldName function to ensure your names are valid


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...