Implemented toRaster function in classes