Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to add a field to a layer file, but it always gives an error. What I did was making a closest facility layer and save the result as a layer and after that I tried to add a field, but then it gives an error. It says it cannot add a field if it isn't a raster layer, ...

I tried to avoid this by making a shapefile (manually) and this can work, but is there a method to do this in Python? So convert a route from the closest facility layer to a shapefile using Python? It always says:

ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000840: The value is not a Feature Layer.

share|improve this question
You may want to post your actual Python code to help us better troubleshoot your problem. – Baltok Apr 4 '13 at 13:39
Did you really try to Add Field to a layer file rather than a layer or dataset? If so, that would explain the error message. – PolyGeo Apr 7 '13 at 12:46
up vote 1 down vote accepted

You might need to add the ValidateFieldName function to your script, which will replace invalid characters with an underscore, and ensure the suggested new field name does not already exist. The code below should get you started:

import arcpy  
fc = "C:/Data/NameOfData.shp" 
fieldname = arcpy.ValidateFieldName("NewFieldName") 
arcpy.AddField_management(fc, fieldname, "TEXT", "","", 12)
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.