Friday, February 22, 2019

PYTHON SCRIPT IN ARC GIS - CLIP ANALYSIS


PYTHON SCRIPT IN ARC GIS
GEOPROCESSING TOOL
CLIP
How to do Clip analysis?
You can refer to the video tutorial here.
To do Clip analysis, we need one Input vector layer (i.e. file with .shp extension). E.g. province.shp

Let’s take a shape file named “province4.shp” as Clip boundary

Then we need to save the output layer obtained after Clip analysis. Let’s take name for the output clipped layer as “Province4_clipped.shp”

These two are the arguments/parameters of clip analysis, which we will use in python script.

Let’s code…
Import arcpy
>>> From arcpy.sa import *

Store the address of input layer i.e. province.shp
>>> input = r'E:\HYDROLOGY\S2\ArcPY\Province_of_Nepal\Nepal_Province.shp'

Store the address of clip layer i.e. province4.shp
>>> clipLayer = r'E:\HYDROLOGY\S2\ArcGis\Province4.shp'

Store the address of output clipped layer i.e. Province4_clipped.shp
>>> output = r'E:\HYDROLOGY\S2\ArcPY\OUTPUT\Province4_Clipped.shp'

Execute arcpy.clip_analysis() command
>>> arcpy.Clip_analysis(input, clipLayer, output)

You can execute this command by two methods.
Method 1: write “arcpy.clip_analysis()”
Method 2: drag and drop tool from arc tool box…

Help
You can see help in a window adjacent to the python console. If you cannot see the help window, you can-
1. right click on the python console
2. go to help placement and choose your option
In the help window, you can see the arguments/parameters highlighted with yellow color. This shows which arguments/parameters you are currently entering.
The parameters within braces { } are optional.
After pressing enter, output file will be saved to the output folder. Look in output folder, where your file is saved.

You can see clip working, in status bar and you will get a message after completion in a blue window at bottom right corner of your screen.


This is how you can use clip analysis of Arc GIS in python console.

Full code:
>>> From arcpy.sa import *
>>> input = r'E:\HYDROLOGY\S2\ArcPY\Province_of_Nepal\Nepal_Province.shp'
>>> clipLayer = r'E:\HYDROLOGY\S2\ArcGis\Province4.shp'
>>> output = r'E:\HYDROLOGY\S2\ArcPY\OUTPUT\Province4_Clipped.shp'
>>> arcpy.Clip_analysis(input, clipLayer, output)



No comments:

Post a Comment

MOST RECENT

BITUMEN, ASPHALT, COAL TAR, CUTBACK BITUMEN

Ever wondered what is Bitumen? What is Asphalt? What is difference between these two? What is MC 30 Bitumen? What is cutback bitumen? We wil...