Odawara Castle - Sogamae
The sogamae refers to the outer ring of defenses developed by the Hojo against attacks from Hideyoshi and his allies. The 9km network of defenses was so impressive that some of the lords who saw it took the idea back home after the Siege of Odawara to help fortify their own castles.
Here is a map to the Sogamae: https://odawaracastle.com/global-image/units/upfiles/304-1-20171016150531_b59e44c2bc1c75.pdf
dug to prevent attackers from easily entering or moving around a castle. There are also various subtypes depending on the location in the castle and orientation such as horizontal, vertical or across a mountain ridge. There are also subtypes depending on structure like unebori and shouji-bori.