The adequate translation for the geometric shape is ligne here.
Les canards étaient assis en ligne.
Ils formaient une ligne.
On pouvait voir une ligne de canards.
When used in conjunction with a verb, the corresponding adverbial group is en ligne:
Ils étaient rangés en ligne.
The verb to express this is aligner used in a passive form:
Les canards étaient alignés.
Les rangs is only used to indicate that the formation is deliberately ordered (or looks like it).
On aurait dit les rangs d'une armée de canards.
Also, une rangée is one row of a (maybe fictive) bigger formation.
Plusieurs rangées de canards s'approchaient de l'étang.
Le rang has nothing to do with the actual geometry, it refers either to the position inside an ordering (which may be a spacial ordering), or to the general concept of maintaining a hierarchy or a formation.