# LandscapeEditorUtils::SetHeightmapData

**URL:** <https://forums.unrealengine.com/t/landscapeeditorutils-setheightmapdata/488407>\
**Category:** World Creation\
**Tags:** c-build, ue4-editor, unreal-engine, question\
**Created:** [September 5, 2021, 10:28am UTC](https://forums.unrealengine.com/t/landscapeeditorutils-setheightmapdata/488407 "2021-09-05T10:28:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jikks](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@jikks](https://forums.unrealengine.com/u/jikks)\
**Post date:** [September 5, 2021, 10:28am UTC](https://forums.unrealengine.com/t/landscapeeditorutils-setheightmapdata/488407/1 "2021-09-05T10:28:46Z")

</div>

I had code a perlin noise terrain generate function refer to a book.  
The example has use the LandscapeEditorUtils::SetHeightmapData function to recreate terrain haight.  
If it’s ok, return true.  
I use it, and the result is true.  
But, landscape has nothing to change.  
I wonder why the problem. Thanks a lot.

here the code:

```
// MUST CALL.
	ULandscapeInfo::RecreateLandscapeInfo(GetWorld(), 1);

	// Get all the landscapes in the level.
	TArray<ALandscape*> landscapes = GetLandscapes();

	// Go thru all landscape objects..
	for (ALandscape* landscape : landscapes)
	{
		FIntRect rect = landscape->GetBoundingRect();
		// LandscapeEditorUtils::SetHeightmapData adds one to each dimension
		// because the boundary edges may be used.
		int32 cols = rect.Width() + 1, rows = rect.Height() + 1;
		int32 numHeights = cols * rows;
		//Info(FS("LANDSCAPE `%s` measures %dx%d has %d elts",
		//	*landscape->GetName(), rows, cols, numHeights));

		UE_LOG(LogTemp, Warning, TEXT("Landscape gogogogoogogogo"));

		TArray<uint16> Data;
		Data.Init(0, numHeights);

		// #octaves to sum, period in x, period in y.
		// The larger the period, the more variation we get
		// in the lowest frequency.
		int32 octaves = 16, px = 4, py = 4;
		float amplitude = 1000.f;
		for (int i = 0; i < Data.Num(); i++)
		{
			float nx = (i % cols) / (float)cols; //normalized col
			float ny = (i / cols) / (float)rows; //normalized row
			Data[i] = PerlinNoise2D(nx, ny, amplitude, octaves, px, py);

			//UE_LOG(LogTemp, Warning, TEXT("The Data: %d"), Data[i]);
		}

		bool isSuccessed = LandscapeEditorUtils::SetHeightmapData(landscape, Data);
		UE_LOG(LogTemp, Warning, TEXT("is Successed:%s"), isSuccessed?TEXT("Ture"):TEXT("False"));
		ULandscapeInfo::RecreateLandscapeInfo(GetWorld(), 1);

		// resample to ensure it works
		//LandscapeEditorUtils::ResampleData<uint16>( Data, cols, rows, cols, rows );

		
	} // each landscape
```
