This paper presents an efficient method of extracting line segments from the occupancy grids in a grid map. The grid map is composed of 2-D grids that have both the occupancy and orientation probabilities using sonar sensors. We evaluate the orientation information of every grid when the occupancy probability of the grid is updated from sonar range data. To find the shape of an object in the map from orientation information, the orientations are clustered into several groups according to their values. The line segments are, then, extracted from the clusters based on Hough transform. Finally, a feature-based map is built with these line segments. The proposed method is illustrated with the results produced by sets of experiments in an indoor environment.