-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreateValidationFiles.py
More file actions
33 lines (27 loc) · 1.42 KB
/
CreateValidationFiles.py
File metadata and controls
33 lines (27 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------
# CreateValidationFields.py
# Created on: 2014-04-14 1251
# Description: Create files for land cover classification validation
# ---------------------------------------------------------------------------
# Create Random points within streets_buffer
# Straitification
# Raster to polygon
# Create random points in each strata
# Convert it to 3m * 3m square (later)
# Record the ground truth and classification result one by one
# Create Confusion matrix
import arcpy
arcpy.env.overwriteOutput = 1 # enable overwriting
arcpy.env.workspace = "c:/Users/koitaroh/Documents/ArcGIS/Default.gdb"
inRaster = arcpy.GetParameterAsText(0)
outPoint = arcpy.GetParameterAsText(1)
try:
arcpy.RasterToPolygon_conversion(inRaster, "tmpRasterToPolygon", "NO_SIMPLIFY", "Value")
# Create 10 random points in each class polygon
for x in xrange(1,8):
arcpy.Select_analysis("tmpRasterToPolygon", "tmpRasterToPolygon_%d" % (x), 'gridcode = %d AND Shape_Area >= 9' % (x))
arcpy.Dissolve_management("tmpRasterToPolygon_%d" % (x), "tmpRasterToPolygon_%d_%d" % (x,x))
arcpy.CreateRandomPoints_management("c:/Users/koitaroh/Documents/ArcGIS/Default.gdb", "RandomPoints_%d" % (x), "tmpRasterToPolygon_%d_%d" % (x,x), "tmpRasterToPolygon_%d_%d" % (x,x), "10")
except:
print arcpy.GetMessages(2)