Hello,
thank you Thomas Stanley and Curtis Price, I've tried your suggestions. I'm a bit further but still can't get my
CalculateField to recognize the output of the GetRasterProperties in ModelBuilder.
I've split up the problem and made a model with just the CalculateField Tool and a model variable of type Double that is used to fill the field (see picture). So far, so good, that work's.
Then I try to use the Output of the GetRasterProperties Tool (Max_Value) instead of the variable %Double% in my field calculation. The model runs without error message but the field is not updated but stays empty.
I also tried to write %Max_Value% instead of Max_Value in the expression line, but that does not make any difference to the result.
If anyone could help me with this issue I would be most grateful.
did you try
float(%Max_Value%)
The geoprocessing messages you get from ModelBuilder when you run the tool may be helpful - I'd look at them carefully.
One thing you can verify is that your raster does return a maximum result from the tool at all. For examples, if it's all NoData, you won't get a result.
Thank you very much for your suggestion. I think I'm getting closer to the core of the problem.
I checked in the geoprocessing results that I get an output from the GetRasterProperties (45,445). My ArcGIS is set up in German, therefore the comma.
Then I tried to use
float(%Max_Value%)
but got an error message stating that float can take only one argument. So I assumed that the comma in my 54,445 is the problem and it actually should be 54.445 in order to be transformed into a float variable.
I exported the whole model into a script to be able to transform the datatyp. My script runs without any error messages but still the field is not filled with my 54.445.
My script looks like this:
# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------
# GetRasterProperties.py
# Created on: 2014-11-13 14:20:41.00000
# (generated by ArcGIS/ModelBuilder)
# Usage: GetRasterProperties <in_raster> <Table>
# Description:
# ---------------------------------------------------------------------------
# Import arcpy module
import arcpy
# Script arguments
in_raster = arcpy.GetParameterAsText(0)
Table = arcpy.GetParameterAsText(1)
# Local variables:
# Max_Value = in_raster
# TableOut = Max_Value
# Process: Raster-Eigenschaften abrufen
MaxWertResult = arcpy.GetRasterProperties_management(in_raster, "MAXIMUM", "")
# Maximum als String in Variable speichern
MaxWert = MaxWertResult.getOutput(0)
# In MaxWert Komma durch Punkt ersetzen
MaxWert2 = MaxWert.replace(",", ".")
# MaxWert2 in Float umwandeln
MaxWertFl = float(MaxWert2)
# Process: Feld berechnen
arcpy.CalculateField_management(Table, "Max2", MaxWertFl, "PYTHON_9.3", "")
You may want to verify the internationalization settings in Python are what they should be.
22.2. locale — Internationalization services — Python 2.7.8 documentation
Thank you Curtis Price, that did the trick!
First I set my ArcGIS to English, but that wasn't enough. I actually had to change the decimal sign for my whole computer to ".", now it works beautifully.
THANK YOU