Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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
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
@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 and by utilising INumberRemap interface… 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

Your Answer


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

Browse other questions tagged or ask your own question.