Select to view content in your preferred language

Controlling Field Data Types When Creating a Feature Service From a GeoJSON

380
1
08-27-2024 11:04 AM
mikeytes
Emerging Contributor

This question is in regards to both using the ArcGIS Portal GUI and the ArcGIS API for Python.

I'm able to create a hosted feature service from a GeoJSON, but I'm unable to create esriFieldTypeDate fields. All date formats in the geojson properties lead to esriFieldTypeString field types. I don't have this issue when publishing from a csv.

I understand that I can delete the fields and add new ones in. But it would help our workflow to immediately declare the field type.

Here's what I do programmatically...

layer.manager.delete_from_definition({
"fields": [{"name": "created_at"}]
})

layer.manager.add_to_definition({
"fields": [{
"name": "created_at",
"type": "esriFieldTypeDate",
"alias": "Created At"]

Just wondering if this is a bug when working with geojsons or if I'm not formatting my dates correctly.

0 Kudos
1 Reply
eabrahams_tesla
New Contributor

I am encountering the same problem, so I appreciate the workaround you included.

That said, I agree that date fields should be typed correctly when the layer is initially published. In my case, I made sure the dates were formatted as Esri expects: https://doc.arcgis.com/en/arcgis-online/manage-data/work-with-date-fields.htm, but they were still interpreted as strings.

0 Kudos