diff --git a/samples/04_gis_analysts_data_scientists/determining_site_suitability_for_oil_palm_plantation.ipynb b/samples/04_gis_analysts_data_scientists/determining_site_suitability_for_oil_palm_plantation.ipynb
index f1d795e13..b6cd8f832 100644
--- a/samples/04_gis_analysts_data_scientists/determining_site_suitability_for_oil_palm_plantation.ipynb
+++ b/samples/04_gis_analysts_data_scientists/determining_site_suitability_for_oil_palm_plantation.ipynb
@@ -1 +1,1024 @@
-{"cells": [{"cell_type": "markdown", "metadata": {"slideshow": {"slide_type": "subslide"}}, "source": ["# Determining site suitability for oil palm plantation "]}, {"cell_type": "markdown", "metadata": {"heading_collapsed": true}, "source": ["## Table of Contents\n", "\n", "- [Introduction](#introduction)\n", "- [Prerequisites](#prerequisites)\n", "- [Necessary Imports](#imports)\n", "- [Using Raster Function Template ](#rft)\n", " - [Suitability factors taken into consideration in the RFT](#factors)\n", " - [Uploading the RFT to ArcGIS Online using Content Manager](#upload)\n", " - [Creating the RFT object using the RFT class from raster function template item. ](#create)\n", "- [Creating hosted imagery layers for analysis](#layers)\n", "- [Applying the raster function chain on the input layers to create the suitability raster ](#suitability)\n", " - [Persisting the output in the GIS](#op)\n", "- [Conclusion](#conclusion)\n", "- [References](#references)"]}, {"cell_type": "markdown", "metadata": {}, "source": ["## Introduction "]}, {"cell_type": "markdown", "metadata": {}, "source": ["Proper land suitability assessment for agriculture has to be carried out to determine the potentiality of a land area to provide the most favorable ecological requirements for a particular crop variety, which results in optimum crop development and maximum productivity. \n", "\n", "In this notebook, we determine the site suitability for oil palm development by: \n", " \n", " - Creating hosted imagery layers. \n", " - Applying raster function chain using the RFT class from the arcgis.raster.functions module.\n", " - Persisting the raster analysis in ArcGIS Online.\n", " \n", "Note: This analysis can be conducted on ArcGIS Enterprise as well as on ArcGIS Online. In this notebook, the notebook was carried out using ArcGIS Online."]}, {"cell_type": "markdown", "metadata": {}, "source": ["## Prerequisites "]}, {"cell_type": "markdown", "metadata": {}, "source": ["- To run raster analysis functions on ArcGIS Online, you must have privileges to create and publish content and to perform Raster Analysis.\n", "For more information, refer [here](https://doc.arcgis.com/en/arcgis-online/analyze/perform-raster-analysis.htm). \n", "\n", "- For creating imagery layers using [copy_raster](https://developers.arcgis.com/python/api-reference/arcgis.raster.analytics.html#copy-raster) in ArcGIS Online, Azure library packages for Python (Azure SDK for Python - azure-storage-blob: 12.1<= version <=12.8) needs to be pre-installed. Refer https://docs.microsoft.com/en-us/azure/developer/python/azure-sdk-install\n", "\n", "- An optional installation of graphviz 2.38 can be used to visualize the funciton chain of the raster function template. "]}, {"cell_type": "markdown", "metadata": {}, "source": ["## Necessary Imports "]}, {"cell_type": "code", "execution_count": 1, "metadata": {"slideshow": {"slide_type": "-"}}, "outputs": [], "source": ["import os\n", "import zipfile\n", "\n", "import arcgis\n", "from arcgis.gis import GIS\n", "from arcgis.raster.analytics import copy_raster\n", "from arcgis.raster.functions import RFT"]}, {"cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": ["gis = GIS(\"Home\")"]}, {"cell_type": "markdown", "metadata": {}, "source": ["## Using Raster Function Template (RFT) "]}, {"cell_type": "markdown", "metadata": {}, "source": ["A raster function template is a model that consists of many function chains to produce a processing workflow. We can build the RFT using the function editor and raster functions pane.\n", "\n", "The RFT can be created using [ArcGIS Pro](https://pro.arcgis.com/en/pro-app/latest/help/analysis/raster-functions/raster-function-template.htm) or [ArcGIS Enterprise](https://enterprise.arcgis.com/en/portal/latest/use/raster-function-editor.htm). "]}, {"cell_type": "markdown", "metadata": {"slideshow": {"slide_type": "subslide"}}, "source": ["### Suitability factors taken into consideration in the RFT \n", "\n", "In order to carry out the suitability analysis, we need to consider some of the favorable environmental and crop criteria settings:\n", "\n", "| Suitability\u00a0 Considerations | Suitable | Not suitable |\n", "| --- | --- | --- |\n", "| Elevation | 0-1000m | >1000 m |\n", "| Slope | 0-30% | >30% |\n", "| Conservation area buffer | >1000 m | <1000m |\n", "| Soil type | Inceptisol, Oxisol, Alfisol, Ultisol, Spodosol, Entisol | Histosols |\n", "| Soil acidity | 1-7 | None |\n", "\n", "\n", "\n", "Based on these criteria, a raster function template was created using ArcGIS Pro. You can acquire the RFT using the following item. "]}, {"cell_type": "code", "execution_count": 32, "metadata": {}, "outputs": [{"data": {"text/html": ["
\n", "
\n", "\n", "
\n", "
\n", " "], "text/plain": ["- "]}, "execution_count": 32, "metadata": {}, "output_type": "execute_result"}], "source": ["palm_oil_suitability_rft = gis.content.get('9fa702ab04f747be99607206c2d0eaaa')\n", "palm_oil_suitability_rft"]}, {"cell_type": "markdown", "metadata": {}, "source": ["The RFT can be further added to your own GIS for further analysis, by downloading the RFT and adding it to your GIS. "]}, {"cell_type": "code", "execution_count": 33, "metadata": {}, "outputs": [], "source": ["# assign variables to locations on the file system \n", "cwd = os.path.abspath(os.getcwd())\n", "data_path = os.path.join(cwd, r'data')"]}, {"cell_type": "code", "execution_count": 34, "metadata": {}, "outputs": [], "source": ["rft_path = palm_oil_suitability_rft.download(save_path=data_path)"]}, {"cell_type": "markdown", "metadata": {"slideshow": {"slide_type": "subslide"}}, "source": ["### Uploading the RFT to ArcGIS Online using Content Manager
"]}, {"cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": ["palm_oil_suitability_rft_item=gis.content.add(item_properties={\"type\":\"Raster function template\",\n", " \"title\":\"PalmOilSuitability\",\n", " \"tags\":\"PalmOilSuitability_UsingFiveFactors\"\n", " },\n", " data=rft_path\n", " )"]}, {"cell_type": "markdown", "metadata": {"slideshow": {"slide_type": "subslide"}}, "source": ["### Creating the RFT object using the RFT class from raster function template item. "]}, {"cell_type": "code", "execution_count": 4, "metadata": {"slideshow": {"slide_type": "-"}}, "outputs": [], "source": ["palm_oil_suitability_rft = RFT(palm_oil_suitability_rft_item, gis=gis)"]}, {"cell_type": "markdown", "metadata": {"slideshow": {"slide_type": "subslide"}}, "source": ["We can visualize the function chain and help document specific to this RFT in order to understand the input parameters and the functions involved."]}, {"cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [{"data": {"text/html": [" "], "text/plain": [""]}, "execution_count": 2, "metadata": {}, "output_type": "execute_result"}], "source": ["palm_oil_suitability_rft.draw_graph(graph_size='10, 15')"]}, {"cell_type": "markdown", "metadata": {}, "source": ["A '?' before or after an RFT object will display the help document consisting of the parameters marked as public by the author of the RFT."]}, {"cell_type": "code", "execution_count": 12, "metadata": {"slideshow": {"slide_type": "subslide"}}, "outputs": [{"name": "stdout", "output_type": "stream", "text": ["\"\"\"\n", "A raster function template to determine the site suitability for oil palm development.\n", "\n", "Parameters\n", "----------\n", "\n", "ElevRaster : None\n", "SlopeRaster : None\n", "ConsRaster : None\n", "STypeRaster : None\n", "SAcidRaster : None\n", "\n", "Returns\n", "-------\n", "Imagery Layer, on which the function chain is applied \n", "\"\"\"\n"]}], "source": ["palm_oil_suitability_rft?"]}, {"cell_type": "markdown", "metadata": {"slideshow": {"slide_type": "subslide"}}, "source": ["## Creating hosted imagery layers for analysis "]}, {"cell_type": "markdown", "metadata": {}, "source": ["Hosted imagery layers can be used to manage, share, and analyze raster and imagery data. Hosted imagery layers can be used as an input to analysis tools, create custom workflows with raster functions, manage large collections of imagery, and include imagery layers in maps. \n", "\n", "The [copy_raster](https://developers.arcgis.com/python/api-reference/arcgis.raster.analytics.html#copy-raster) function is used here to create hosted imagery layers in ArcGIS Online from local raster datasets.\n", "\n", "In the following cells, we will be creating hosted layers representing the elevation, conservation area buffer, slope, soil type and soil acidity. They will act as the input rasters to the RFT. "]}, {"cell_type": "markdown", "metadata": {}, "source": ["You can acquire the data for analysis by using the following item."]}, {"cell_type": "code", "execution_count": 43, "metadata": {}, "outputs": [{"data": {"text/html": ["\n", "
\n", "\n", "
\n", "
\n", " "], "text/plain": ["- "]}, "execution_count": 43, "metadata": {}, "output_type": "execute_result"}], "source": ["analysis_data = gis.content.get('40b00dc5c8794059811d0cced66e9113')\n", "analysis_data"]}, {"cell_type": "code", "execution_count": 65, "metadata": {}, "outputs": [], "source": ["#downloading the data\n", "analysis_data_path = analysis_data.download(save_path=data_path)\n", "with zipfile.ZipFile(analysis_data_path, 'r') as zip_ref:\n", " zip_ref.extractall(data_path)"]}, {"cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": ["elevation_wm_data_path = os.path.join(os.path.splitext(analysis_data_path)[0], r'elevation_wm')\n", "elevation_wm_item = copy_raster(input_raster=elevation_wm_data_path,\n", " output_name=\"elevation_palm_tiled\",\n", " raster_type_name=\"Raster Dataset\",\n", " tiles_only=True\n", " )\n", "elevation_wm_layer = elevation_wm_item.layers[0]"]}, {"cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [{"data": {"text/html": ["
"], "text/plain": [""]}, "execution_count": 4, "metadata": {}, "output_type": "execute_result"}], "source": ["mp = gis.map()\n", "mp.extent = {'spatialReference': {'latestWkid': 3857, 'wkid': 102100},\n", " 'xmax': 13940786.084357359,\n", " 'xmin': 11533936.937714368,\n", " 'ymax': 495805.2734337793,\n", " 'ymin': -482588.6886162166}\n", "mp.add_layer(elevation_wm_layer)\n", "mp"]}, {"cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": ["conser_wm_data_path = os.path.join(os.path.splitext(analysis_data_path)[0], r'conser_wm')\n", "conser_wm_item = copy_raster(input_raster=conser_wm_data_path,\n", " output_name=\"conser_palm_tiled\", \n", " raster_type_name=\"Raster Dataset\", \n", " tiles_only=True\n", " )\n", "conser_wm_layer = conser_wm_item.layers[0]"]}, {"cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [{"data": {"text/html": [" "], "text/plain": [""]}, "execution_count": 5, "metadata": {}, "output_type": "execute_result"}], "source": ["mp.add_layer(conser_wm_layer)\n", "mp"]}, {"cell_type": "code", "execution_count": 28, "metadata": {"slideshow": {"slide_type": "subslide"}}, "outputs": [], "source": ["slope_wm_path = os.path.join(os.path.splitext(analysis_data_path)[0], r'slope_wm')\n", "slope_wm_item = copy_raster(input_raster=slope_wm_path,\n", " output_name=\"slope_palm_tiled\", \n", " raster_type_name=\"Raster Dataset\",\n", " tiles_only=True\n", " )\n", "slope_wm_layer = slope_wm_item.layers[0]"]}, {"cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [{"data": {"text/html": [" "], "text/plain": [""]}, "execution_count": 7, "metadata": {}, "output_type": "execute_result"}], "source": ["mp.add_layer(slope_wm_layer)\n", "mp"]}, {"cell_type": "code", "execution_count": 30, "metadata": {"slideshow": {"slide_type": "subslide"}}, "outputs": [], "source": ["soil_acid_wm_path = os.path.join(os.path.splitext(analysis_data_path)[0], r'soil_acid_wm')\n", "soil_acid_wm_item = copy_raster(input_raster=soil_acid_wm_path,\n", " output_name=\"soil_acid_palm_tiled\",\n", " raster_type_name=\"Raster Dataset\",\n", " tiles_only=True\n", " )\n", "soil_acid_wm_layer = soil_acid_wm_item.layers[0]"]}, {"cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [{"data": {"text/html": [" "], "text/plain": [""]}, "execution_count": 8, "metadata": {}, "output_type": "execute_result"}], "source": ["mp.add_layer(soil_acid_wm_layer)\n", "mp"]}, {"cell_type": "code", "execution_count": 32, "metadata": {"slideshow": {"slide_type": "subslide"}}, "outputs": [], "source": ["soil_type_wm_path = os.path.join(os.path.splitext(analysis_data_path)[0], r'soil_type_wm')\n", "soil_type_wm_item = copy_raster(input_raster=soil_type_wm_path,\n", " output_name=\"soil_type_palm_tiled\",\n", " raster_type_name=\"Raster Dataset\",\n", " tiles_only=True\n", " )\n", "soil_type_wm_layer = soil_type_wm_item.layers[0]"]}, {"cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [{"data": {"text/html": [" "], "text/plain": [""]}, "execution_count": 9, "metadata": {}, "output_type": "execute_result"}], "source": ["mp.add_layer(soil_type_wm_layer)\n", "mp"]}, {"cell_type": "markdown", "metadata": {"slideshow": {"slide_type": "subslide"}}, "source": ["## Applying the raster function chain on the input layers to create the suitability raster "]}, {"cell_type": "code", "execution_count": 32, "metadata": {"slideshow": {"slide_type": "-"}}, "outputs": [], "source": ["suitability_output = palm_oil_suitability_rft(ElevRaster=elevation_wm_layer,\n", " SlopeRaster=slope_wm_layer , \n", " ConsRaster=conser_wm_layer, \n", " STypeRaster=soil_type_wm_layer, \n", " SAcidRaster=soil_acid_wm_layer\n", " )"]}, {"cell_type": "markdown", "metadata": {"slideshow": {"slide_type": "subslide"}}, "source": ["### Persisting the output in the GIS "]}, {"cell_type": "code", "execution_count": 35, "metadata": {}, "outputs": [], "source": ["saved_output = suitability_output.save(output_name='palm_oil_suitability_saved_til', tiles_only=True)"]}, {"cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [{"data": {"text/html": [" "], "text/plain": [""]}, "execution_count": 12, "metadata": {}, "output_type": "execute_result"}], "source": ["mp.add_layer(saved_output.layers[0])\n", "mp"]}, {"cell_type": "markdown", "metadata": {}, "source": ["In the output, the red areas denote places that are less suitable for oil palm plantation, while green areas represent places that are more suitable."]}, {"cell_type": "markdown", "metadata": {}, "source": ["## Conclusion "]}, {"cell_type": "markdown", "metadata": {}, "source": ["In this notebook, we located potentially suitable areas for sustainable oil palm cultivation. This analysis can act as a first step in a site selection process for a certified sustainable plantation and can inform government officials and nongovernmental organizations (NGOs) in assessing land use policy options to support the expansion of sustainable palm oil production."]}, {"cell_type": "markdown", "metadata": {}, "source": ["## References "]}, {"cell_type": "markdown", "metadata": {}, "source": ["[1] [https://hub.arcgis.com/datasets/afe7ce49f19941fab8db58e2aab90910 ]"]}], "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.6.3"}}, "nbformat": 4, "nbformat_minor": 4}
\ No newline at end of file
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "slideshow": {
+ "slide_type": "subslide"
+ }
+ },
+ "source": [
+ "# Determining site suitability for oil palm plantation "
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "heading_collapsed": true
+ },
+ "source": [
+ "## Table of Contents\n",
+ "\n",
+ "- [Introduction](#introduction)\n",
+ "- [Prerequisites](#prerequisites)\n",
+ "- [Necessary Imports](#imports)\n",
+ "- [Using Raster Function Template ](#rft)\n",
+ " - [Suitability factors taken into consideration in the RFT](#factors)\n",
+ " - [Uploading the RFT to ArcGIS Online using Content Manager](#upload)\n",
+ " - [Creating the RFT object using the RFT class from raster function template item. ](#create)\n",
+ "- [Creating hosted imagery layers for analysis](#layers)\n",
+ "- [Applying the raster function chain on the input layers to create the suitability raster ](#suitability)\n",
+ " - [Persisting the output in the GIS](#op)\n",
+ "- [Conclusion](#conclusion)\n",
+ "- [References](#references)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Introduction "
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Proper land suitability assessment for agriculture has to be carried out to determine the potentiality of a land area to provide the most favorable ecological requirements for a particular crop variety, which results in optimum crop development and maximum productivity. \n",
+ "\n",
+ "In this notebook, we determine the site suitability for oil palm development by: \n",
+ " \n",
+ " - Creating hosted imagery layers. \n",
+ " - Applying raster function chain using the RFT class from the arcgis.raster.functions module.\n",
+ " - Persisting the raster analysis in ArcGIS Online.\n",
+ " \n",
+ "Note: This analysis can be conducted on ArcGIS Enterprise as well as on ArcGIS Online. In this notebook, the notebook was carried out using ArcGIS Online."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Prerequisites "
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "- To run raster analysis functions on ArcGIS Online, you must have privileges to create and publish content and to perform Raster Analysis.\n",
+ "For more information, refer [here](https://doc.arcgis.com/en/arcgis-online/analyze/perform-raster-analysis.htm). \n",
+ "\n",
+ "- For creating imagery layers using [copy_raster](https://developers.arcgis.com/python/api-reference/arcgis.raster.analytics.html#copy-raster) in ArcGIS Online, Azure library packages for Python (Azure SDK for Python - azure-storage-blob: 12.1<= version <=12.8) needs to be pre-installed. Refer https://docs.microsoft.com/en-us/azure/developer/python/azure-sdk-install\n",
+ "\n",
+ "- An optional installation of graphviz 2.38 can be used to visualize the funciton chain of the raster function template. "
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Necessary Imports "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {
+ "slideshow": {
+ "slide_type": "-"
+ }
+ },
+ "outputs": [],
+ "source": [
+ "import os\n",
+ "import zipfile\n",
+ "\n",
+ "import arcgis\n",
+ "from arcgis.gis import GIS, ItemTypeEnum, ItemProperties\n",
+ "from arcgis.raster.analytics import copy_raster\n",
+ "from arcgis.raster.functions import RFT"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "gis = GIS(profile=\"your_online_profile\")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Using Raster Function Template (RFT) "
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "A raster function template is a model that consists of many function chains to produce a processing workflow. We can build the RFT using the function editor and raster functions pane.\n",
+ "\n",
+ "The RFT can be created using [ArcGIS Pro](https://pro.arcgis.com/en/pro-app/latest/help/analysis/raster-functions/raster-function-template.htm) or [ArcGIS Enterprise](https://enterprise.arcgis.com/en/portal/latest/use/raster-function-editor.htm). "
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "slideshow": {
+ "slide_type": "subslide"
+ }
+ },
+ "source": [
+ "### Suitability factors taken into consideration in the RFT \n",
+ "\n",
+ "In order to carry out the suitability analysis, we need to consider some of the favorable environmental and crop criteria settings:\n",
+ "\n",
+ "| Suitability Considerations | Suitable | Not suitable |\n",
+ "| --- | --- | --- |\n",
+ "| Elevation | 0-1000m | >1000 m |\n",
+ "| Slope | 0-30% | >30% |\n",
+ "| Conservation area buffer | >1000 m | <1000m |\n",
+ "| Soil type | Inceptisol, Oxisol, Alfisol, Ultisol, Spodosol, Entisol | Histosols |\n",
+ "| Soil acidity | 1-7 | None |\n",
+ "\n",
+ "\n",
+ "\n",
+ "Based on these criteria, a raster function template was created using ArcGIS Pro. You can acquire the RFT using the following item. "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "
\n",
+ "\n",
+ "
\n",
+ "
\n",
+ " "
+ ],
+ "text/plain": [
+ "- "
+ ]
+ },
+ "execution_count": 6,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "palm_oil_suitability_rft_item = gis.content.get('9fa702ab04f747be99607206c2d0eaaa')\n",
+ "palm_oil_suitability_rft_item"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "The RFT can be further added to your own GIS for further analysis, by downloading the RFT and adding it to your GIS. "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 12,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# assign variables to locations on the file system \n",
+ "cwd = os.path.abspath(os.getcwd())\n",
+ "data_path = os.path.join(cwd, r'data')"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 19,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "rft_path = palm_oil_suitability_rft.download(save_path=data_path)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "slideshow": {
+ "slide_type": "subslide"
+ }
+ },
+ "source": [
+ "### Uploading the RFT to ArcGIS Online using Content Manager
"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 22,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#Fetching root folder\n",
+ "root_folder = gis.content.folders.get()\n",
+ "\n",
+ "#Defining item properties\n",
+ "item_props = ItemProperties(\n",
+ " title = \"PalmOilSuitability\",\n",
+ " item_type = ItemTypeEnum.RASTER_FUNCTION_TEMPLATE,\n",
+ " tags = \"PalmOilSuitability_UsingFiveFactors\"\n",
+ ")"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 23,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#Creating the item\n",
+ "palm_oil_suitability_rft_item1 = root_folder.add(item_properties=item_props,\n",
+ " file=rft_path\n",
+ " )"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "slideshow": {
+ "slide_type": "subslide"
+ }
+ },
+ "source": [
+ "### Creating the RFT object using the RFT class from raster function template item. "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {
+ "slideshow": {
+ "slide_type": "-"
+ }
+ },
+ "outputs": [],
+ "source": [
+ "palm_oil_suitability_rft = RFT(palm_oil_suitability_rft_item, gis=gis)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "slideshow": {
+ "slide_type": "subslide"
+ }
+ },
+ "source": [
+ "We can visualize the function chain and help document specific to this RFT in order to understand the input parameters and the functions involved."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "image/svg+xml": [
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ " \n",
+ "\n",
+ "\n",
+ "0 \n",
+ " \n",
+ "Colormap To RGB Function \n",
+ " \n",
+ "\n",
+ "\n",
+ "1 \n",
+ " \n",
+ "Colormap Function \n",
+ " \n",
+ "\n",
+ "\n",
+ "1->0 \n",
+ " \n",
+ " \n",
+ " \n",
+ "\n",
+ "\n",
+ "2 \n",
+ " \n",
+ "Stretch Function \n",
+ " \n",
+ "\n",
+ "\n",
+ "2->1 \n",
+ " \n",
+ " \n",
+ " \n",
+ "\n",
+ "\n",
+ "3 \n",
+ " \n",
+ "Local Function \n",
+ " \n",
+ "\n",
+ "\n",
+ "3->2 \n",
+ " \n",
+ " \n",
+ " \n",
+ "\n",
+ "\n",
+ "4 \n",
+ " \n",
+ "Elev LT X \n",
+ " \n",
+ "\n",
+ "\n",
+ "4->3 \n",
+ " \n",
+ " \n",
+ " \n",
+ "\n",
+ "\n",
+ "5 \n",
+ " \n",
+ " \n",
+ " \n",
+ "ElevRaster \n",
+ " \n",
+ "\n",
+ "\n",
+ "5->4 \n",
+ " \n",
+ " \n",
+ " \n",
+ "\n",
+ "\n",
+ "6 \n",
+ " \n",
+ "Slope LT 30 \n",
+ " \n",
+ "\n",
+ "\n",
+ "6->3 \n",
+ " \n",
+ " \n",
+ " \n",
+ "\n",
+ "\n",
+ "7 \n",
+ " \n",
+ " \n",
+ " \n",
+ "SlopeRaster \n",
+ " \n",
+ "\n",
+ "\n",
+ "7->6 \n",
+ " \n",
+ " \n",
+ " \n",
+ "\n",
+ "\n",
+ "8 \n",
+ " \n",
+ "Cons GT 1000 \n",
+ " \n",
+ "\n",
+ "\n",
+ "8->3 \n",
+ " \n",
+ " \n",
+ " \n",
+ "\n",
+ "\n",
+ "9 \n",
+ " \n",
+ " \n",
+ " \n",
+ "ConsRaster \n",
+ " \n",
+ "\n",
+ "\n",
+ "9->8 \n",
+ " \n",
+ " \n",
+ " \n",
+ "\n",
+ "\n",
+ "10 \n",
+ " \n",
+ "SType IN 1 2 3 5 6 7 8 \n",
+ " \n",
+ "\n",
+ "\n",
+ "10->3 \n",
+ " \n",
+ " \n",
+ " \n",
+ "\n",
+ "\n",
+ "11 \n",
+ " \n",
+ " \n",
+ " \n",
+ "STypeRaster \n",
+ " \n",
+ "\n",
+ "\n",
+ "11->10 \n",
+ " \n",
+ " \n",
+ " \n",
+ "\n",
+ "\n",
+ "12 \n",
+ " \n",
+ "SAcid IN BET 1 7 \n",
+ " \n",
+ "\n",
+ "\n",
+ "12->3 \n",
+ " \n",
+ " \n",
+ " \n",
+ "\n",
+ "\n",
+ "13 \n",
+ " \n",
+ " \n",
+ " \n",
+ "SAcidRaster \n",
+ " \n",
+ "\n",
+ "\n",
+ "13->12 \n",
+ " \n",
+ " \n",
+ " \n",
+ " \n",
+ " \n"
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "execution_count": 8,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "palm_oil_suitability_rft.draw_graph(graph_size='10, 15')"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "A '?' before or after an RFT object will display the help document consisting of the parameters marked as public by the author of the RFT."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 9,
+ "metadata": {
+ "slideshow": {
+ "slide_type": "subslide"
+ }
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\"\"\"\n",
+ "A raster function template to determine the site suitability for oil palm development.\n",
+ "\n",
+ "Parameters\n",
+ "----------\n",
+ "\n",
+ "ElevRaster : None\n",
+ "SlopeRaster : None\n",
+ "ConsRaster : None\n",
+ "STypeRaster : None\n",
+ "SAcidRaster : None\n",
+ "\n",
+ "Returns\n",
+ "-------\n",
+ "Imagery Layer, on which the function chain is applied \n",
+ "\"\"\"\n"
+ ]
+ },
+ {
+ "data": {
+ "text/plain": [
+ "\u001b[0;31mSignature:\u001b[0m \n",
+ "\u001b[0mpalm_oil_suitability_rft\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\u001b[0m\n",
+ "\u001b[0;34m\u001b[0m \u001b[0mElevRaster\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
+ "\u001b[0;34m\u001b[0m \u001b[0mSlopeRaster\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
+ "\u001b[0;34m\u001b[0m \u001b[0mConsRaster\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
+ "\u001b[0;34m\u001b[0m \u001b[0mSTypeRaster\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
+ "\u001b[0;34m\u001b[0m \u001b[0mSAcidRaster\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
+ "\u001b[0;34m\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
+ "\u001b[0;31mCall signature:\u001b[0m \u001b[0mpalm_oil_suitability_rft\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
+ "\u001b[0;31mType:\u001b[0m RFT\n",
+ "\u001b[0;31mString form:\u001b[0m \n",
+ "\u001b[0;31mFile:\u001b[0m /opt/conda/lib/python3.11/site-packages/arcgis/raster/functions/__init__.py\n",
+ "\u001b[0;31mDocstring:\u001b[0m "
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "palm_oil_suitability_rft?"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "slideshow": {
+ "slide_type": "subslide"
+ }
+ },
+ "source": [
+ "## Creating hosted imagery layers for analysis "
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Hosted imagery layers can be used to manage, share, and analyze raster and imagery data. Hosted imagery layers can be used as an input to analysis tools, create custom workflows with raster functions, manage large collections of imagery, and include imagery layers in maps. \n",
+ "\n",
+ "The [copy_raster](https://developers.arcgis.com/python/api-reference/arcgis.raster.analytics.html#copy-raster) function is used here to create hosted imagery layers in ArcGIS Online from local raster datasets.\n",
+ "\n",
+ "In the following cells, we will be creating hosted layers representing the elevation, conservation area buffer, slope, soil type and soil acidity. They will act as the input rasters to the RFT. "
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "You can acquire the data for analysis by using the following item."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "
\n",
+ "\n",
+ "
\n",
+ "
\n",
+ " "
+ ],
+ "text/plain": [
+ "- "
+ ]
+ },
+ "execution_count": 10,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "analysis_data = gis.content.get('40b00dc5c8794059811d0cced66e9113')\n",
+ "analysis_data"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 13,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#downloading the data\n",
+ "analysis_data_path = analysis_data.download(save_path=data_path)\n",
+ "with zipfile.ZipFile(analysis_data_path, 'r') as zip_ref:\n",
+ " zip_ref.extractall(data_path)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 15,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "elevation_wm_data_path = os.path.join(os.path.splitext(analysis_data_path)[0], r'elevation_wm')\n",
+ "elevation_wm_item = copy_raster(input_raster=elevation_wm_data_path,\n",
+ " output_name=\"elevation_palm_tiled\",\n",
+ " raster_type_name=\"Raster Dataset\",\n",
+ " tiles_only=True\n",
+ " )\n",
+ "elevation_wm_layer = elevation_wm_item.layers[0]"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "
"
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "execution_count": 1,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "m1 = gis.map()\n",
+ "m1.extent = {'spatialReference': {'latestWkid': 3857, 'wkid': 102100},\n",
+ " 'xmax': 13940786.084357359,\n",
+ " 'xmin': 11533936.937714368,\n",
+ " 'ymax': 495805.2734337793,\n",
+ " 'ymin': -482588.6886162166}\n",
+ "m1.content.add(elevation_wm_layer)\n",
+ "m1"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 17,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "conser_wm_data_path = os.path.join(os.path.splitext(analysis_data_path)[0], r'conser_wm')\n",
+ "conser_wm_item = copy_raster(input_raster=conser_wm_data_path,\n",
+ " output_name=\"conser_palm_tiled5\", \n",
+ " raster_type_name=\"Raster Dataset\", \n",
+ " tiles_only=True\n",
+ " )\n",
+ "conser_wm_layer = conser_wm_item.layers[0]"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ " "
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "execution_count": 2,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "m2 = gis.map()\n",
+ "m2.extent = {'spatialReference': {'latestWkid': 3857, 'wkid': 102100},\n",
+ " 'xmax': 13940786.084357359,\n",
+ " 'xmin': 11533936.937714368,\n",
+ " 'ymax': 495805.2734337793,\n",
+ " 'ymin': -482588.6886162166}\n",
+ "m2.content.add(conser_wm_layer)\n",
+ "m2"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 19,
+ "metadata": {
+ "slideshow": {
+ "slide_type": "subslide"
+ }
+ },
+ "outputs": [],
+ "source": [
+ "slope_wm_path = os.path.join(os.path.splitext(analysis_data_path)[0], r'slope_wm')\n",
+ "slope_wm_item = copy_raster(input_raster=slope_wm_path,\n",
+ " output_name=\"slope_palm_tiled5\", \n",
+ " raster_type_name=\"Raster Dataset\",\n",
+ " tiles_only=True\n",
+ " )\n",
+ "slope_wm_layer = slope_wm_item.layers[0]"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ " "
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "execution_count": 3,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "m3 = gis.map()\n",
+ "m3.extent = {'spatialReference': {'latestWkid': 3857, 'wkid': 102100},\n",
+ " 'xmax': 13940786.084357359,\n",
+ " 'xmin': 11533936.937714368,\n",
+ " 'ymax': 495805.2734337793,\n",
+ " 'ymin': -482588.6886162166}\n",
+ "m3.content.add(slope_wm_layer)\n",
+ "m3"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 21,
+ "metadata": {
+ "slideshow": {
+ "slide_type": "subslide"
+ }
+ },
+ "outputs": [],
+ "source": [
+ "soil_acid_wm_path = os.path.join(os.path.splitext(analysis_data_path)[0], r'soil_acid_wm')\n",
+ "soil_acid_wm_item = copy_raster(input_raster=soil_acid_wm_path,\n",
+ " output_name=\"soil_acid_palm_tiled5\",\n",
+ " raster_type_name=\"Raster Dataset\",\n",
+ " tiles_only=True\n",
+ " )\n",
+ "soil_acid_wm_layer = soil_acid_wm_item.layers[0]"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ " "
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "execution_count": 4,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "m4 = gis.map()\n",
+ "m4.extent = {'spatialReference': {'latestWkid': 3857, 'wkid': 102100},\n",
+ " 'xmax': 13940786.084357359,\n",
+ " 'xmin': 11533936.937714368,\n",
+ " 'ymax': 495805.2734337793,\n",
+ " 'ymin': -482588.6886162166}\n",
+ "m4.content.add(soil_acid_wm_layer)\n",
+ "m4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 23,
+ "metadata": {
+ "slideshow": {
+ "slide_type": "subslide"
+ }
+ },
+ "outputs": [],
+ "source": [
+ "soil_type_wm_path = os.path.join(os.path.splitext(analysis_data_path)[0], r'soil_type_wm')\n",
+ "soil_type_wm_item = copy_raster(input_raster=soil_type_wm_path,\n",
+ " output_name=\"soil_type_palm_tiled5\",\n",
+ " raster_type_name=\"Raster Dataset\",\n",
+ " tiles_only=True\n",
+ " )\n",
+ "soil_type_wm_layer = soil_type_wm_item.layers[0]"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ " "
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "execution_count": 6,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "m5 = gis.map()\n",
+ "m5.extent = {'spatialReference': {'latestWkid': 3857, 'wkid': 102100},\n",
+ " 'xmax': 13940786.084357359,\n",
+ " 'xmin': 11533936.937714368,\n",
+ " 'ymax': 495805.2734337793,\n",
+ " 'ymin': -482588.6886162166}\n",
+ "m5.content.add(soil_type_wm_layer)\n",
+ "m5"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "slideshow": {
+ "slide_type": "subslide"
+ }
+ },
+ "source": [
+ "## Applying the raster function chain on the input layers to create the suitability raster "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 25,
+ "metadata": {
+ "slideshow": {
+ "slide_type": "-"
+ }
+ },
+ "outputs": [],
+ "source": [
+ "suitability_output = palm_oil_suitability_rft(ElevRaster=elevation_wm_layer,\n",
+ " SlopeRaster=slope_wm_layer , \n",
+ " ConsRaster=conser_wm_layer, \n",
+ " STypeRaster=soil_type_wm_layer, \n",
+ " SAcidRaster=soil_acid_wm_layer\n",
+ " )"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "slideshow": {
+ "slide_type": "subslide"
+ }
+ },
+ "source": [
+ "### Persisting the output in the GIS "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 26,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "saved_output = suitability_output.save(output_name='palm_oil_suitability_saved_tile1', tiles_only=True)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ " "
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "execution_count": 7,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "m6 = gis.map()\n",
+ "m6.extent = {'spatialReference': {'latestWkid': 3857, 'wkid': 102100},\n",
+ " 'xmax': 13940786.084357359,\n",
+ " 'xmin': 11533936.937714368,\n",
+ " 'ymax': 495805.2734337793,\n",
+ " 'ymin': -482588.6886162166}\n",
+ "m6.content.add(saved_output.layers[0])\n",
+ "m6"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "In the output, the red areas denote places that are less suitable for oil palm plantation, while green areas represent places that are more suitable."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Conclusion "
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "In this notebook, we located potentially suitable areas for sustainable oil palm cultivation. This analysis can act as a first step in a site selection process for a certified sustainable plantation and can inform government officials and nongovernmental organizations (NGOs) in assessing land use policy options to support the expansion of sustainable palm oil production."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## References "
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "[1] [https://www.arcgis.com/home/item.html?id=afe7ce49f19941fab8db58e2aab90910]"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3 (ipykernel)",
+ "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.11.10"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 4
+}