I've written a Python script that reclassifies a raster using a set of conditional statements into 4 classes:
- 0 - 12
- 12 - 24
- 24 - 30
- 30 - 60
rec_ras = Con(costmin <= 12, 12, Con((costmin > 12) & (costmin <= 24), 24, Con((costmin > 24) & (costmin <= 30), 30, Con((costmin > 30) & (costmin <= 60), 60))))
I then needed to change the classes into 7 classes:
- 0 - 5
- 5 - 10
- 10 - 15
- 15 - 20
- 20 - 25
- 25 - 30
- 30 - 60
rec_ras = Con(costmin <= 5, 5, Con((costmin > 5) & (costmin <= 10), 10, Con((costmin > 10) & (costmin <= 15), 15, Con((costmin > 15) & (costmin <= 20), 20, Con((costmin > 20) & (costmin <= 25), 25, Con((costmin > 25) & (costmin <= 30), 30, Con((costmin > 30) & (costmin <= 60), 60)))))))
Is ther a better way of creating a Python function that can create my conditional statement as and if when I need to change the classes before running it. The following is part of a larger Python Class.