POST
|
A nested "Con" statement might do the trick... it can handle floats, right?
... View more
09-08-2011
01:52 PM
|
0
|
0
|
375
|
POST
|
I'm realizing my 11 classes would require 64-bit data to perform the analysis described above,whereas the reclassify tool is obviously limited to 32-bit based maximum value(2147483648). Any suggestions? Ideally the reclass would be as follows: (input:output) 1:1 2:10 3:100 4:1000 5:10000 6:10000 . . . 11: 10000000000 I've considered using 32-bit float and using decimal places, but again reclassify outputs must be integers! Any advice? Thanks, James
... View more
09-08-2011
01:41 PM
|
0
|
0
|
375
|
POST
|
One additional approach, which might be more closely aligned with the available tools in Spatial Analyst is to reclassify the landcover classification in such a way that a focal sum could create unique outputs based on the values within the neighborhood window e.g. quadrant1 (3 x 3 grid) = 100,000 + 10,000 + 1,000 + 100 + 10 + 1 = 111,111 quadrant2 = 10,000 + 10,000 + 1,000 + 100 + 100 + 10 = 21,210 such an approach would give both what amounts to a list of values and the relative abundance of each class. From there, you could simply calculate a second focal stats using 'variety"...
... View more
09-08-2011
10:53 AM
|
0
|
0
|
375
|
POST
|
At its simplest, I'd like to create a list of values within quadrants (neighborhood/window) and then compare the contents of those lists. The first step would be to create a list of values -- is that possible using spatial analyst?
... View more
09-08-2011
09:52 AM
|
0
|
0
|
375
|
POST
|
Hi folks, I'm trying to work out a method to calculate the "beta"-diversity given a Landsat vegetation classification -- essentially to determine how patterns of vegetation change across a landscape. Unlike "richness" which could be easily calculated using focal stats ("variety"), I'm trying to determine how the composition of the classification changes in space. More on beta-diversity here: http://en.wikipedia.org/wiki/Beta_diversity (It's essentially a measure of similarity) Theoretically this could be done using features and Python lists (searchcursor) -- eg. create a new list for each quadrant of the classifications values, for intance: quadrant 1 = [1,2,3,4,5] quadrant 2 = [3,6,8,9] and then based on the location of the quadrants (lat-long), I could create a pseudo-moving window to compare the contents of each list for adjacent or nearby quadrants. Problem is this is >1GB raster that I'm starting with (30m resolution), so conversion to shapefile and subsequent processing is going to be super-slow. Any ideas as how to perform something akin to what I have described above using the spatial analyst tools? Unfortunately, I don't see a simple focal stats approach here... but perhaps I am missing something. The other approach I've considered is creating raster dataset for each classification value and then using a local analysis, but unfortunately I run across the same limitation, which is actually implementing the beta-diversity algorithm/calculation... Any thoughts would be greatly appreciated! For comparison the closest post on here I can find is: http://forums.arcgis.com/threads/20900-How-do-I-make-a-calculation-on-a-raster-file-within-a-specific-neighbourhood?highlight=raster+diversity
... View more
09-08-2011
09:16 AM
|
0
|
4
|
1076
|
POST
|
The overwrite option is a good idea as well. Although, when implementing that approach, I find I need to be carefule to use "arcpy.Exists(output_feature) != True:" to ensure that I don't go overwriting everything... That could be the simplest solution, if you aren't considered about lossing outputs that have already been created.
... View more
05-05-2011
11:57 AM
|
0
|
0
|
317
|
POST
|
Thanks, Mathew. That would also work. I was expecting a simple solution, but couldn't find the tool. Thanks! James
... View more
05-05-2011
08:04 AM
|
0
|
0
|
317
|
POST
|
I'm attempting to perform what I thought would be a simple series of select by locations using arcpy -- e.g. create feature layers for each input feature and select feature and then complete the select by location.
boundary_file_list = arcpy.ListFeatureClasses()
for boundary_file in boundary_file_list:
arcpy.MakeFeatureLayer_management(boundary_file, "bnd_lyr")
arcpy.MakeFeatureLayer_management(copy_ft, "in_lyr")
arcpy.SelectLayerByLocation_management ("in_lyr", "INTERSECT", "bnd_lyr")
arcpy.CopyFeatures_management("in_lyr", output_ft) But I get an error message on the second round of the processing, as the boundary feature layer already exists: ExecuteError: Failed to execute. Parameters are not valid. ERROR 000725: Output Layer: Dataset bnd_lyr already exists. Failed to execute (MakeFeatureLayer). Does that mean I have create a unique boundary layer name for each iteration of the series? Eg. "bnd_lyr" + str(x) , while x >= 0 and x< 10 ? Is there some other way to remove or delete the feature layer? Many thanks!
... View more
05-05-2011
07:47 AM
|
0
|
6
|
1062
|
POST
|
The Reclassify approach seems to be most promising; no success yet, but here's a slight change to that code: try:
in_raster = CAVM_het_output
reclass_field = "VALUE"
valueMAX = arcpy.GetRasterProperties_management(CAVM_het_output, "MAXIMUM")
print "max = ", valueMAX
valueMIN = arcpy.GetRasterProperties_management(CAVM_het_output, "MINIMUM")
print "min = ", valueMIN
remap = RemapRange([[value99, 585, 99], [value95, value99, 95], [value90, value95, 90], [value85, value90, 85],[value80, value85, 80], [0, value80, 0]])
print "remap = ", remap
outRas = Reclassify(in_raster, reclass_field, remap, "NODATA")
print "outRas created"
print "Reclassify statement completed"
except Exception as e:
print e.message Which produces the remap statement: remap = 565.0 585 99; 546.0 565.0 95; 525.0 546.0 90; 504.0 525.0 85; 483.0 504.0 80; 0 483.0 0 Problem is, now Python crashes when it attempts the Reclassify processing step!
... View more
01-19-2011
07:50 AM
|
0
|
0
|
222
|
POST
|
Hi, In 9.3, I had successfully applied the following nested Con statement: while row:
value = row.getvalue("ID")
if value == ID99:
print "Value99..."
value99 = row.getvalue("VALUE")
print value99
elif value == ID95:
print "Value95..."
value95 = row.getvalue("VALUE")
print value95
elif value == ID90:
print "Value90..."
value90 = row.getvalue("VALUE")
print value90
elif value == ID85:
print "Value85..."
value85 = row.getvalue("VALUE")
print value85
elif value == ID80:
print "Value80..."
value80 = row.getvalue("VALUE")
print value80
row = rows.Next()
gp.SingleOutputMapAlgebra_sa("CON ( " + str(raster) + " >= " + str(value99) + ", 99 , CON ( " + str(raster) + " >= " + str(value95) + ", 95, CON ( " + str(raster) + " >= " + str(value90) + ", 90, CON ( " + str(raster) + " >= " + str(value85) + ", 85, CON ( " + str(raster) + " >= " + str(value80) + " , 80, 0 ) ) ) ) )", Output)
print "Output percentile raster created" However, I've had some issues implementing the same processes using arcpy. I've tried using both the Con and Reclassify approaches, but both raise errors. Using the Con tool, the expression I've used is: for row in rows:
value99 = row.getValue("VAL_99")
value95 = row.getValue("VAL_95")
value90 = row.getValue("VAL_90")
value85 = row.getValue("VAL_85")
value80 = row.getValue("VAL_80")
try:
outRas = Con(raster >= value99, 99, Con(raster >= value95, 95, Con(raster >= value90, 90, Con(raster >= value85, 85, Con(raster >= value80, 80, 0)))))
print "Con statement completed"
except Exception as e:
print e.message
try:
outRas.save(r"F:\outRas")
print "output raster saved"
except Exception as e:
print e.message Which raises the following error: ERROR 010240: Could not save raster dataset to F:\outRas with output format GRID. Similarly, when using the Reclassify approach: try:
in_raster = CAVM_het_output
reclass_field = "VALUE"
valueMAX = arcpy.GetRasterProperties_management(CAVM_het_output, "MAXIMUM")
print "max = ", valueMAX
valueMIN = arcpy.GetRasterProperties_management(CAVM_het_output, "MINIMUM")
print "min = ", valueMIN
remap = ([value99, valueMAX, 99], [value95, value99, 95], [value90, value95, 90], [value85, value90, 85],[value80, value85, 80], [valueMIN, value80, 0])
print "remap = ", remap
outRas = Reclassify(in_raster, reclass_field, remap, "NODATA")
print "outRas created"
print "Reclassify statement completed"
except Exception as e:
print e.message
try:
outRas.save(r"F:/outRas")
print "output raster saved"
This approach raises the following error: Object: Error in executing tool In both cases, my thinking is the trouble is attributed to having variables in the expressions (e.g. value99 or valueMAX), but perhaps I'm wrong. E.g. remap = ([565.0, <Result '585'>, 99], [546.0, 565.0, 95], [525.0, 546.0, 90], [504.0, 525.0, 85], [483.0, 504.0, 80], [<Result '0'>, 483.0, 0]) Does anyone have any ideas here? I'm guessing this is an easy fix, but I'm hitting the wall... Many thanks, James
... View more
01-19-2011
06:30 AM
|
0
|
3
|
345
|
POST
|
Thanks Dan! Will do! I'll keep you posted on what they advise...
... View more
10-07-2010
09:41 AM
|
0
|
0
|
306
|
POST
|
Thanks Dan. Unfortunately, this problem is back again! And I haven't even re-installed any third-party extensions. Which, as you might imagine, is very frustrating! Things were working just fine, until I started trying to build a script in Python using Spatial Analyst functions (which was the same as last time). Now I can't run Spatial Analyst tools anywhere! I'll try the normal templates approach again. I'm hoping that I won't have to un-install and re-install, again...
... View more
10-07-2010
07:39 AM
|
0
|
0
|
306
|
POST
|
Thanks Dan. I uninstalled all third-party extensions and then re-installed ArcGIS, and things seem to be working fine! Many thanks, James
... View more
09-15-2010
01:49 PM
|
0
|
0
|
306
|
POST
|
Thanks Dan. Unfortunately, yes, I have deleted my temp cache. I even tried changing my temp and scratch directories. Still stumped on this one, so any further suggestions would be welcomed! James
... View more
09-15-2010
05:00 AM
|
0
|
0
|
306
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|