The procedural foliage volume does this.
Check the function in FoliageEdMode.cpp “LandscapeLayerCheck” and “GetMaxHitWeight” (which seems similar to what youre trying to do)
And more specifically ULandscapeComponent::GetLayerWeightAtLocation and ULandscapeComponent::GetLandscapeInfo().GetLayerInfoByName(…)
you would need to have layers in your landscape, which you achieve by adding a “sample layer” node in your material using a chosen name.
(related xkcd: Wisdom of the Ancients )
