Accepts a raster file and converts it to Well Known Binary text using the raster2pgsql
        executable that comes with PostGIS. This is the format that rasters are stored in a
        PostGIS database.

def rasterToWKB(cls, rasterPath, srid, noData, raster2pgsql):
        """
        Accepts a raster file and converts it to Well Known Binary text using the raster2pgsql
        executable that comes with PostGIS. This is the format that rasters are stored in a
        PostGIS database.
        """
        raster2pgsqlProcess = subprocess.Popen([raster2pgsql,
                                                '-s', srid,
                                                '-N', noData,
                                                rasterPath,
                                                'n_a'],stdout=subprocess.PIPE)

        # This commandline tool generates the SQL to load the raster into the database
        # However, we want to use SQLAlchemy to load the values into the database.
        # We do this by extracting the value from the sql that is generated.
        sql, error = raster2pgsqlProcess.communicate()
        if sql:
            # This esoteric line is used to extract only the value of the raster (which is stored as a Well Know Binary string)
            # Example of Output:
            # BEGIN;
            # INSERT INTO "idx_index_maps" ("rast") VALUES ('0100...56C096CE87'::raster);
            # END;
            # The WKB is wrapped in single quotes. Splitting on single quotes isolates it as the
            # second item in the resulting list.
            wellKnownBinary = sql.split("'")[1]
        else:
            print(error)
            raise
        return wellKnownBinary