This could be the first step.
Then find a way to save render to target to a texture, from there it’s just image processing getting the pixels, but render to target I hear can also do this directly without converting to texture by reading the pixels off of the render to target. Pixels for heightmap repersent 1 per 1 as in 1 pixel = 1 vertex point. 3 vertex points = 1 triangle. You can get I think pretty easy the amount of pixels per one area. I think looking with the camera is pretty good as the culled don;t show up into the render to target and what you see is what you get.
There is a way to do this live.
But it’s slow…
There is also a way to do it live on a texture that you save but it requires image processing code in an extensive manner.
In the end you can draw triangles if you have the pixels as vertex data, you have to build an instant heightmap system when you click some button after you view an area draw a mesh, the triangle system is automated at this point, it just counts the vertex points in a procedural way, alocates indices for it and then draws the triangles from the vertexes that were initial pixels.
If that is what you want then this could be one way of doing it.