def warp(self, dem=None, proj="<STR_LIT>", **kwargs):
try:<EOL><INDENT>img_md = self.rda.metadata["<STR_LIT:image>"]<EOL>x_size = img_md["<STR_LIT>"]<EOL>y_size = img_md["<STR_LIT>"]<EOL><DEDENT>except (AttributeError, KeyError):<EOL><INDENT>x_size = kwargs.get("<STR_LIT>", <NUM_LIT>)<EOL>y_size = kwargs.get("<STR_LIT>", <NUM_LIT>)<EOL><DEDENT>if self.proj is None:<EOL><INDENT>from_proj = "<STR_LIT>"<EOL><DEDENT>else:<EOL><INDENT>from_proj = self.proj<EOL><DEDENT>try:<EOL><INDENT>center = wkt.loads(self.rda.metadata["<STR_LIT:image>"]["<STR_LIT>"]).centroid<EOL>g = box(*(center.buffer(self.rda.metadata["<STR_LIT>"]["<STR_LIT>"] / <NUM_LIT:2>).bounds))<EOL>tfm = partial(pyproj.transform, pyproj.Proj(init="<STR_LIT>"), pyproj.Proj(init=proj))<EOL>gsd = kwargs.get("<STR_LIT>", ops.transform(tfm, g).area ** <NUM_LIT:0.5>)<EOL>current_bounds = wkt.loads(self.rda.metadata["<STR_LIT:image>"]["<STR_LIT>"]).bounds<EOL><DEDENT>except (AttributeError, KeyError, TypeError):<EOL><INDENT>tfm = partial(pyproj.transform, pyproj.Proj(init=self.proj), pyproj.Proj(init=proj))<EOL>gsd = kwargs.get("<STR_LIT>", (ops.transform(tfm, shape(self)).area / (self.shape[<NUM_LIT:1>] * self.shape[<NUM_LIT:2>])) ** <NUM_LIT:0.5> )<EOL>current_bounds = self.bounds<EOL><DEDENT>tfm = partial(pyproj.transform, pyproj.Proj(init=from_proj), pyproj.Proj(init=proj))<EOL>itfm = partial(pyproj.transform, pyproj.Proj(init=proj), pyproj.Proj(init=from_proj))<EOL>output_bounds = ops.transform(tfm, box(*current_bounds)).bounds<EOL>gtf = Affine.from_gdal(output_bounds[<NUM_LIT:0>], gsd, <NUM_LIT:0.0>, output_bounds[<NUM_LIT:3>], <NUM_LIT:0.0>, -<NUM_LIT:1> * gsd)<EOL>ll = ~gtf * (output_bounds[:<NUM_LIT:2>])<EOL>ur = ~gtf * (output_bounds[<NUM_LIT:2>:])<EOL>x_chunks = int((ur[<NUM_LIT:0>] - ll[<NUM_LIT:0>]) / x_size) + <NUM_LIT:1><EOL>y_chunks = int((ll[<NUM_LIT:1>] - ur[<NUM_LIT:1>]) / y_size) + <NUM_LIT:1><EOL>num_bands = self.shape[<NUM_LIT:0>]<EOL>try:<EOL><INDENT>dtype = RDA_TO_DTYPE[img_md["<STR_LIT>"]]<EOL><DEDENT>except:<EOL><INDENT>dtype = '<STR_LIT>'<EOL><DEDENT>daskmeta = {<EOL>"<STR_LIT>": {},<EOL>"<STR_LIT>": (num_bands, y_size, x_size),<EOL>"<STR_LIT>": dtype,<EOL>"<STR_LIT:name>": "<STR_LIT>".format(self.name),<EOL>"<STR_LIT>": (num_bands, y_chunks * y_size, x_chunks * x_size)<EOL>}<EOL>def px_to_geom(xmin, ymin):<EOL><INDENT>xmax = int(xmin + x_size)<EOL>ymax = int(ymin + y_size)<EOL>bounds = list((gtf * (xmin, ymax)) + (gtf * (xmax, ymin)))<EOL>return box(*bounds)<EOL><DEDENT>full_bounds = box(*output_bounds)<EOL>dasks = []<EOL>if isinstance(dem, GeoDaskImage):<EOL><INDENT>if dem.proj != proj:<EOL><INDENT>dem = dem.warp(proj=proj, dem=dem)<EOL><DEDENT>dasks.append(dem.dask)<EOL><DEDENT>for y in xrange(y_chunks):<EOL><INDENT>for x in xrange(x_chunks):<EOL><INDENT>xmin = x * x_size<EOL>ymin = y * y_size<EOL>geometry = px_to_geom(xmin, ymin)<EOL>daskmeta["<STR_LIT>"][(daskmeta["<STR_LIT:name>"], <NUM_LIT:0>, y, x)] = (self._warp, geometry, gsd, dem, proj, dtype, <NUM_LIT:5>)<EOL><DEDENT><DEDENT>daskmeta["<STR_LIT>"], _ = optimization.cull(HighLevelGraph.merge(daskmeta["<STR_LIT>"], *dasks), list(daskmeta["<STR_LIT>"].keys()))<EOL>gi = mapping(full_bounds)<EOL>gt = AffineTransform(gtf, proj)<EOL>image = GeoDaskImage(daskmeta, __geo_interface__ = gi, __geo_transform__ = gt)<EOL>return image[box(*output_bounds)]<EOL>
Delayed warp across an entire AOI or Image

        Creates a new dask image by deferring calls to the warp_geometry on chunks

        Args:
            dem (ndarray): optional. A DEM for warping to specific elevation planes
            proj (str): optional. An EPSG proj string to project the image data into ("EPSG:32612")

        Returns:
            daskarray: a warped image as deferred image array