Saturday, 5 March 2016

how to get max and min from a raster using arcpy?


I have a land surface temperature raster file and I want the max and min of it.


minLSTresult = arcpy.GetRasterProperties_management(raster_result, "MINIMUM")

minLST = minLSTresult.getOutput(0)


minLST returns u'261.22'. How could I only get the number of it?



Answer



That is simply indicating that the value is a Unicode string. You can use this unicode string in most situations. However, if you need to fully control the type, convert it to float format.


test = unicode('261.22')

>>> test
u'261.22'

>>> type(test)



test2 = float(test)
>>> test2
261.22

>>> type(test2)

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...