Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I used the following lines of code to classify a raster. However, my problem is how can I denote the old and new classification values in the last code line using variables? Then number of values hence the number of variables may vary from raster to raster. I note that I know how to read these values from the raster attribute table. Thanks

' Create the Geoprocessor object
Set GP = WScript.CreateObject("esriGeoprocessing.GPDispatch.1")

' Check out any necessary licenses
GP.CheckOutExtension "spatial"

' Load required toolboxes...
GP.AddToolbox "C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Spatial Analyst Tools.tbx"


' Local variables...
Reclass_rast1 = "C:\LACONISS\LandSpaCES\Reclass_rast1"
Substract5_12 = "Substract5_12"

' Process: Reclassify...
GP.Reclassify_sa Substract5_12, "VALUE", "-3 0;-2 0;-1 0;0 1;1 0;2 0;3 0",  Reclass_rast1, "DATA"
share|improve this question
1  
Is it possible to use the ListFields method, and limit your list of values to the ones you specifically want for a certain classification and create a variable from that list that can then be used in the tool? Maybe I'm not quite understanding your question. –  dchaboya Dec 20 '11 at 20:36
1  
If I have understood, the question asks how to construct a string like "-3 0;-2 0; ... ;3 0" dynamically from a Python array like [-3 -2 -1 0 1 2 3]. If I'm right, this question belongs on SO--where it would get a real quick answer (probably a bunch of good different ones)--because it's not a GIS question, it's a basic Python question. –  whuber Dec 20 '11 at 22:42
1  
@dchaboya and Whuber. You have fully described what I want to do. I know that this is not a pure GIS question. I have to say that eventually I did what I wanted by modyfying a sample code called "Reclassifying a string field" provided in edndoc.esri.com/arcobjects/8.3 and by utilising INumberRemap interface resources.esri.com/help/9.3/arcgisengine/ArcObjects/… and in particular MapValue and MapRange methods. Thanks both of you for the effort. –  Demetris Dec 21 '11 at 5:54
    
@Demetris Can you post that as an answer to your question and accept it? That way, other people can learn from your situation. Thanks –  R.K. Dec 21 '12 at 4:15
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.