是否有可能从控制器更改参数 params:{source:$ scope.chartr1} - 我想调用带有可变参数的php文件。
import arcpy
arcpy.CheckOutExtension("Spatial")
from PIL import Image
import matplotlib.pyplot as plt
import numpy as np
from skimage import io
from skimage.segmentation import quickshift
arcpy.env.overwriteOutput = True
# The input 4-band NAIP image
img = r'C:\Users\Alekhya\Desktop\Krishna\NRSC\processed image\newclip4\clip4.tif'
# Convert image to numpy array
imgarr = io.imread(img)
print imgarr
print imgarr.shape
print imgarr.dtype
# Run the quick shift segmentation
segments = quickshift(imgarr, kernel_size=3, convert2lab=False, max_dist=6, ratio=0.5)
print("Quickshift number of segments: %d" % len(np.unique(segments)))
# View the segments via Python
plt.imshow(segments)
print segments
print segments.shape
print type(segments)
print segments.dtype
# Get raster metrics for coordinate info
imgRaster = arcpy.sa.Raster(img)
# Lower left coordinate of block (in map units)
mx = imgRaster.extent.XMin
my = imgRaster.extent.YMin
sr = imgRaster.spatialReference
'''
# Note the use of arcpy to convert numpy array to raster
seg = arcpy.NumPyArrayToRaster(segments, arcpy.Point(mx,my), imgRaster.meanCellWidth, imgRaster.meanCellHeight)
outRaster = r'C:\Users\Alekhya\Desktop\Krishna\NRSC\processed image\newclip4\segments_clip4.tif'
seg_temp = seg.save(outRaster)
arcpy.DefineProjection_management(outRaster, sr)
'''
# Calculate NDVI from bands 4 and 3
b4 = arcpy.sa.Raster(r'C:\Users\Alekhya\Desktop\Krishna\NRSC\processed image\newclip4\clip4.tif\Band_4')
b3 = arcpy.sa.Raster(r'C:\Users\Alekhya\Desktop\Krishna\NRSC\processed image\newclip4\clip4.tif\Band_3')
ndvi = arcpy.sa.Float(b4-b3) / arcpy.sa.Float(b4+b3)
print ndvi
# Extract NDVI values based on image object boundaries
zones = arcpy.sa.ZonalStatistics(segments, "VALUE", ndvi, "MEAN")
zones.save(r'C:\Users\Alekhya\Desktop\Krishna\NRSC\processed image\newclip4\zones_clip4.tif')
# Classify the segments based on NDVI values
binary = arcpy.sa.Con(zones < 20, 1, 0)
binary.save(r'C:\Users\Alekhya\Desktop\Krishna\NRSC\processed image\newclip4\classified_clip4.tif')
答案 0 :(得分:0)
问题是,一旦控制器运行,您就会使用默认参数调用$ http。您应该在函数中编写$ http部分,并仅在用户准备好时(即更改输入后)调用它。
$scope.request = function() {
$http.get('xxx.php', {params: source:$scope.chartr1})...
}
<input ng-model="chartr1">
<button type="button" ng-click="request()">submit</button>