My project is about "Extracting water and urban features from satellite images". I have extracted urban and water features using Python code. Now, I want to do accuracy assessment. I know two primary requirements for accuracy are reference data and predicted data. So, as reference data I have GeoTIFF file and as predicted data I have my extracted image (GeoTIFF format). I tried with accuracy assessment using Python but I am getting accuracy as 99% which is not possible. Can somebody suggest how I can achieve this using Python?

Please find my code:

import numpy as np  
import matplotlib.pyplot as plt  
import cv2  
from PIL import Image  
import os  
import gdal  
import osr  

gtif = gdal.Open('E:\\tanvi_iirs_work\\Task 3\\Images\\geosample.tif')  
srcband = gtif.GetRasterBand(1)  
trans = gtif.GetGeoTransform()  
proj = gtif.GetProjection()  
arr = srcband.ReadAsArray()  
print("urban area")                       #Extracting urban area
for i in range(arr.shape[0]):  
    for j in range(arr.shape[1]):  
        if 0.6 <= arr[i,j] <= 1:  
            arr[i,j] = 1  
            arr[i,j] = 0  
plt.imshow(arr,cmap = 'gray')  

cols = arr.shape[1]  
rows = arr.shape[0]  

driver = gdal.GetDriverByName('GTiff')  

if arr.ndim == 2:  
    band_num = 1  
    band_num = arr.shape[2]  

outRaster = driver.Create('E:\\tanvi_iirs_work\\Task 3\\Images\\outputtrial1.tif',cols,rows,1,gdal.GDT_Float32)  
#srs = osr.SpatialReference()  
#s1 = srs.ImportFromEPSG(4326)  


outband = outRaster.GetRasterBand(1)  

#data2 = outband.ReadAsArray()  

#Accuracy Assessment  


for i in range(arr.shape[0]):  
    for j in range(arr.shape[1]):  
       if arr[i][j]==1 and 0.5=<arr1[i][j]<=1:  
       if arr[i][j]==0 and 0.0=<arr1[i][j]<=0.4:  
       if arr[i][j]==1 and 0.5=<arr1[i][j]<=1:  
       if arr[i][j]==0 and 0.0=<arr1[i][j]<=0.4:  

closed as unclear what you're asking by Vince, Fran Raga, BERA, whyzar, Taras Jul 16 at 4:23

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Welcome to GIS SE. As a new user, please take the Tour. You state that you are "facing [an] issue", but not what that issue is. You haven't provided the code you are using that has the issue, or an indication of what code library you are using to access the GeoTIFF data. As it stands, this question is unclear, opinion-based, too broad, and missing a code attempt. Please Edit the question to focus it on the problem. – Vince Jul 13 at 14:36
  • Thank you for adding code, but please fix the formatting so that it's readable. There's a code format button in edit mode, or just add 4 spaces at the beginning of each line. – smiller Jul 13 at 16:20
  • It looks like you are extracting data from a raster, assigning it to a new raster, then testing against the same original raster using the same original limits (e.g. Value > 0.6). You don't have two sets of data, you just have one set, with tests. What is the known good or somehow verified data to test against? – smiller Jul 16 at 4:21