{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# Notebook Template\n", "\n", "This Notebook is stubbed out with some project paths, loading of enviroment variables, and common package imports to speed up the process of starting a new project.\n", "\n", "It is highly recommended you copy and rename this notebook following the naming convention outlined in the readme of naming notebooks with a double number such as `01-first-thing`, and `02-next-thing`. This way the order of notebooks is apparent, and each notebook does not need to be needlesssly long, complex, and difficult to follow." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import configparser\n", "import os\n", "from pathlib import Path\n", "import pkgutil\n", "import sys\n", "\n", "from arcgis.features import GeoAccessor, GeoSeriesAccessor\n", "from arcgis.gis import GIS\n", "import pandas as pd\n", "\n", "# import arcpy if available\n", "if pkgutil.find_loader(\"arcpy\") is not None:\n", " import arcpy" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# paths to common data locations - NOTE: to convert any path to a raw string, simply use str(path_instance)\n", "dir_prj = Path.cwd().parent\n", "\n", "dir_data = dir_prj/'data'\n", "\n", "dir_raw = dir_data/'raw'\n", "dir_ext = dir_data/'external'\n", "dir_int = dir_data/'interim'\n", "dir_out = dir_data/'processed'\n", "\n", "gdb_raw = dir_raw/'raw.gdb'\n", "gdb_int = dir_int/'interim.gdb'\n", "gdb_out = dir_out/'processed.gdb'\n", "gdb_ext = dir_ext/'external.gdb'\n", "\n", "# path to the config file\n", "config_pth = dir_prj/'config'/'secrets.ini'\n", "\n", "# import the project package from the project package path - only necessary if you are not using a unique environemnt for this project\n", "sys.path.append(str(dir_prj/'src'))\n", "import reach_tools\n", "\n", "# load the \"autoreload\" extension so that code can change, & always reload modules so that as you change code in src, it gets loaded\n", "%load_ext autoreload\n", "%autoreload 2\n", "\n", "# load environment variables from the config file\n", "config = configparser.ConfigParser()\n", "config.read(config_pth)\n", "\n", "# create a GIS object instance; if you did not enter any information for these values, it defaults to anonymous access to ArcGIS Online\n", "gis = GIS(\n", " url=config.get('ESRI_GIS_URL'),\n", " username=config.get('ESRI_GIS_USERNAME'),\n", " password=config.get('ESRI_GIS_PASSWORD')\n", ")\n", "\n", "gis" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "Licensing\n", "\n", "Copyright 2020 Esri\n", "\n", "Licensed under the Apache License, Version 2.0 (the \"License\"); You\n", "may not use this file except in compliance with the License. You may\n", "obtain a copy of the License at\n", "\n", "http://www.apache.org/licenses/LICENSE-2.0\n", "\n", "Unless required by applicable law or agreed to in writing, software\n", "distributed under the License is distributed on an \"AS IS\" BASIS,\n", "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n", "implied. See the License for the specific language governing\n", "permissions and limitations under the License.\n", "\n", "A copy of the license is available in the repository's\n", "LICENSE file." ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.8" } }, "nbformat": 4, "nbformat_minor": 4 }