Can I publish a scene layer package using this API?

2015
6
03-10-2017 01:21 AM
Min_KenMoey
New Contributor

Hi,

I've been trying to programmatically upload a scene layer package and eventually publish it as a scene layer. The idea is that my web scene will get updated layers frequently, so I need to automate uploading, publishing, and reediting the web scene.

My issue is that while trying this on the ArcGIS Pro Python console:

from arcgis.gis import GIS
gis = GIS("http://esrimsia.maps.arcgis.com", "xxxx", "xxxxx")
slpk_path = r"D:\Documents\ArcGIS\Projects\MMD\Rainfall_pointsample_few.slpk"
slpk_properties={'title':'rainfall_test', 'description':'rainfall test', 'tags':'test', 'type':'Scene Package'}
rainfall_item = gis.content.add(item_properties=slpk_properties, data=slpk_path)
rainfall_item.publish()

At the publish statement, I got the following error:

Traceback (most recent call last):

File "<string>", line 1, in <module>

File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis.py", line 2818, in publish elif fileType == 'CSV':

UnboundLocalError: local variable 'fileType' referenced before assignment

What's the best way to tackle this issue?

Regards,

Ken Moey

0 Kudos
6 Replies
by Anonymous User
Not applicable

Min, could you verify you are using the 1.0.1 version of the API?

Could you also paste the full traceback, it would be easier to debug.

0 Kudos
Min_KenMoey
New Contributor

Hi Atma Maini,

I was trying it on ArcGIS Pro, so the version says it's 0.3 of the ArcGIS API for Python. It's the latest one i just downloaded.

That is the full traceback that i got.

0 Kudos
by Anonymous User
Not applicable

Thanks Min, please remove or mask that picture you posted as it accidentally has your credentials.

The ability to publish packages as web layers was added to version 1.0. Could you please update the package following these instructions and then try again?

0 Kudos
Min_KenMoey
New Contributor

Hi Atma Mani,

Alright that worked. I could publish it now. However, when i try to view the web scene which i published using ArcGIS API for Python, i get the error:

Layer cannot be added
Unable to retrieve the scene service information.
I compare this to when in the arcgis online browser item. I use that very same Scene Layer Package that i just uploaded, enter the item description page and press 'Publish' button in the browser. This works instead. but if i use th command rainfall_item.publish() in ArcgIS Pro, it doesn't work.

Regards,

Ken Moey

0 Kudos
by Anonymous User
Not applicable

Min, since you are publishing to ArcGIS Online, we put a check where you need to visit the item (in the browser) and publish the tiles as a second step. This exists only on ArcGIS Online and not on Portal for ArcGIS since this step consumes some credits. We are evaluating a couple of different ways to address this issue.

0 Kudos
Min_KenMoey
New Contributor

Hi Atma Mani,

Ok, so if i was publishing to Portal, it theoretically can work. Publishing to Portal is my ultimate use case actually. Thanks for your help.

Thanks, MIn Ken

0 Kudos