add hosted feature layers to local feature service

258
2
Jump to solution
12-21-2018 01:45 PM
BrianLomas
Occasional Contributor III

Is there a way to append/POST queried features from a AGOL hosted layer to a ArcGIS server feature service using ArcGIS python api? If so, have would I go about doing so?

Right now I'm able to access both feature services and query the features I want. However, I cannot figure how to get them from the hosted feature layer into the local feature service. Any help would be great thanks.

0 Kudos
1 Solution

Accepted Solutions
BrianLomas
Occasional Contributor III

I was able to keep attributes along with geometry by using the ".as_dict" with the features module...

#loops through features and updates the processed attribute
for f in snowplow_fset.features:
    sp_edit = f
    sp_edit.attributes['Processed']=8
    update_result = snowplow.edit_features(updates=[sp_edit])
    update_result
    t = sp_edit.as_dict
    #appends select features to local feature service
    add_result = fs_layers.edit_features(adds = [t])
    add_result

View solution in original post

0 Kudos
2 Replies
BrianLomas
Occasional Contributor III

I was able to figure it out. ***this may not be best practice but it worked, newbie here...***

However, it does not carry over the attribute information. Any help on that would be great. Thanks.

#loops through features and updates the processed attribute
for f in snowplow_fset.features:
    sp_edit = f
    sp_edit.attributes['Processed']=8
    update_result = snowplow.edit_features(updates=[sp_edit])
    update_result
    t=(update_result)
    #appends select features to local feature service
    add_result = fs_layers.edit_features(adds = [t])
    add_result‍‍‍‍‍‍‍‍‍‍
0 Kudos
BrianLomas
Occasional Contributor III

I was able to keep attributes along with geometry by using the ".as_dict" with the features module...

#loops through features and updates the processed attribute
for f in snowplow_fset.features:
    sp_edit = f
    sp_edit.attributes['Processed']=8
    update_result = snowplow.edit_features(updates=[sp_edit])
    update_result
    t = sp_edit.as_dict
    #appends select features to local feature service
    add_result = fs_layers.edit_features(adds = [t])
    add_result
0 Kudos