Select to view content in your preferred language

Field Mapping parameter in geoanalytics append_data

1667
6
Jump to solution
02-05-2021 11:06 PM
AriMatiur
Emerging Contributor

I try to append two feature layers in my ArcGIS portal. I'm using arcgis.geoanalytics module to do this. I manage to append these layers without using field mapping, I only pass the input layer and append layer parameter. However, I can't append these layers if I'm using field_mapping parameter. I have read this documentation  but there is no example of field_mapping script. https://developers.arcgis.com/python/api-reference/arcgis.geoanalytics.manage_data.html#append-data 

AriMatiur_0-1612594964270.png

Maybe some example of field_mapping parameter would help me. Thank you! 

0 Kudos
1 Solution

Accepted Solutions
SarahAmbrose
Esri Contributor

Hi @AriMatiur,

The REST API documentation for the tool outlines the field mapping parameters here.  Here is an example:

[
{ "inputLayerField": "Mean_Scales", "mappingType": "AppendField", "mappingValue": "Average_Scales" },
{ "inputLayerField": "Bonus", "mappingType": "Expression", "mappingValue": "$feature['WeeklyRate'] * 1.5" },
{ "inputLayerField": "Errors", "mappingType": "Expression", "mappingValue": "null" }
]

I agree that it's confusing that it's different than expected and then not clearly documented in the ArcGIS API for Python. I've put in a request to have the ArcGIS API for Python documentation include an example. 

Please let me know if you have any follow up questions,

Sarah Ambrose
GeoAnalytics Team

 

View solution in original post

0 Kudos
6 Replies
DavidPike
MVP Frequent Contributor

I think it may be a list of lists rather than KVPs:

field_mapping = [['kelurahan', 'kelurahan'], ['kecamatan','kecamatan']]

 

0 Kudos
AriMatiur
Emerging Contributor

Hello David 

It still not working

AriMatiur_0-1612672704182.png

 

0 Kudos
DavidPike
MVP Frequent Contributor

Yeh I only came across that type of field mapping in another Python API tool, was worth a go I guess.

This tool's documentation for the field_mapping parameter is awful.

0 Kudos
AriMatiur
Emerging Contributor

Yeah, other Python API tool field_mapping use list or KVPs. I don't know why this one is different.
Anyway, thank you very much.

0 Kudos
SarahAmbrose
Esri Contributor

Hi @AriMatiur,

The REST API documentation for the tool outlines the field mapping parameters here.  Here is an example:

[
{ "inputLayerField": "Mean_Scales", "mappingType": "AppendField", "mappingValue": "Average_Scales" },
{ "inputLayerField": "Bonus", "mappingType": "Expression", "mappingValue": "$feature['WeeklyRate'] * 1.5" },
{ "inputLayerField": "Errors", "mappingType": "Expression", "mappingValue": "null" }
]

I agree that it's confusing that it's different than expected and then not clearly documented in the ArcGIS API for Python. I've put in a request to have the ArcGIS API for Python documentation include an example. 

Please let me know if you have any follow up questions,

Sarah Ambrose
GeoAnalytics Team

 

0 Kudos
AriMatiur
Emerging Contributor

It's working, thank you Sarah 😁

AriMatiur_0-1612795505971.png