Terrain data

From kevinpbuckley/VibeUE · View interactive version

Terrain data is an AI agent skill from the GitHub repository kevinpbuckley/VibeUE. Build terrain from geographic coordinates with aligned heightmaps, orthophotos, feature masks, map and water vectors, and vista backdrops using terrain_data.

How to use this skill

Skill file

🧠 Brains complement: IF an unreal-engine-skills-manager tool (external MCP) exists in this session, call it with {action: "load", skill: "landscape-and-foliage"} for UE domain knowledge on this topic β€” correct APIs, architecture, best practices β€” and treat it as the rubric for any review / "best practices" question. If no such tool is available (e.g. running under Claude Code or Codex without that MCP), skip this line entirely and proceed with this skill alone β€” do NOT attempt the call.

Real-World Terrain Skill

Use terrain_data with the VibeUE API key configured in Editor Preferences β†’ Plugins β†’ VibeUE. Generated files default to the project's Saved/Terrain/ directory.

Aligned workflow at Enchanted Rock

Use longitude βˆ’98.819936, latitude 30.505025 and a 3 km square for every step. Heightmaps are now centred exactly on the requested point. Pass exact_center=false for the old off-centre crop on preview and heightmap (up to half a source tile away, about 1 km here). Check the returned alignment (exact or legacy) before overlaying imagery or geometry. Pass landscape_space=true to get_water_features: without it the water coordinates are the ones older builds wrote, with +Y north, mirrored north-south on the landscape.

| Step | Tool call | What to use |

| --- | --- | --- |

| 1. Preview | terrain_data(action="preview_elevation", lng=-98.819936, lat=30.505025, map_size=3) | Read minHeight, maxHeight, suggestedBaseLevel, suggestedHeightScale and alignment. |

| 2. Heightmap | terrain_data(action="generate_heightmap", lng=-98.819936, lat=30.505025, map_size=3, resolution=1009, base_level=0, height_scale=100) | Import the 16-bit PNG at file. For this example the XY scale is 297.619048 cm per quad and Z scale is 200. Use the preview settings if you need a different vertical mapping, and repeat them for the vista. |

| 3. Orthophoto | terrain_data(action="get_ortho_image", lng=-98.819936, lat=30.505025, map_size=3, size=4096, source="auto", band="both") | files.rgb is one stitched quality-92 JPEG. files.canopy is a linear 8-bit PNG vegetation proxy. manifest_file is the saved server manifest (bounds, credit). The result also has size, metres_per_pixel (ground metres per texel: 0.732600733 at 4096), source (naip or mapbox), source_reason, acquisition_years, attribution, license_note, import_hints and uv_formula (and fallback_reason when NAIP failed and the image was restarted from Mapbox). Canopy requires NAIP (United States); elsewhere auto picks Mapbox and only rgb exists. |

| 4. Masks | terrain_data(action="get_feature_masks", lng=-98.819936, lat=30.505025, map_size=3, resolution=1009, layers="surface,landcover,parking,road_distance", prefer="auto") | files (layer β†’ PNG path), resolutions (layer β†’ actual side), layers (layer β†’ channel β†’ meaning), counts, notes, source, import_hints, uv_formula and the saved manifest_file. Surface and landcover are 8-bit RGBA, parking is 8-bit grey, road distance is 16-bit grey in centimetres. Keep all channels linear, preserve RGB under zero alpha, and use lossless compression. |

| 5. Map features | terrain_data(action="get_map_features", lng=-98.819936, lat=30.505025, map_size=3, categories=["roads","buildings","pois"], min_spacing_m=0, max_features=500, prefer="auto") | file holds full vectors, tags, IDs and provenance. The reply gives counts, truncated, notes, source, attribution, license, alignment and first_names (up to five distinct names per category). In the file read ue5_point, ue5_points or ue5_rings for point, line or polygon geometry ({x, y, z} in centimetres, z 0). The first ring is the exterior and subsequent rings are holes. |

