Python script to derive new cells values from the current ones,

506
3
03-30-2013 12:17 AM
JamalNUMAN
Legendary Contributor
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).


[ATTACH=CONFIG]23087[/ATTACH]

Thank you

Best

Jamal
----------------------------------------
Jamal Numan
Geomolg Geoportal for Spatial Information
Ramallah, West Bank, Palestine
Tags (2)
0 Kudos
3 Replies
DanPatterson_Retired
MVP Emeritus
See the spatial anlysts Con method, it allows you to create what-if scenarios
0 Kudos
JamalNUMAN
Legendary Contributor
See the spatial anlysts Con method, it allows you to create what-if scenarios


Many thanks Dan for the answer,

Sound that the Con (spatial analyst) is not appropriate to do the job!

For example, how to construct a code for the condition below:

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 (applying 3x3 window)

[ATTACH=CONFIG]23099[/ATTACH]

Is that possible using the Con (spatial analyst) tool?

Best

Jamal
----------------------------------------
Jamal Numan
Geomolg Geoportal for Spatial Information
Ramallah, West Bank, Palestine
0 Kudos
JamalNUMAN
Legendary Contributor
Many thanks Dan for the answer,

Sound that the Con (spatial analyst) is not appropriate to do the job!

For example, how to construct a code for the condition below:

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 (applying 3x3 window)

[ATTACH=CONFIG]23099[/ATTACH]

Is that possible using the Con (spatial analyst) tool?

Best

Jamal


The data is attached
----------------------------------------
Jamal Numan
Geomolg Geoportal for Spatial Information
Ramallah, West Bank, Palestine
0 Kudos