A method for creating a map by a moving robot includes receiving sensor data regarding a distance to an external object through a distance measurement sensor, and creating a cell-based grid map based on the sensor data. Image processing is performed to distinguish between regions in the grid map and to create a boundary line between the regions. An optimal boundary line is selected from the one or more boundary lines, and a path to the optimal boundary line is planned. The grid map is updated while the moving robot is moving along the path such that the map may be automatically created.