![]() To get a better idea of the dataset, print some basic statistics: # Display statistics (min, max, mean) numpy.nanmin calculates the minimum without the NaN values. Print('SERC CHM Array:\n',chm_array) #display array values Once we generate the array, we want to set No Data Values to NaN, and apply the scale factor: chm_array = chm_dataset.GetRasterBand(1).ReadAsArray(0,0,cols,rows).astype(np.float)Ĭhm_array=np.nan #Assign CHM No Data Values to NaN Use the extension astype(np.float) to ensure the array contains floating-point numbers. SERC CHM Statistics: Minimum=0.00, Maximum=33.06, Mean=7.684, StDev=9.012įinally we can convert the raster to an array using the ReadAsArray command. (chm_stats, chm_stats, chm_stats, chm_stats)) Print('SERC CHM Statistics: Minimum=%.2f, Maximum=%.2f, Mean=%.3f, StDev=%.3f' % ![]() ScaleFactor = chm_raster.GetScale() print('scale factor:',scaleFactor)Ĭhm_stats = chm_raster.GetStatistics(True,True) NoDataVal = chm_raster.GetNoDataValue() print('no data value:',noDataVal) ![]() We can read in a single raster band with GetRasterBand and access information about this raster band such as the No Data Value, Scale Factor, and Statitiscs as follows: chm_raster = chm_dataset.GetRasterBand(1) XMax = xMin chm_dataset.RasterXSize/chm_mapinfo #divide by pixel width We can convert this information into a spatial extent (xMin, xMax, yMin, yMax) by combining information about the origin, number of columns
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |