def write(self, directory, name=None, session=None, replaceParamFile=None):
        """
        Index Map Write to File Method
        """

        # Initiate file
        if name != None:
            filename = '%s.%s' % (name, self.fileExtension)
            filePath = os.path.join(directory, filename)
        else:
            filePath = os.path.join(directory, self.filename)

        # If the raster field is not empty, write from this field
        if type(self.raster) != type(None):
            # Configure RasterConverter
            converter = RasterConverter(session)

            # Use MapKit RasterConverter to retrieve the raster as a GRASS ASCII Grid
            grassAsciiGrid = converter.getAsGrassAsciiRaster(rasterFieldName='raster',
                                                             tableName=self.__tablename__,
                                                             rasterIdFieldName='id',
                                                             rasterId=self.id)

            # Write to file
            with open(filePath, 'w') as mapFile:
                mapFile.write(grassAsciiGrid)

        else:
            if self.rasterText is not None:
                # Open file and write, raster_text only
                with open(filePath, 'w') as mapFile:
                    mapFile.write(self.rasterText)