CLAWRIM Wiki

Computing Lab for Advanced Water Resources Informatics and Modeling

User Tools

Site Tools


canopy:tutorial

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
canopy:tutorial [2020-03-13 11:04 am] – ToDo unchecked: Write a tutorial using the sample data like CanoPy for dummies osmithcanopy:tutorial [2020-04-19 08:49 pm] (current) hcho
Line 14: Line 14:
   * ArcPy   * ArcPy
   * Python 2 standard module: os   * Python 2 standard module: os
-  * Feature Analyst(tm) by the Textron Systems 
-  * Automated Feature Extraction (AFE) models trained using Feature Analyst 
  
 We are currently planning on developing a fully open source solution without using ArcGIS and Feature Analyst. We are currently planning on developing a fully open source solution without using ArcGIS and Feature Analyst.
Line 23: Line 21:
 {{ :canopy:canopy_sample_data.zip |}} {{ :canopy:canopy_sample_data.zip |}}
  
-===== TODOs =====+The sample data will contain 3 folders titled ‘naip’, ‘data’, and ‘Outputs’. The ‘data’ folder contains the Georgia physiographic regions shapefile, the NAIP Quarter Quad (QQ) polygon shapefile in addition to the TIFF file which will be used for snapping. The ‘naip’ folder will contain 4 input QQ NAIP tiles that form a 2 x 2 area. The ‘Outputs’ folder contains the outputs that are created by Textron’s Feature Analysis software for each NAIP QQ in the sample dataset. This is included as this tutorial does NOT go over the process of using Textrons Feature Analyst but rather the process of using the CanoPy Python module.
  
-<todo @owen>Write a tutorial using the sample data like CanoPy for dummies</todo> +===== Steps =====
-====CanoPy Tutorial==== +
- +
-Sample  Data Contents: +
- +
-The sample data will contain folders titled ‘naip’, ‘data’, and ‘Blue_Ridge_Mountains’. The ‘data’ folder contains the Georgia physiographic regions shapefile, the NAIP Quarter Quad (QQ) polygon shapefile in addition to the TIFF file which will be used for snapping. The ‘naip’ folder will contain 4 input QQ NAIP tiles that form a 2 x 2 area. The ‘Blue_Ridge_Mountains’ folder contains the outputs that are created by Textron’s Feature Analysis software for each QQ. This is included so if the user does not possess a Textron license they can still run the process on the sample data.  +
- +
-Steps:+
  
   - Either clone the repository using Git in the terminal with the below code <code>   - Either clone the repository using Git in the terminal with the below code <code>
