Notebook Template¶
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.
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.
[ ]:
import configparser
import os
from pathlib import Path
import pkgutil
import sys
from arcgis.features import GeoAccessor, GeoSeriesAccessor
from arcgis.gis import GIS
import pandas as pd
# import arcpy if available
if pkgutil.find_loader("arcpy") is not None:
import arcpy
[ ]:
# paths to common data locations - NOTE: to convert any path to a raw string, simply use str(path_instance)
dir_prj = Path.cwd().parent
dir_data = dir_prj/'data'
dir_raw = dir_data/'raw'
dir_ext = dir_data/'external'
dir_int = dir_data/'interim'
dir_out = dir_data/'processed'
gdb_raw = dir_raw/'raw.gdb'
gdb_int = dir_int/'interim.gdb'
gdb_out = dir_out/'processed.gdb'
gdb_ext = dir_ext/'external.gdb'
# path to the config file
config_pth = dir_prj/'config'/'secrets.ini'
# import the project package from the project package path - only necessary if you are not using a unique environemnt for this project
sys.path.append(str(dir_prj/'src'))
import reach_tools
# load the "autoreload" extension so that code can change, & always reload modules so that as you change code in src, it gets loaded
%load_ext autoreload
%autoreload 2
# load environment variables from the config file
config = configparser.ConfigParser()
config.read(config_pth)
# create a GIS object instance; if you did not enter any information for these values, it defaults to anonymous access to ArcGIS Online
gis = GIS(
url=config.get('ESRI_GIS_URL'),
username=config.get('ESRI_GIS_USERNAME'),
password=config.get('ESRI_GIS_PASSWORD')
)
gis
Licensing
Copyright 2020 Esri
Licensed under the Apache License, Version 2.0 (the “License”); You may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
A copy of the license is available in the repository’s LICENSE file.