def process(parsed, target, temp_metatile, temp_processed, save_offsetx, save_offsety, save_xsize, save_ysize, nodata, ot, *args, **kwargs): landpolygon = parsed.landpolygon temp_landpolygon = "/tmp/temp_landpolygon_%s.sqlite" % os.getpid() # get metattile extent ds = gdal.Open(temp_metatile) geotransform = ds.GetGeoTransform(1) xpixelsize = geotransform[1] ypixelsize = geotransform[5] width = ds.RasterXSize height = ds.RasterYSize llx = geotransform[0] lly = geotransform[3] + width*geotransform[4] + height*geotransform[5] urx = geotransform[0] + width*geotransform[1] + height*geotransform[2] ury = geotransform[3] # clip landpolygon print "clipping" clip_landpolygon = "ogr2ogr -clipsrc %s %s %s %s -f SQLite %s %s" %(llx, lly, urx, ury, temp_landpolygon, landpolygon) os.system(clip_landpolygon) # rasterize landpolygon print "rasterizing" rasterize_landpolygon = "gdal_rasterize -burn 1 -te %s %s %s %s -tr %s %s -ot Byte %s %s" %(llx, lly, urx, ury, xpixelsize, ypixelsize, temp_landpolygon, temp_processed) os.system(rasterize_landpolygon) if os.path.isfile(temp_landpolygon): os.remove(temp_landpolygon) tiff_save(temp_processed, target, save_offsetx, save_offsety, save_xsize, save_ysize, nodata, ot)
def process(parsed, target, temp_metatile, temp_processed, save_offsetx, save_offsety, save_xsize, save_ysize, nodata, ot, *args, **kwargs): scale = parsed.s zfactor = parsed.z altitude = parsed.alt process_hillshade = "gdaldem hillshade -s %s -z %s -alt %s %s -of GTiff %s > /dev/null" %(scale, zfactor, altitude, temp_metatile, temp_processed) #print process_hillshade os.system(process_hillshade) tiff_save(temp_processed, target, save_offsetx, save_offsety, save_xsize, save_ysize, nodata, ot)
def process(parsed, target, temp_metatile, temp_processed, save_offsetx, save_offsety, save_xsize, save_ysize, nodata, ot, metatile_xsize, metatile_ysize, *args, **kwargs): tile_xsize = parsed.tile_xsize[0] tile_ysize = parsed.tile_ysize[0] xresolution = float(parsed.x) yresolution = float(parsed.y) xscale = xresolution/tile_xsize yscale = yresolution/tile_ysize interpolation = parsed.i scalefactor = xresolution/tile_xsize rescaled_xsize = int(metatile_xsize*xscale) rescaled_ysize = int(metatile_ysize*yscale) process_rescale = "gdalwarp -ts %s %s -r %s -overwrite %s -of GTiff %s -srcnodata %s -dstnodata %s -multi > /dev/null" %(rescaled_xsize, rescaled_ysize, interpolation, temp_metatile, temp_processed, nodata, nodata) os.system(process_rescale) save_offsetx = int(save_offsetx*xscale) save_offsety = int(save_offsety*yscale) save_xsize = int(save_xsize*xscale) save_ysize = int(save_ysize*yscale) tiff_save(temp_processed, target, save_offsetx, save_offsety, save_xsize, save_ysize, nodata, ot)
def process(parsed, target, temp_metatile, temp_processed, save_offsetx, save_offsety, save_xsize, save_ysize, nodata, ot, *args, **kwargs): landpolygon = parsed.landpolygon temp_landpolygon = "/tmp/temp_landpolygon_%s.sqlite" % os.getpid() # get metattile extent ds = gdal.Open(temp_metatile) geotransform = ds.GetGeoTransform(1) xpixelsize = geotransform[1] ypixelsize = geotransform[5] width = ds.RasterXSize height = ds.RasterYSize llx = geotransform[0] lly = geotransform[3] + width * geotransform[4] + height * geotransform[5] urx = geotransform[0] + width * geotransform[1] + height * geotransform[2] ury = geotransform[3] # clip landpolygon print "clipping" clip_landpolygon = "ogr2ogr -clipsrc %s %s %s %s -f SQLite %s %s" % ( llx, lly, urx, ury, temp_landpolygon, landpolygon) os.system(clip_landpolygon) # rasterize landpolygon print "rasterizing" rasterize_landpolygon = "gdal_rasterize -burn 1 -te %s %s %s %s -tr %s %s -ot Byte %s %s" % ( llx, lly, urx, ury, xpixelsize, ypixelsize, temp_landpolygon, temp_processed) os.system(rasterize_landpolygon) if os.path.isfile(temp_landpolygon): os.remove(temp_landpolygon) tiff_save(temp_processed, target, save_offsetx, save_offsety, save_xsize, save_ysize, nodata, ot)
def process(parsed, target, temp_metatile, temp_processed, save_offsetx, save_offsety, save_xsize, save_ysize, nodata, ot, metatile_xsize, metatile_ysize, *args, **kwargs): tile_xsize = parsed.tile_xsize[0] tile_ysize = parsed.tile_ysize[0] xresolution = float(parsed.x) yresolution = float(parsed.y) xscale = xresolution / tile_xsize yscale = yresolution / tile_ysize interpolation = parsed.i scalefactor = xresolution / tile_xsize rescaled_xsize = int(metatile_xsize * xscale) rescaled_ysize = int(metatile_ysize * yscale) process_rescale = "gdalwarp -ts %s %s -r %s -overwrite %s -of GTiff %s -srcnodata %s -dstnodata %s -multi > /dev/null" % ( rescaled_xsize, rescaled_ysize, interpolation, temp_metatile, temp_processed, nodata, nodata) os.system(process_rescale) save_offsetx = int(save_offsetx * xscale) save_offsety = int(save_offsety * yscale) save_xsize = int(save_xsize * xscale) save_ysize = int(save_ysize * yscale) tiff_save(temp_processed, target, save_offsetx, save_offsety, save_xsize, save_ysize, nodata, ot)
def process(parsed, target, temp_metatile, temp_processed, save_offsetx, save_offsety, save_xsize, save_ysize, nodata, ot, *args, **kwargs): process_fillnodata = "gdal_fillnodata.py %s %s > /dev/null" %(temp_metatile, temp_processed) os.system(process_fillnodata) tiff_save(temp_processed, target, save_offsetx, save_offsety, save_xsize, save_ysize, nodata, ot)
def process(parsed, target, temp_metatile, temp_processed, save_offsetx, save_offsety, save_xsize, save_ysize, nodata, ot, *args, **kwargs): temp_processed = temp_metatile tiff_save(temp_processed, target, save_offsetx, save_offsety, save_xsize, save_ysize, nodata, ot)