There are too methods in gee to cast an image to float : toFloat() and float().

They have the same documentation which is the following :

Casts the input value to a 32-bit float.

Is there any difference between the 2 functions?

This question can be extended to all casting method that usually exist in 2 versions (int(), toInt() ...etc)


toFloat() and float() are exactly the same, and this is true for all the other band type cast operators like int() and toInt(). You can use either ones, but if you're looking for a recommendation, I'd say to always use the ones with to, to be a little more specific about what they're doing.

(It happens that the versions without to prefixes came first and the prefixed ones were added later, but the precise rationale for adding the second set of names has been forgotten. Of course, it'd be simpler to have only one set now, but since both are in use, removing either would break some scripts without much benefit.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.