Add the Box.com Python SDK libraries/modules to ArcGIS Online Notebooks.

1092
4
04-14-2022 06:05 PM
Ian-Horn
New Contributor II

Our organization leverages Box.com where we allow any and all state agencies to store geospatial data if they need it.  The biggest users of this platform, besides my office, are the UAV/UAS operators.  I have been tasked to routinely search Box.com for project mosaics with the end product being an image footprint layer.  My previous method is obsolete because our capacity has become so large that I simply can't use the Box Drive.  If I can leverage the Box Python SDK in notebook (like one can leverage pandas or matplotlib), I could create a query that searches for files with specific names, create a list from that query (filtering unnecessary records - box doesn't handle wildcards).  Then, I could use the list to grab a file by its Box ID, geoprocess it creating a tile index, and then move that tile (polygon vector) to a feature class/feature service, etc.  The end product, the feature service would be used by all the drone operators.  It allows users from different agencies see where data may be available across the state. 

In notebooks on AGOL, I would like to be able to do this:

from boxsdk import JWTAuth

 

Another example that I have:  I routinely extract data from a handful of features services.  I export those features services to shapefiles, zip them up, and push them to Box so that the most up to date data is on Box.  All of our geoportal records point towards Box links.  We made this change because FTP is basically impossible to access in a web browser.  

4 Comments
jcarlson

Can you start your notebook with a cell like this:

!pip install boxsdk

I've used that method to add missing modules to the AGOL Notebook in the past. 

Ian-Horn

@jcarlson  Thanks for that response.  It totally worked.  Does the below result mean that I will always have the boxsdk, or will I need to installing every time I want to open that notebook and run a query?

```

Collecting boxsdk
  Downloading boxsdk-3.2.0-py2.py3-none-any.whl (133 kB)
     |████████████████████████████████| 133 kB 37.4 MB/s eta 0:00:01
Requirement already satisfied: requests>=2.4.3 in /opt/conda/lib/python3.7/site-packages (from boxsdk) (2.26.0)
Requirement already satisfied: wrapt>=1.10.1 in /opt/conda/lib/python3.7/site-packages (from boxsdk) (1.12.1)
Requirement already satisfied: requests-toolbelt<1.0.0,>=0.4.0 in /opt/conda/lib/python3.7/site-packages (from boxsdk) (0.9.1)
Requirement already satisfied: python-dateutil in /opt/conda/lib/python3.7/site-packages (from boxsdk) (2.8.2)
Requirement already satisfied: attrs>=17.3.0 in /opt/conda/lib/python3.7/site-packages (from boxsdk) (21.2.0)
Requirement already satisfied: certifi>=2017.4.17 in /opt/conda/lib/python3.7/site-packages (from requests>=2.4.3->boxsdk) (2021.10.8)
Requirement already satisfied: idna<4,>=2.5 in /opt/conda/lib/python3.7/site-packages (from requests>=2.4.3->boxsdk) (3.2)
Requirement already satisfied: charset-normalizer~=2.0.0 in /opt/conda/lib/python3.7/site-packages (from requests>=2.4.3->boxsdk) (2.0.4)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /opt/conda/lib/python3.7/site-packages (from requests>=2.4.3->boxsdk) (1.25.11)
Requirement already satisfied: six>=1.5 in /opt/conda/lib/python3.7/site-packages (from python-dateutil->boxsdk) (1.15.0)
Installing collected packages: boxsdk
Successfully installed boxsdk-3.2.0```

 ```

Requirement already satisfied: boxsdk[jwt] in /opt/conda/lib/python3.7/site-packages (3.2.0)
Requirement already satisfied: python-dateutil in /opt/conda/lib/python3.7/site-packages (from boxsdk[jwt]) (2.8.2)
Requirement already satisfied: attrs>=17.3.0 in /opt/conda/lib/python3.7/site-packages (from boxsdk[jwt]) (21.2.0)
Requirement already satisfied: wrapt>=1.10.1 in /opt/conda/lib/python3.7/site-packages (from boxsdk[jwt]) (1.12.1)
Requirement already satisfied: requests>=2.4.3 in /opt/conda/lib/python3.7/site-packages (from boxsdk[jwt]) (2.26.0)
Requirement already satisfied: requests-toolbelt<1.0.0,>=0.4.0 in /opt/conda/lib/python3.7/site-packages (from boxsdk[jwt]) (0.9.1)
Requirement already satisfied: pyjwt>=1.3.0 in /opt/conda/lib/python3.7/site-packages (from boxsdk[jwt]) (2.1.0)
Requirement already satisfied: cryptography>=3 in /opt/conda/lib/python3.7/site-packages (from boxsdk[jwt]) (3.4.8)
Requirement already satisfied: cffi>=1.12 in /opt/conda/lib/python3.7/site-packages (from cryptography>=3->boxsdk[jwt]) (1.14.6)
Requirement already satisfied: pycparser in /opt/conda/lib/python3.7/site-packages (from cffi>=1.12->cryptography>=3->boxsdk[jwt]) (2.20)
Requirement already satisfied: certifi>=2017.4.17 in /opt/conda/lib/python3.7/site-packages (from requests>=2.4.3->boxsdk[jwt]) (2021.10.8)
Requirement already satisfied: charset-normalizer~=2.0.0 in /opt/conda/lib/python3.7/site-packages (from requests>=2.4.3->boxsdk[jwt]) (2.0.4)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /opt/conda/lib/python3.7/site-packages (from requests>=2.4.3->boxsdk[jwt]) (1.25.11)
Requirement already satisfied: idna<4,>=2.5 in /opt/conda/lib/python3.7/site-packages (from requests>=2.4.3->boxsdk[jwt]) (3.2)
Requirement already satisfied: six>=1.5 in /opt/conda/lib/python3.7/site-packages (from python-dateutil->boxsdk[jwt]) (1.15.0)```

 

 

jcarlson

@Ian-Horn  That would be the main downside of this "solution". You'll need to run that cell every time you start up the notebook.

RaviNarayanan

Hi @Ian-Horn  Thanks for this post. We will bring this up with the team for review. 

I would also recommend the suggestion from @jcarlson,. However it may need to run once every time a new container is launched and may also need a kernel restart.  

thanks,

Ravi