I am not sure if this is possible, at least I could not find the solution. I have a raster and each pixel has a value. What I try to do is to write a function that finds:
- The 5 pixels the distance between those is maximized. Say the 5 pixels most far away from each other.
- And, at the same time, the value of those pixels is the maximum possible while satisfying the first condition.
The raster looks like below, yet this question is general and may be applied to any sort of rasters. Particularly this raster has values on solar radiation (W/m2). http://www.mediafire.com/download/t7xl9adxz3764f3/solar_dni_20130102_00UT.txt
setwd("/Users/mercel/Documents/Australia") library(SDMTools) library(raster) file.rename("solar_dni_20130102_11UT.txt", "solar_dni_20130102_11UT.asc") dat <- read.asc("solar_dni_20130102_11UT.asc") str(dat) r <- raster.from.asc(dat) ...
The version I am using is ArcMap 10.2. And I have Python 27 and Python 35 installed. I have tried to do it applying 'Euclidean Distance' and other functions per default in Desktop, yet I believe this may required some sort of optimization coding, which I do not have previous experience with. Hence I cannot provide an example of the code developed so far, because really I don't know even where to start from. Therefore someone with more experience than I, may know how to approach this problem.
Error found by executing the code of FelixIP below, in the Python window of ArcMap 10.2:
Runtime error Traceback (most recent call last): File "<string>", line 24, in <module> File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\__init__.py", line 202, in SetProgressor return gp.setProgressor(type, message, min_range, max_range, step_value) File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\geoprocessing\_base.py", line 83, in setProgressor self._gp.SetProgressor(*gp_fixargs(args, True))) AttributeError: Object: Error in parsing arguments for SetProgressor
Error when copying the .py into C:\Python27\ArcGIS10.2\Lib\site-packages\pythonwin, and try to run it from PythonWin 2.7.5 (32):
File "C:\Python27\ArcGIS10.2\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 323, in RunScript debugger.run(codeObject, __main__.__dict__, start_stepping=0) File "C:\Python27\ArcGIS10.2\Lib\site-packages\pythonwin\pywin\debugger\__init__.py", line 60, in run _GetCurrentDebugger().run(cmd, globals,locals, start_stepping) File "C:\Python27\ArcGIS10.2\Lib\site-packages\pythonwin\pywin\debugger\debugger.py", line 654, in run exec cmd in globals, locals File "C:\Python27\ArcGIS10.2\Lib\site-packages\pythonwin\Script.py", line 1, in <module> try: arcpy NameError: name 'time' is not defined`