At Cape Juby, Morocco, we can see with Google Maps a rectangle of 3 km long, in which there is hundreds of little squares. What method was used to draw these squares on the sand? More importantly, why are these square drawn?

At Cape Juby, Morocco, we can see with Google Maps a rectangle of 3 km long, in which there is hundreds of little squares. What method was used to draw these squares on the sand? More importantly, why are these square drawn?

They are not perfectly straight. Making them with modern GPS equipment should not be too difficult, you just keep a fixed distance to the previous line. They are only 5-6 meters wide.
Googling for cape juby tarfaya sand beach experiment I found this 16 Jan 2013 entry from the blog An overland adventure mentioning:
"Between the road and the sea is another experiment to save Tarfaya from being swallowed up by the Ergs (=sand dunes), mangrove. These trees have been introduced here from the tropics as one of the few salt loving, sand rooting toughs. They seem quite young from the window of the truck so I am guessing it is too early to tell if the project has been a success."
Maybe this is what you are seeing. I have contacted the blog writer to ask for confirmation. Update: The author confirmed that this is indeed what you're seeing: "Yes. Shame there is no picture."
Subsequent Googling for tarfaya mangrove turns up more info (often in French, where palétuvier is indeed mangrove), e.g. this Les mangoves du Sahara chapter from the Book Maroc 8 - Sud du Maroc et Sahara Occidental. This Lonely Planet E-Book PDF Marokko Reiseführer which is almost a literal translation, mentions a 900 meter long strip, but the artifact in the picture is approx 3.2 km.
The planting project was named The Manzanar project
It's an effort to help stymie sand dune erosion. It appears this photo was taken early before the grass or straw took root.
http://www.dw.de/grid-of-straw-squares-turns-chinese-sand-to-soil/a-15182754