delete missing data

parent 05b11191
#!/usr/bin/python
# -*- coding: utf-8 -*-
import osgeo.ogr as ogr
import osgeo.osr as osr
import numpy as np
import gdal
import sys
#-------------------------------------------------------------------------------
def imageMissingData(filename):
inputImage = gdal.Open(inputfile)
rows, cols, geotransform = inputImage.RasterYSize, inputImage.RasterXSize, inputImage.GetGeoTransform()
data = inputImage.GetRasterBand(1).ReadAsArray(0,0,cols,rows)
inputImage = None
return (data>0).sum()/(rows*cols)
#-------------------------------------------------------------------------------
def main(argv):
if len(sys.argv) != 2:
print("Usage: " + argv[0] + " <File>")
else:
print (imageMissingData(filename))
#-------------------------------------------------------------------------------
if __name__ == "__main__":
main(sys.argv)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment