import rasterio
import numpy as np

#14796 in csv
#FSD2303
#fnraster '/caldera/projects/usgs/eros/urban_heat_islands/Phase1/FSD/output_folder/HOTSPOT/UHI_CU_FSD_1985_20210727_C01_MAXLST_HOTSPOT.tif'
#fnzones '/caldera/projects/usgs/eros/urban_heat_islands/Phase2/uhi_metrobuffer_generation/City_Boundaries_Dissolved/ard_fsd_city_dissolved.shp'
#fnclass '/caldera/projects/usgs/eros/urban_heat_islands/Phase2/section_332/output/FSD/UHI_CU_FSD_1985_20230124_C01_LC.tif'
#'/caldera/projects/usgs/eros/urban_heat_islands/Phase1/FSD/output_folder'


from rasterstats import zonal_stats
stats2 = zonal_stats('/caldera/projects/usgs/eros/urban_heat_islands/Phase2/uhi_metrobuffer_generation/City_Boundaries_Dissolved/ard_fsd_city_dissolved.shp', 
 '/caldera/projects/usgs/eros/urban_heat_islands/Phase1/FSD/output_folder/HOTSPOT/UHI_CU_FSD_1985_20210727_C01_MAXLST_HOTSPOT.tif',
             stats=["count","nodata"])

stats = zonal_stats('/caldera/projects/usgs/eros/urban_heat_islands/Phase2/uhi_metrobuffer_generation/City_Boundaries_Dissolved/ard_fsd_city_dissolved.shp', 
'/caldera/projects/usgs/eros/urban_heat_islands/Phase1/FSD/output_folder/HOTSPOT/UHI_CU_FSD_1985_20210727_C01_MAXLST_HOTSPOT.tif',
            categorical=True)

#[{0.0: 146353, 1.0: 26508}, {0.0: 134070, 1.0: 24936}, {0.0: 781401, 1.0: 112122}, {0.0: 117750, 1.0: 21110}, {0.0: 88031, 1.0: 13780}, {0.0: 138260, 1.0: 25022}, {0.0: 224397, 1.0: 39308}]


ABC = None

path = '/caldera/projects/usgs/eros/urban_heat_islands/Phase1/FSD/output_folder/HOTSPOT_CLASS_STATS_ANNUAL/UHI_CU_FSD_1985_20210727_C01_MAXLST_HOTSPOT_ZMEAN_FSD2303_CLASS02.tif'
dataset = rasterio.open(path)
band1 = dataset.read(1)

vals,counts = np.unique(band1,return_counts=True)#147688

