Import .json/.geojson file as map layer in AGOL Python Notebook?

408
1
09-16-2020 03:20 PM
EricThomas3
New Contributor II

I cannot for the life of me, find some sample Python for importing a local file as a map layer into an AGOL notebook. 

What I have:

Pull some data from ArcOnline:

item = gis.content.get("xyz") 

Map it real quick:

map1 = gis.map('USA')
map1.add_layer(item)
map1

Pull some data from a .json file (uploaded to notebook/home directory):

with open(filePath + geoFileName) as f:
geoFile = json.load(f)

I've tried:

map1.add_layer(geoFile) # no good

Also tried:

data_file_location = filePath + geoFileName
data = gis.content.add(geoFile, data=data_file_location) # error

What I need:

How on earth do I add a .json file (geoFile) as a map layer using Python?!?

Thank you

0 Kudos
1 Reply
EricThomas2
New Contributor II

I really need this answered today. Can anyone help? Should be an easy task. 
Thank you

0 Kudos