3

I have the raster map of monthly precipitation of some years (download from CGIAR http://www.cgiar-csi.org/data/uea-cru-ts-v3-10-01-historic-climate-database) and I need the mean values on a specific area (polygonal shapefile). I tried with zonal statistic but I had not results, the attribute table was empty.

Is it possible that my region is too small for do this?

I'm a bit new in QGIS world.

5

Before using Zonal Statistics make sure that you have same projections for both raster data and vector (shapefile) data. Sometimes different projection produce empty results. In the following example, I used WGS 84 for both raster data (SRTM Global) and a polygon vector data (Test.shp), and I didn't specify any column prefix:

enter image description here

The final output is as follows:

enter image description here

1
  1. convert raster to vector using (https://online.rapidresizer.com/tracer.php)
  2. Run this python tool:

import arcpy
import xlwt
import os
outfile = "C:\Users\soft\Desktop\Pole\exce\Domain_Description_report.xls"
try:
    if os.path.exists(outfile):
        os.remove(outfile)
except OSError:
    print 'Unable to delete Report File at '+outfile
    quit()
book = xlwt.Workbook()
sheet1 = book.add_sheet("Featureclass_coordinates")
cntx1 = 1
#cnty2=1
input_fc="C:\Users\soft\Desktop\Pole\Pole.shp"
sheet1.write(0,0,"Feature Id")
sheet1.write(0,1,"Coordinates")
sheet1.write(0,2,"POLETYPE")
desc = arcpy.Describe(input_fc)
if desc.shapeType.upper()=="POINT":
    for row in arcpy.da.SearchCursor(input_fc, ["OID@", "SHAPE@XY","POLETYPE"]):    
        x,y = row[1]
        if x!=None:
            #print(cntx1)
            sheet1.write(cntx1, 0,"Feature "+str(row[0]))
            sheet1.write(cntx1, 1,"{}, {}".format(x, y))
            sheet1.write(cntx1, 2,"{}".format(row[2]))
            cntx1= cntx1 + 1
else:
    print("Loaded Shape file is not a polygon")
book.save(outfile)
1
  • Side note you have to own esri software to use arcpy Aug 18 '20 at 17:14

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.