Hello everyone, I'm quite new to ArcGIS Notebooks and my understanding of them is quite basic.
Is it possible to use ArcGIS Notebooks to seamlessly replace the old layer in Arcgis online maps with a new one, while keeping all my labels and symbology intact and applied to the new layer? The new layer will have all the same fields as the old one, plus a few extra.
It is possible. You want to grab the map's definition as JSON, edit it, then perform an update.
This came up very recently, I posted a response to someone else containing two functions, one to download a map's definition and one to update it. These functions are intended to save the JSON to the file system where you can manually edit it (or run other scripts) but the same concepts apply to notebooks, you could either save them in the notebook's temporary file space or keep the definition in memory and update it there:
I would highly recommend doing this to maps you don't care about first though, as well as creating backups of your maps' JSON definitions. I actually use the download_data() function here to push my maps into source control.
I have zero doubt that what you said is correct. Zero, zilch, nada, but the problem is I don't really know how to even start. You see, I think of myself as a pretty good map producer, but I am by no means a coder, whatsoever. I just sort of know about ArcGIS Notebooks, and my basic understanding of them is that within a notebook, if the correct code is written, I can do what you said. Let me know if what you said can indeed be done within ArcGIS Notebooks, as I am honestly not sure. 🙂
So, with this in mind, is it at all possible for you to consider producing some type of YouTube video showing exactly how what you said is done to replace one layer with another in a map? Please?
Side question: would this need to be done in every map that the layer is used in, or is there some way to make a global setting change in ArcGIS Online that says, in all maps hosted in ArcGIS Online, instead of looking for this old layer, now just look at this new layer? Just wondering.
It is possible to write a script that would do this:
I've done this before but don't think have the code anymore, I might be able to dig it up, however. (Edit to add - This did have a limitation if layers were used outside the organization; it could only find where the layer was used internally.)
There may be a no-code / no-JSON option you could use, however it has some restrictions and I have to admit I haven't actually done this myself. If your maps use a hosted feature layer view instead of a layer, you can update your view properties to point to a new layer:
https://doc.arcgis.com/en/arcgis-online/manage-data/swap-view-source.htm
In this case you don't change your map definition at all, instead you change the properties of the view that your map is pointing at.
Hello Mr. Snake,
First, thank you for your response. Let me hit you with a follow-up question that you might know the answer to. In the post you linked me to in your original response, another person mentioned the use of the ArcGIS Assistant tool. I had honestly never heard of it before, but from my looking around at it, it appears to be able to directly edit the JSON of my ArcGIS Online web maps, which would allow me to swap out one feature layer for another.
However, I now feel like I should explain a little more of what my true problem is so that you might be able to inform me if the ArcGIS Assistant tool could assist me with my real problem. What I actually have in my maps is a joined hosted feature layer view, as depicted in the image attached to this message. My goal is to update several maps with a new joined feature layer view.
Given the specifics of my situation—aiming to replace an existing joined view layer in my maps with a newly created joined hosted feature layer view—do you believe ArcGIS Assistant can facilitate this transition?
Basically, I need to do this switching out of hosted feature layer views because I have added some new fields to one of the feature layers that are used in the joined feature layer view and because of this, I now have to make a new joined view, as you can't update a joined view. In my mind, it should work, but I just wanted to ask a pro before I gave it a shot to see what you would think :).
ArcGIS Assistant should be able to solve this for you, it basically does the same thing as grabbing the JSON definition in a notebook or other Python script would do. Just instead of manipulating the JSON definition via code or a text editor, you're manipulating it in the web browser.
Updating a joined view layer should be the same in theory as updating any other layer, there are two main properties to pay attention to, the Item ID and the URL. I don't think there's anything else specific to joined layers you'd need to update, but I could be wrong...
As with the other approaches, I'd suggest doing this with a map you don't care about first, rather than one that's in use. If you create a copy of one of your maps containing the join, that should be a good test case.
AWESOME! Will try and report back so that the world can learn with me, haha.