Python script to derive new cells values from the current ones,
I couldn’t figure out how to develop a code that change the values of cells based on If –Then statements.
Suppose that I got a raster where its cells have seven possible values:
1. water,
2. road,
3. commercial,
4. forest area,
5. residential areas,
6. pasture and
7. row crops
and I wanted to derive a new values for the current cells based on the rules below (Sharaf Alkheder and Jie Shan) considering 3x3 window:
1. IF tested pixel under consideration is water, THEN no growth is allowed at this pixel.
2. IF tested pixel under consideration is road, THEN no growth is allowed at this pixel.
3. IF tested pixel under consideration is residential OR commercial, THEN keep this pixel
the same without any change.
4. IF tested pixel under consideration is either (forest OR pasture OR row crops) AND
there are 4 commercial pixels in the neighborhood, THEN change tested pixel to
commercial.
5. IF tested pixel under consideration is either (forest OR pasture OR row crops) AND
there are 4 HEN change tested pixel to residential.
Then how such code can be developed? any hints?
Unfortunately, the built-in tools in the ArcGIS don't do this sort of work (such as focal statistics).
Attachment 23087
Thank you
Best
Jamal
I couldn’t figure out how to develop a code that change the values of cells based on If –Then statements.
Suppose that I got a raster where its cells have seven possible values:
1. water,
2. road,
3. commercial,
4. forest area,
5. residential areas,
6. pasture and
7. row crops
and I wanted to derive a new values for the current cells based on the rules below (Sharaf Alkheder and Jie Shan) considering 3x3 window:
1. IF tested pixel under consideration is water, THEN no growth is allowed at this pixel.
2. IF tested pixel under consideration is road, THEN no growth is allowed at this pixel.
3. IF tested pixel under consideration is residential OR commercial, THEN keep this pixel
the same without any change.
4. IF tested pixel under consideration is either (forest OR pasture OR row crops) AND
there are 4 commercial pixels in the neighborhood, THEN change tested pixel to
commercial.
5. IF tested pixel under consideration is either (forest OR pasture OR row crops) AND
there are 4 HEN change tested pixel to residential.
Then how such code can be developed? any hints?
Unfortunately, the built-in tools in the ArcGIS don't do this sort of work (such as focal statistics).
Attachment 23087
Thank you
Best
Jamal