-    git clone https://github.com/HuidaeCho/canopy.git +git clone https://github.com/HuidaeCho/canopy.git 
-    </code>  OR visit the [[https://github.com/HuidaeCho/canopy|CanoPy GitHub repository]] and       download the zip file. +</code>  OR visit the [[https://github.com/HuidaeCho/canopy|CanoPy GitHub repository]] and       download the zip file. 
     * If you download the .zip file you will first need to unzip the file. It will be named ‘canopy-master’, rename this folder to ‘canopy’.     * If you download the .zip file you will first need to unzip the file. It will be named ‘canopy-master’, rename this folder to ‘canopy’.
   - Download the CanoPy sample data from this page and extract it from its .zip format.   - Download the CanoPy sample data from this page and extract it from its .zip format.
Line 60: Line 51:
   -  Open the Python window under the geoprocessing pane located on the top bar within ArcMap.   -  Open the Python window under the geoprocessing pane located on the top bar within ArcMap.
   -  After the Python window is open you must import the CanoPy module for ArcMap to be able to use its functions. To accomplish this use the following code. <code python>   -  After the Python window is open you must import the CanoPy module for ArcMap to be able to use its functions. To accomplish this use the following code. <code python>
-      import sys +import sys 
-      sys.path.append('C:/path/to/the/canopy/module'+sys.path.append('C:/path/to/the/canopy/module'
-      import canopy +import canopy 
-      </code>+</code>
   -  Most functions in CanoPy only contain one parameter, ''phyreg_ids''. This is the unique identifier for each physiographic region that enables the user to decide which region to process. In this case you will be using the id ''[3]'' which is the ''phyreg_id'' of the Blue Ridge Mountains region. However, to first be able to use the id’s you have to add the id’s to the '' naipqq_layer''. To do this simply run the following code in the Python window.<code python>   -  Most functions in CanoPy only contain one parameter, ''phyreg_ids''. This is the unique identifier for each physiographic region that enables the user to decide which region to process. In this case you will be using the id ''[3]'' which is the ''phyreg_id'' of the Blue Ridge Mountains region. However, to first be able to use the id’s you have to add the id’s to the '' naipqq_layer''. To do this simply run the following code in the Python window.<code python>
-     canopy.assign_phyregs_to_naipqq() +canopy.assign_phyregs_to_naipqq() 
-     </code>+</code>
     * After it is finished the ''naipqq_layer'' will now contain the '' naipqq_phyregs_field'' which will be titled ‘PHYREGS’ in this case. Each NAIP QQ will now have the region id’s of each region it is in.      * After it is finished the ''naipqq_layer'' will now contain the '' naipqq_phyregs_field'' which will be titled ‘PHYREGS’ in this case. Each NAIP QQ will now have the region id’s of each region it is in. 
-    * The secondary purpose of ''canopy.assign_phyregs_to_naipqq'' is to calculate the area in square kilometers of each physiographic region. The ''phyregs_layer'' will now contain the '' phyregs_area_sqkm_field'' which will be titled ‘AREA_SQKM’. The ‘AREA_SQKM’ field will be used with the ''generate_ground_truthing_points'' function. +    * The secondary purpose of ''canopy.assign_phyregs_to_naipqq'' is to calculate the area in square kilometers of each physiographic region. The ''phyregs_layer'' will now contain the '' phyregs_area_sqkm_field'' which will be titled ‘AREA_SQKM’. The ‘AREA_SQKM’ field will be used with the ''generate_gtpoints'' function. 
   -  Next you will assign the phyreg_ids, which in our case will be:<code python>   -  Next you will assign the phyreg_ids, which in our case will be:<code python>
-       phyreg_ids = [3] +phyreg_ids = [3] 
-       </code>+</code>
      * If more regions were able to process you would assign those regions as such: <code python>      * If more regions were able to process you would assign those regions as such: <code python>
 phyreg_ids = [3, 7, 15] phyreg_ids = [3, 7, 15]
 </code> </code>
   -  Next you will reproject all input NAIP tiles to the projection specified by the '' spatref_wkid'' in ''canopy_config'' which will be [[https://spatialreference.org/ref/sr-org/usa-contiguous-albers-equal-area-conic-usgs-version-landfire/|WKID-102039: USA Contiguous Albers Equal Area Conic USGS version.]]. Use the following code to use the reprojection function<code python>   -  Next you will reproject all input NAIP tiles to the projection specified by the '' spatref_wkid'' in ''canopy_config'' which will be [[https://spatialreference.org/ref/sr-org/usa-contiguous-albers-equal-area-conic-usgs-version-landfire/|WKID-102039: USA Contiguous Albers Equal Area Conic USGS version.]]. Use the following code to use the reprojection function<code python>
-       canopy.reproject_input_tiles(phyreg_ids) +canopy.reproject_naip_tiles(phyreg_ids) 
-      </code>+</code>
     * Reprojected tiles with the suffix ‘rm_’ will be saved to ''.../CanoPy_sample_data/2009 Analysis/Blue_Ridge_Mountains/Inputs'' which will have been created by the function.     * Reprojected tiles with the suffix ‘rm_’ will be saved to ''.../CanoPy_sample_data/2009 Analysis/Blue_Ridge_Mountains/Inputs'' which will have been created by the function.
   -  The reprojected tiles in the Inputs folder will be used in as the inputs with Textrons Feature Analyst, however we are skipping that step, so you will want to move the ''.../CanoPy_sample_data/Outputs/'' folder to the ''.../CanoPy_sample_data/2009 Analysis/Blue_Ridge_Mountains'' folder. This is where the classified outputs of Textrons Feature Analyst would have been saved to be used with the rest of the CanoPy functions.   -  The reprojected tiles in the Inputs folder will be used in as the inputs with Textrons Feature Analyst, however we are skipping that step, so you will want to move the ''.../CanoPy_sample_data/Outputs/'' folder to the ''.../CanoPy_sample_data/2009 Analysis/Blue_Ridge_Mountains'' folder. This is where the classified outputs of Textrons Feature Analyst would have been saved to be used with the rest of the CanoPy functions.
canopy/tutorial.1584119062.txt.gz · Last modified: 2020-03-13 11:04 am by osmith

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki