A method for keeping a vehicle in a lane of a road when driving along segments of the road by a driver-assistance system, the driver-assistance system having a GNSS receiver, a camera and a control unit, the method comprising the following steps:
- generating a respective image of at least the respective segment by the camera;
- calculating respective local lane data dependent on the respective image, wherein the respective local lane data specifies a respective course of the lane on the respective segment relative to the vehicle;
- steering the vehicle dependent on the respective local lane data by the control unit such that the vehicle stays in the lane when driving on the respective segment;
- converting the respective local lane data into respective global lane data dependent on respective GNSS data of the vehicle generated by the GNSS receiver when driving on the respective segment;
- and
- saving the respective global lane data, wherein the respective global lane data specifies the respective course of the lane on the respective segment in global coordinates.