Created
November 28, 2017 22:10
-
-
Save mpayson/471516f8a103eba05287402226473bd1 to your computer and use it in GitHub Desktop.
[ArcGIS Python API] Add a field to a feature service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from arcgis.gis import * | |
from arcgis.features import FeatureLayer | |
gis = GIS("https://www.arcgis.com", "<UN>", "<PW>") #for AGOL, also can do Portal URL | |
fl_url = "<URL>" | |
fl = FeatureLayer(fl_url, gis) | |
# about field types http://pro.arcgis.com/en/pro-app/tool-reference/data-management/add-field.htm | |
# rest endpoint http://resources.arcgis.com/en/help/arcgis-rest-api/#/Add_to_Definition_Feature_Layer/02r300000228000000/ | |
new_field = { | |
"name": "TEST_STR_FIELD", | |
"type": "esriFieldTypeString", | |
"alias": "TEST_STR_FIELD", | |
"length": 256, | |
"nullable": True, | |
"editable": True, | |
"visible": True, | |
"domain": None | |
} | |
update_dict = {"fields": [new_field]} | |
fl.manager.add_to_definition(update_dict) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The REST API endpoint link is out of date. Current link is https://developers.arcgis.com/rest/services-reference/online/add-to-definition-feature-layer-.htm