| 6. Water | terrain_data(action="get_water_features", lng=-98.819936, lat=30.505025, map_size=3, landscape_space=true, detail="high", min_spacing_m=0) | Read the saved JSON at file for complete lines and rings (ue5_points, ue5_rings: with landscape_space=true on the landscape's axes, north negative Y). The reply lists water bodies, waterways and point counts. Omit both options for the original server detail and spacing (at Enchanted Rock: 14 waterways / 223 points by default, 36 / 439 with detail="high", min_spacing_m=3). Water comes from whole source tiles, so some of it lies outside the landscape square. |

| 7. Vista | terrain_data(action="generate_vista_heightmap", lng=-98.819936, lat=30.505025, map_size=3, resolution=1009, base_level=0, height_scale=100, vista_factor=8) | file and alignment_file (the same numbers as a JSON sidecar) describe a 24 km backdrop (map_size_km). Use suggested_xy_scale (2380.952381 cm), suggested_z_scale (200), fractional inner_rect, and clipped / clipping. Match the playable landscape's centre, Z location and processing settings. |

Keep the returned attribution and license (or license_note) with the saved files and derived assets (map features, masks and orthophotos return them; heightmaps, vistas and water do not). Display imagery attribution when presenting the imagery. get_map_image provides a quick reference picture and list_styles lists its available styles.

Files, sources and waiting

Registration and request options


Test Prompts

Create a landscape from the terrain around Mount Fuji
Generate a heightmap for San Francisco at coordinates -122.4194, 37.7749
Build a real-world landscape from the Swiss Alps near Zermatt (lng=7.7480, lat=46.0207)
Get the terrain around the Grand Canyon and make a landscape
Generate heightmap for Tokyo at 139.6917, 35.6895 with a satellite reference image

Step-by-Step Example (Mount Fuji)

Step 1 β€” Preview elevation

terrain_data(action="preview_elevation", lng=138.7274, lat=35.3606)

Response:

{
  "minHeight": 340.0,
  "maxHeight": 3776.0,
  "heightRange": 3436.0,
  "suggestedBaseLevel": 340,
  "suggestedHeightScale": 27,
  "suggestedZScale": 741,
  "suggestedXYScales": { "505": 3429, "1009": 1714, "2017": 857, "4033": 429, "8129": 213 },
  "tileZoom": 13,
  "tileCount": 9,
  "alignment": "exact"
}

Preview XY scales are rounded. Use 100000 * map_size / (resolution - 1) for exact registration when calling create_landscape. Use suggestedZScale for the Z scale.

Step 2 β€” Generate heightmap using suggested values

terrain_data(
  action="generate_heightmap",
  lng=138.7274, lat=35.3606,
  base_level=340,
  height_scale=27,
  resolution=1009, format="png"
)

Response:

{
  "success": true,
  "file": "C:/Project/Saved/Terrain/heightmap_35.3606_138.7274.png",
  "min_height_m": 340.0,
  "max_height_m": 3776.0,
  "dimensions": "1009x1009",
  "alignment": "exact"
}

Step 3 β€” Get satellite reference image

terrain_data(
  action="get_map_image",
  lng=138.7274, lat=35.3606,
  style="satellite-v9"
)

Response:

{
  "success": true,
  "file": "E:/Project/Saved/Terrain/map_satellite_v9_35.3606_138.7274.png",
  "style": "satellite-v9",
  "size_bytes": 1981147
}

Step 3b β€” Attach satellite image for vision analysis

⚠️ CRITICAL: After downloading a satellite image, ALWAYS attach it so you can see the terrain colors and features. This lets you make informed decisions about material layers and painting.

attach_image(file_path="E:/Project/Saved/Terrain/map_satellite_v9_35.3606_138.7274.png")

attach_image is a tool call (like terrain_data), NOT a Python function. Do NOT put it inside execute_python_code. Call it directly as a tool. If no attach_image tool is available in your session, skip this step and proceed using the saved file path returned by get_map_image.

After attaching, you will see the satellite image in your next response. Use it to:

Step 4 β€” Import into UE5

Use the landscape skill to import the heightmap file:

Example:

result = unreal.LandscapeService.create_landscape(
    location=unreal.Vector(0, 0, 0),
    rotation=unreal.Rotator(0, 0, 0),
    scale=unreal.Vector(1714.2857, 1714.2857, 741),  # XY = 100000 * map_size / (resolution - 1), Z from suggestedZScale
    sections_per_component=2,
    quads_per_section=63,
    component_count_x=8,
    component_count_y=8,
    landscape_label="MyLandscape"
)

Parameters Reference

generate_heightmap

| Parameter | Default | Notes |

|-----------|---------|-------|

| lng / lat | required | Decimal degrees. Positive = East/North |

| format | png | 16-bit grayscale PNG, big-endian uint16 RAW (byte-swap for native little-endian import), or ZIP containing PNG and info |

| map_size | 17.28 | km β€” Cities: Skylines standard |

| resolution | 1081 | Samples per side, 33–4097. Pass the landscape's vertex count (505, 1009, 2017, ...) |

| exact_center | true | Centre the square exactly on lng / lat; the reply says alignment: "exact". false = the crop older builds returned (alignment: "legacy"), which does not line up with masks, orthophotos or vectors |

| base_level | 0 | Use suggestedBaseLevel from preview |

| height_scale | 100 | Use suggestedHeightScale from preview |

| water_depth | 40 | Cities: Skylines water units |

| gravity_center | 0 | 0=off, 2=N, 4=E, 6=S, 8=W (tilts terrain for water flow) |

| level_correction | 0 | 0=none, 2=flatten coastlines, 3=aggressive |

| blur_passes | 10 | Adjust per terrain character! 5–10=rugged, 15–25=hills, 25–40=smooth/flat. See Terrain Character Guide |

| plains_height | 140 | Meters β€” threshold between plains and mountains |

| save_path | auto | Saves to <ProjectDir>/Saved/Terrain/ by default |

get_map_image styles

| Style | Description |

|-------|-------------|

| satellite-v9 | Quick aerial reference |

| outdoors-v11 | Topo with trails and contours |

| streets-v11 | Street map |

| light-v10 / dark-v10 | Minimal |


UE5 Landscape Import Settings

Valid Resolutions β€” Always Pass `resolution=N`

⚠️ Never use the default 1081Γ—1081 for UE landscapes β€” it requires 36Γ—36 components and will timeout. Always pass resolution= matching your landscape config.

| resolution= | Components | Quads | Sections | km at UE scale=100 |

|-------------|-----------|-------|----------|--------------------|

| 505 | 8Γ—8 | 63 | 1 | ~0.5 km |

| 1009 | 8Γ—8 | 63 | 2 | ~1.0 km |

| 1009 | 16Γ—16 | 63 | 1 | ~1.0 km |

| 2017 | 16Γ—16 | 63 | 2 | ~2.0 km |

| 4033 | 32Γ—32 | 63 | 2 | ~4.0 km |

"km at scale=100" is the UE world size when landscape XY scale = 100 cm/quad (default). Adjust scale to match real geography (see below).

Matching Real-World Scale

terrain_data's map_size (default: 17.28 km) controls the geographic area captured. To make the UE landscape match actual geography:

UE XY Scale (cm/quad) = (map_size_km Γ— 100,000) / (resolution βˆ’ 1)

Example: map_size=20, resolution=2017 β†’ (20 Γ— 100,000) / 2016 β‰ˆ 992 cm/quad (~9.9 m/quad)

Set this as the landscape's X and Y scale when creating it.

Format and Z Scale

⚠️ ALWAYS calculate Z Scale from height_scale. Do NOT guess. Use this formula when creating the landscape:

z_scale = 20000 / height_scale

For absolute elevations, set the actor Z at local zero to 100 * base_level + 32768 * z_scale / 128 cm. Use the same local datum offset for the inner map and vista.

Derivation: pixel encoding is pixel = elevation_m × heightScale × 64 / 100 and UE interprets height_cm = pixel × z_scale / 128. Setting height_cm = elevation_m × 100 (meters→cm) gives z_scale = 20000 / heightScale.

| height_scale | Z Scale | Terrain Type Example |

|-------------|---------|---------------------|

| 27 | 741 | Tall mountains (Mt. Fuji, Alps) |

| 50 | 400 | Moderate mountains (Appalachians) |

| 100 | 200 | Hills, canyons (Grand Canyon) |

| 150 | 133 | Low hills, mesas |

| 200 | 100 | Gentle rolling terrain |

| 250 | 80 | Very flat terrain, gentle domes |

For Cities: Skylines, export as PNG and import via the standard heightmap importer (1081 default is fine there).


Terrain Character Guide

⚠️ CRITICAL: The suggestedHeightScale from preview_elevation maximizes detail, but also amplifies noise. You MUST adjust blur_passes based on the terrain character.

Identifying Terrain Character

After preview_elevation, look at the heightRange and think about what the terrain actually looks like:

| heightRange | suggestedHeightScale | Terrain Character | blur_passes |

|-------------|----------------------|-------------------|-------------|

| > 2000m | Low (< 50) | Rugged mountains β€” keep default blur | 5–10 |

| 500–2000m | Moderate (50–100) | Mixed terrain β€” moderate smoothing | 10–15 |

| 100–500m | High (100–200) | Hills/mesas β€” needs more smoothing | 15–25 |

| < 100m | Very high (200–250) | Flat/gentle β€” needs heavy smoothing | 25–40 |

Smooth vs Rugged Terrain

Smooth terrain (granite domes, rolling hills, plains, gentle slopes):

Rugged terrain (jagged peaks, canyons, volcanic craters):

Common Mistake: Jagged Smooth Terrain

If you get a terrain that looks jagged/spiky when the real place is smooth:

  1. The height_scale was too high without enough blur_passes
  2. Fix: Re-generate with blur_passes=30 or higher
  3. Also check: Z scale should be 20000 / height_scale, NOT an arbitrary value like 200

Water Features Reference

get_water_features

Fetches waterways and water bodies from Mapbox vector tiles. Use the exact same lng, lat, and map_size as your heightmap call.

terrain_data(action="get_water_features", lng=-105.0, lat=39.7, map_size=17.28, landscape_space=true)

Response includes:

The saved JSON file contains the full data with:

⚠️ CRITICAL FIELD NAMES:

Coordinate system

ue5_points and ue5_rings are landscape-center-relative (origin-centered):


Troubleshooting

| Issue | Fix |

|-------|-----|

| 429 rate limit | Read the error for the daily request quota or hourly tile/layer allowance and its UTC reset |

| HTTP_503 (or HTTP_502 / HTTP_504 without detail) | An upstream source (OpenStreetMap, NAIP, Mapbox) failed or was too slow; upstream and retry_after_s say which and how long to wait. Call again; for vectors use prefer="auto" |

| Flat heightmap | heightRange < 50m β€” use height_scale: 250 for detail |

| Clipped mountains | Lower height_scale or increase base_level |

| Jagged/spiky terrain | Increase blur_passes (20–40 for smooth terrain) and check Z scale formula |

| Terrain doesn't match real place | Check terrain character guide β€” smooth places need high blur_passes |

| Timeout | Reduce the extent, resolution or filter passes for the operation |

| No waterways returned | Area may have no mapped water features (desert, urban grid) β€” check satellite image |

| Landscape too small | You used XY scale=100 (default) instead of the correct value from suggestedXYScales. Recreate with the correct scale |

| Black screenshots after camera move | Camera inside terrain. Use ActorService.get_actor_view_camera() to frame from TOP view instead of guessing Z height |

| Water features timeout | PBF tile fetch uses 45s timeout β€” large map_size at high zoom may still be slow |

| Field name errors | Use ue5_points (not points), ue5_rings (not polygon), class (not waterway_class) |

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.