0

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 = gis_agol.content.search(query=layer_name, 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 = feature_layer.properties['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})

1 Answer 1

0

You should format the datetime string according to the https://doc.arcgis.com/en/arcgis-online/manage-data/add-or-delete-fields.htm standard.

For example, 2023-10-10T15:03:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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