# Adding field with prices based on ground use using ArcGIS Spatial Analyst?

I need to calculate the least cost path for a water pipe. The layers I have now are land use, slope, soil type and protected natural parks. Now my teacher has given me the prices of building a water pipe. For example: the soil type layer consists of Sand, Clay, Lime, Loam and Other. Sand and Clay are €10 for each meter and Lime and Loam are €30/m. The Land Use layer has 4 categories with different prices for each category. And the slope is based on % of the total price. Protected natural parks is forbidden.

Now my first question is if I can use Weighted Overlay for this. I have completed Esri's Spatial Analyst tutorial. But I can't see how I can use these prices for this.

Instead I thought of another method, by creating a cost raster. This cost raster includes all the used layers, but these layers all must have prices added. But I tried this for the soil type layer and I'm stuck now. I added a new field to the layer with the name "Costs". I used the Field Calculator to replace the soil types in the field "Soil" to the price that belongs to the soil type. For example Replace( [LETTER],"BLb/Ldh/Ldd/Ld/BLd/AHl/Lnd/BLn/Lh/ABl/Ln/BLh","30"). BLb/Ldh/Ldd/Ld/BLd/AHl/Lnd/BLn/Lh/ABl/Ln/BLh stands for Loam, I reclassified this. So I tried to place 4 of these Replace functions behind each other. But I get the same error everytime: 000539: invalid syntax (, line 1). I'm probably doing something really wrong, but I couldn't find anything similar on the internet.

My second question is therefore how I could get this tool running.

I'm not really skilled in ArcGIS yet.

• Summarise your soil type, add new field to it to store cost and populate it by actual cost. Add field "COST" to soils, join it to summary table and populate by costs from summary table Apr 5, 2016 at 0:00
• Welcome! Please take the tour here: gis.stackexchange.com/tour and limit your question to only one question. As for your error, your syntax is off for the VB script. I believe you will need to wrap that in either an if-else or a case statement. Apr 5, 2016 at 0:04
• @FelixIP I'm not sure what you mean, sorry! I think creating a new summarize table and then join it with the actual costs? But then I still keep this problem, because the prices are new data that I need to join with this table.@MaryBeth Sorry, will keep in mind next time! Not sure how if-else or a case statement work, but I'm going to try it. Thank you
– Bas
Apr 5, 2016 at 0:16
• There is an edit button beneath your question that you can use to focus it down to a single clear question.
– PolyGeo
Apr 5, 2016 at 6:05

You may have to do them one-by-one.

You need to establish an if-block. Here's an example in python format:

=

ifBlock(!Geomorphic_Compatibility!,!GeomorphCompat!)

code block:

def ifBlock(Geomorphic_Compatibility, GeomorphCompat): if Geomorphic_Compatibility is None: return GeomorphCompat else: return Geomorphic_Compatibility

note you could use elif to extend this to more options. I'd rewrite it to your code, but I'm on my way out the door. Also the variables in the code block are read by the order you put them in, so they don't have to match your feature. (it just helps keep track of what's going on)

• Thank you so much! Haven't worked with Python before, but it worked perfectly. I did the following: if KOSTEN == 'BLb/Ldh/Ldd/Ld/BLd/AHl/Lnd/BLn/Lh/ABl/Ln/BLh': Return "30". After this I used elif for the other soil types as you explained. Haven't used else, because it wasn't needed. Thanks again, this solved an annoying problem!
– Bas
Apr 6, 2016 at 0:40