Select to view content in your preferred language

Update Visualization with ArcGIS API for Python

505
1
03-07-2023 12:15 AM
Labels (2)
Pia
by
New Contributor II

hello,

I'm a newbie to arcgis api and new to Python and have two questions.

My script downloads a updated excel file and a feature layer from ArcGIS Online and then merge on a spatial Dataframe. Afterwards, I want to symbolize it and then overwrite another Feature Layer on ArcGIS Online.

sdf = pd.DataFrame.spatial.from_layer(layer)
new_sp = pd.merge(csv, sdf, on="probeentna")

 I tried it with:

 fc = new_sp.spatial.to_featurelayer(
        gis = gis,
        title = 'title',
        tags= 'tags',
        folder= 'folder'
    )

but that just uploads a new feature layer and I can't work with fc on my visualization. I also tried to export my spatial Dataframe to a Feature Class, doesn't work.

My Visualization so far:

map_renderer = {'renderer': "autocast", "type": "uniqueValue",
                    'field1':"field"}

map_renderer["uniqueValueInfos"] = [{"value": "pos",
                                          "symbol": {
                                              "color": [0, 77, 168, 255],
                                              "size": 6,
                                              "angle": 0,
                                              "xoffset": 0,
                                              "yoffset": 0,
                                              "type": "esriSMS",
                                              "style": "esriSMSCircle",
                                              "outline": {
                                                  "color": [190, 210, 255, 88],
                                                  "width": 0.75,
                                                  "type": "esriSLS",
                                                  "style": "esriSLSSolid"
                                              }
                                          },
                                          "label": "Positiv"
                                          },
                                         {"value": "neg",
                                          "symbol": {
                                              "color": [56, 168, 0, 255],
                                              "size": 6,
                                              "angle": 0,
                                              "xoffset": 0,
                                              "yoffset": 0,
                                              "type": "esriSMS",
                                              "style": "esriSMSCircle",
                                              "outline": {
                                                  "color": [163, 255, 115, 82],
                                                  "width": 0.75,
                                                  "type": "esriSLS",
                                                  "style": "esriSLSSolid"
                                              }
                                          },
                                          "label": "Neg"
                                          },
                                        {"value": "<Null>",
                                         "symbol": {
                                             "color": [0, 0, 0, 255],
                                             "size": 6,
                                             "angle": 0,
                                             "xoffset": 0,
                                             "yoffset": 0,
                                             "type": "esriSMS",
                                             "style": "esriSMSCircle",
                                             "outline": {
                                                 "color": [163, 255, 115, 82],
                                                 "width": 0.75,
                                                 "type": "esriSLS",
                                                 "style": "esriSLSSolid"
                                             }
                                         },
                                         "label": "label"
                                         }
                                        ]
fc.update_renderer(renderer_type= 'uniqueValue', symbol = map_renderer)

 

Overwriting.

I want to update the Feature Layer without creating a webmap. How can I do this? I tried with layer.update_renderer but that obviously doesn't work.

I'm sure that there is a possibility how I can visualize my spatial DF after I exported it to a feature whatsoever and then Overwrite or update the new Information to another Feature Layer in ArcGIS Online. Just can't find any solutions. Thanks for your help!

0 Kudos
1 Reply
David_McRitchie
Esri Contributor

Hey Pia,

I believe the section Overwrite the feature layer in the following sample should help resolve this. It will allow the Feature Layer on ArcGIS Online to be overwritten.

The following Technical Article also provides another sample with a full code block that can be used.

Hopefully these help! if you encounter any issues with them then please let me know.

Esri UK -Technical Support Analyst
0 Kudos