Add Feature Layer to Webmap

1817
5
06-19-2018 11:06 PM
HugoBouckaert1
New Contributor III

Hi 

I have upgraded my ArcGIS Pro to version 2.1 because I thought limitations on functions available for the arcgis.gis package in ArcGIS Pro 2.0 were the problem. Now, with ArcGIS Pro 2.1 I am using arcgis.gis 1.2.5 (which is the highest version available with ArcGIS Pro 2.1), but all the examples I see online are for arcgis.gis 1.4.2. So this is my first question - is there any way to use the latest version of arcgis.gis within ArcGIS Pro?  The vast majority of functions in arcgis.gis 1.4.2 seems to be unavailable in arcgis.gis 1.2.5.   

Basically all I would like to do is add feature layers to a webmap. 

Ideally I would like to clone a web map, and then change the URLs and other item properties so that the new webmap has the same layout compared to the old one but uses different feature services. The best examples I have come across are: 

Add Feature Service Item to WebMap 

This example uses a dictionary, but it is never explained where "base.json" in the code is coming from to load into the dictionary so I cannot replicate this code. The other example is: https://community.esri.com/thread/193550-web-map-created-with-python-api-and-feature-services-not-di...

But here (all the way below) a function is used "clone_items" and also webmap.layers[0] is used, neither of which are available to use with my arcgis.gis 1.2.5 (which is all that is available in ArcGIS Pro 2.1).

So given I am limited to working with arcgis.gis 1.2.5 (because I want to use anaconda within an ArcGIS Pro environment), how can I add feature layers to a webmap?

All functions available for use with a webmap object (in this case named "northam_wm") are listed below, but none of them seem to allow adding a feature layer.  

I have spent several hours on this now and it looks like this cannot be done. Surely even the earlier arcgis.gis API 1.5.0 should be able to handle this? A code example would be greatly appreciated. 

Thanks

Hugo  

0 Kudos
5 Replies
by Anonymous User
Not applicable

Hello Hugo,
I am sorry that you had to spend a lot of time on this. At Pro 2.1 due to a technical complication we could not allow upgrading the Python API from the UI. Please take a look here: Install and set up | ArcGIS for Developers  to see how you can upgrade the Python API via "Python command prompt". I agree this workflow (command line overrides) is not ideal, but the good news is, future versions of Pro will have a much nicer workflow of upgrading your Python packages and managing your environments.

Now that you can upgrade the API to version 1.4.2, take a look at this topic: Working with web maps and web scenes | ArcGIS for Developers which might be relevant to what you are doing.

Side note: In the image you attached, you are querying the members exposed off the 'Item' object, not the WebMap object. At 1.4.2, you will see methods to list, add, remove layers.

- Atma

0 Kudos
HugoBouckaert1
New Contributor III

Hi Atma

Thanks for that. Perhaps you can clarify something further for me? Obviously the APIs are limited by the arcgis.gis version you are using. But the version I am using now with ArcGIS Pro 2.1, which is arcgis.gis 1.2.5, can do more when I am connecting to ArcGIS Online, compared to connecting to our local Portal for ArcGIS which is 10.5. This is borne out by the fact that if I connect to Portal as

gis = GIS (portalURL,fullname, password)

and look for the version:

print (gis.properties['currentVersion'])

it is 4.4

If I connect to AGOL, the same statement about gis.properties returns:

6.1

So is what you can do programmatically dependent on two things: (1) the version of arcgis.gis you are using and (2) the AGOL/Portal environment you are connecting to?

This is an important question because if I do one of the two (e.g. upgrade arcgis.gis) I still may be limited by Portal 10.5 in our current environment.

Any chance you can elaborate on this? Thanks.

Secondly, I have been to the link you are mentioning. I have tried upgrading from within ArcGIS Pro, but have also tried to command line option in a python window, i.e.

conda upgrade -c esri arcgis

But this still only upgrades to arcgis.gis 1.2.5 (i.e. it does not do anything in this case) and not to 1.4.2.

Do you perhaps mean I have to upgrade the complete CONDA environment? If so, how would this be done, and would this still work with ArcGIS Pro?

Thanks

Hugo

0 Kudos
by Anonymous User
Not applicable

Hugo, you were close. You should do the following in the Python command prompt as mentioned in the Install and set up | ArcGIS for Developers help.

conda upgrade -c esri --no-pin arcgis

(note the --no-pin at the end)

Yes, you have a good understanding of the versions. The functionality you get is dependent on ArcGIS Online version, ArcGIS Enterprise version and the version of the Python API. Since Online is  SAAS (software as a service), we like to call it version-less. It is always up-to-date, whereas you need to manually update Enterprise and the Python API.

0 Kudos
HugoBouckaert1
New Contributor III

Hi Atma

It works! Thank you very much.

Cheers

Hugo

GNOMICAdmin
New Contributor III

I've done the above but my jupyter notebook code still complains about a required item when creating the webmap instance. So points to the fact is still running on the old api version.

how do i get jupyter to see this latest api upgrade

how do i confirm in the notebook the version of the arcgis api it is reading?

0 Kudos