Create a Schiphol map using Arcgis online and Jupyter notebook

Documentation for the beta Esri Arcgis Python API can be found here: http://esri.github.io/arcgis-python-api/apidoc/html/index.html


In [107]:
from arcgis.gis import *
from arcgis.viz import MapView
from IPython.display import display

Log in to the Arcgis Portal

Use your developers account. If you do not have one, you can register freely at http://developers.arcgis.com/sign-up


In [108]:
username = "Bierkaai"
password = "nen-HAy-d4C-yXQ"
gis_portal = GIS("http://www.arcgis.com", username, password)

Get the Passenger Maps


In [130]:
map_shg2 = gis_portal.map("Schiphol")

In [152]:
content = gis_portal.content.search("IWF", "Feature Service")

In [153]:
for i,x in enumerate(content):
    print("{0} -> {1}".format(i, x.title))


0 -> States
1 -> Barriers_IWF
2 -> IWF_POI
3 -> IWF_POI_VLAKKEN

In [154]:
map_shg.add_layer(content[2])


---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-154-912ba9e52a1d> in <module>()
----> 1 map_shg.add_layer(content[2])

//anaconda/lib/python3.5/site-packages/arcgis/viz.py in add_layer(self, item, options)
    178         if isinstance(item, arcgis.gis.Item):
    179             if item.type.lower() == 'feature service':
--> 180                 fs = FeatureService(item)
    181                 lyr_url = ""
    182                 for layer in fs.layers:

//anaconda/lib/python3.5/site-packages/arcgis/lyr.py in __init__(self, item)
     85             }
     86 
---> 87             allayers = self.item._portal.con.post(fsurl, params)
     88             try:
     89                 for layer in allayers['layers']:

//anaconda/lib/python3.5/site-packages/arcgis/_impl/portalpy.py in post(self, path, postdata, files, ssl, compress, is_retry, use_ordered_dict, add_token)
   2523                     postdata['token'] = newtoken
   2524                     return self.post(path, postdata, files, ssl, compress,
-> 2525                                      is_retry=True)
   2526                 elif errorcode == 498:
   2527                     raise RuntimeError('Invalid token')

//anaconda/lib/python3.5/site-packages/arcgis/_impl/portalpy.py in post(self, path, postdata, files, ssl, compress, is_retry, use_ordered_dict, add_token)
   2525                                      is_retry=True)
   2526                 elif errorcode == 498:
-> 2527                     raise RuntimeError('Invalid token')
   2528                 self._handle_json_error(resp_json['error'])
   2529                 return None

RuntimeError: Invalid token

In [145]:
map_shg.addlayer


Out[145]:
'{"type": "FeatureLayer", "url": "http://services.arcgis.com/nSZVuSZjHpEZZbRo/arcgis/rest/services/Bebouwdekom/FeatureServer/0"}'

In [132]:
map_shg2.addlayer


Out[132]:
''

In [137]:
map_shg.center = gis_portal.tools.geocoder.find_best_match("Schiphol", 6)

In [138]:
map_shg


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
TypeError: _handle_map_msg() takes 3 positional arguments but 4 were given
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
TypeError: _handle_map_msg() takes 3 positional arguments but 4 were given
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
TypeError: _handle_map_msg() takes 3 positional arguments but 4 were given
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
TypeError: _handle_map_msg() takes 3 positional arguments but 4 were given

In [ ]: