Select to view content in your preferred language

Issue with attribute types when publishing GeoJSON to ArcGIS Online

07-13-2023 06:28 AM
Labels (2)
New Contributor III


I'm trying to publish a GeoJSON file containing lines and points to ArcGIS Online. The publication process is successful, resulting in a Feature Layer with two layers - point and line. Everything looks fine, except that all attributes are automatically converted to the "string" type. I've attempted to modify the attribute types using the following code, but I haven't achieved the desired outcome. The attributes still remain as "string" instead of the intended "date" type.

# Name of the layer you want to load
layer_name = "Test GeoJSON File"

# Retrieve the Feature Layer through search
layer =, item_type="Feature Layer")[0]

# Get the Feature Layer object
feature_layer = layer.layers[0]

# Retrieve information about the attribute table of the Feature Layer
attributes =['fields']

# Define new attribute types to be used
new_types = {
    "realizace_do": "esriFieldTypeDate",
    # Continue with other attributes you want to modify

# Update the attribute types in the attribute table of the Feature Layer
for attribute in attributes:
    attribute_name = attribute['name']
    if attribute_name in new_types:
        attribute_type = new_types[attribute_name]
        attribute['type'] = attribute_type

feature_layer.manager.update_definition({'fields': attributes})
Tags (3)
0 Kudos
0 Replies