Disclaimer: Links to third-party websites are provided for convenience only. The fact that LMC has provided a link to a third-party’s website does not constitute an implicit or explicit endorsement, authorization, sponsorship, or affiliation by LMC with respect to such website, its owners, content, products, or services. By clicking on a third-party link, you will leave the LMC website and will be subject to the privacy and security policies of the third-party website.
The Prepar3D Software Development Kit (SDK) has numerous functionalities enabling users to customize their Prepar3D experience. One of these features allows users to import imagery to create a more immersive flying experience with geo-specific data. Prepar3D’s terrain system utilizes geographic information system (GIS) data techniques enabling realistic flights over accurate terrain across the entire earth. However, it may be desired to use satellite imagery in specific scenarios. To address this, not only does Prepar3D have 40 (and counting) high-detail cities around the world, but also has SDK tools letting users choose which areas they want to replace with custom imagery.
Importing imagery into Prepar3D consists of the following steps: First, the satellite imagery itself must be downloaded and converted to the proper file format. Following this, a third-party tool will reproject and reformat the file into the proper coordinate system that Prepar3D uses. Then, using the SDK’s resample tool, a .bgl file will be created, enabling the user to replace default terrain data. Once this is finished, the new terrain data can be seen in Prepar3D and scenery objects can be autogenerated onto the existing terrain through other SDK and third-party tools.
First download and install FWTools, an open-source GIS tool made by Frank Warmerdam. Using the USGS National Map (recommended for geospatial data within the US), requires downloading the following items. Using geospatial data from other sources may also require these items as they’re used for various file conversions.
Download and extract the Raster Conversion Scripts files from here, which are geospatial file conversion scripts.
The above scripts require the use of GDAL (Note: the correct installer will be the gdal-[version]-core.msi).
ScenProc is a third-party tool that can speed up the process of adding large amounts of scenery objects (buildings, vegetation, etc.).
Procedure: Updating Terrain
- If using the USGS National Map, download a JP2 file(s) from here. To do this, select an area using the “Draw Rectangle” tool and then select “Imagery – NAIP Plus (1 meter to 1 foot)” option on the left before hitting “Find Products”. Multiple options may appear depending on how large of an area is selected so be sure to view the footprint of each .jp2 file before downloading to know what area of imagery is being downloaded.
- If using the USGS National Map or have other geospatial data that is not in a GeoTIFF format, use the USGS Raster Conversion Scripts to make this file change. Navigate in command line to the ……USGS_Raster_Conversion_ScriptsJP2_Source folder and run this command:
- GDAL_JP2_2_GeoTIFF.bat “Input JP2 file location & name” [Output TIFF file location & name]For more information on how to convert to GeoTIFF, refer to this guide.
- Reproject the GeoTIFF with FWTools by opening up “FWTools Shell” from the Start menu and running this command:
- gdalwarp -t_srs “+proj=longlat +ellps=wgs84 +datum=wgs84 +units=d” -s_srs EPSG:3857 “Input TIFF file location & name” “Output TIFF file location & name”
- Reformat the GeoTIFF file with FWTools by running this command in the FWTools shell:
- gdal_translate -b 1 -b 2 -b 3 -co “TFW=YES” “Input(Output file from prev. step) TIFF file location & name” “Output TIFF file location & name”
- Note: Skip this if your scenery is majority water.
- Create an INF file in any text editing program (i.e. Notepad or Notepad++) with the following content:
Type = GeoTIFF
SourceDir = <Input GeoTIFF File location>
SourceFile = <GeoTIFF file name>
Layer = Imagery
Variation = Day
NullValue = 0,0,0
DestDir = <Export BGL file location>
DestBaseFileName = <BGL file name>
DestFileType = BGL
LOD = Auto
Note: If adding scenery objects, ensure the folder with the BGL files is titled “Scenery”.
6. Run the resample tool by navigating to the folder containing resample.exe and dragging the .inf file on top of it.
7. Once in Prepar3D, navigate to the Scenery Library (click on Scenery on the startup screen or go to World, then Scenery Library once in a scenario), click on “Add Area”, navigate to the folder with all the BGL output files and hit OK.
8. Enjoy the new terrain, where viewing a mountaintop went from looking like the image on the left to the right.
Procedure: Adding Autogeneration Objects
Note: If generating a small amount of buildings or vegetation the Annotator tool can be used instead of the steps listed below. Refer to the autogeneration overview page in the Learning Center for an in-depth tutorial on the Annotator tool.
- Run a query on OpenStreetMap data using Overpass. For example, the query on the right is finding all the buildings and natural landscape (forests, ponds, wetlands, etc.) within an area bounded by the window of the map itself. The output is shown on the map with different areas colored accordingly. For more information on writing queries to access different types of data, consult the OpenStreetMap wiki. Note: OpenStreetMap is open-source so there is a chance to come across missing or erroneous data, however this is rare.
- Export raw OSM data once satisfied with the Overpass output.
- Using ScenProc, write a script (or utilize a template) to transform the raw OSM data into AGN files that Prepar3D can use. Documentation for ScenProc is in“ScenProc.pdf” which should be in the .zip file downloaded earlier. When configuring ScenProc upon startup, select the latest version of Prepar3D (currently v3 and v2) that’s supported by this tool. While ScenProc doesn’t officially support Prepar3D v4, the tool still works correctly. Below is an example script that uses building and natural landscape OSM data to generate houses and trees in a neighborhood. Important: Ensure that the EXPORTAGN command directs the AGN files to a folder labeled “texture” that is in the same folder as the “Scenery” folder from Step 5 of Terrain above.
Note: Depending on what data is imported from OpenStreetMap, the GUIDs at the bottom may be different (e.g. larger buildings, different climactic zone, etc.). There are .xml files located in WorldAutogenerationAutogen source xml that have other GUIDs that can be copied over to the appropriate areas of the ScenProc script.
- Run the script and navigate in File Explorer to the “texture” folder and ensure the AGN files are present.
- To confirm that the script worked, open the BGL file from Step 6 of Terrain through the Annotator tool, which is in …SDKWorldAutogeneration. The file should look similar to this, although it depends on the exact query and script.
- Open Prepar3D again (if its open, close it before opening), navigate to the area with autogenerated objects, and increase the Autogen Vegetation/Building Density settings in Options->Graphics->World
- Enjoy the more realistic surrounding landscape by transforming the terrain and autogen as shown below!
# Add attribute to indicate the type of building
# 1 = ALMOST RECTANGLE (BASED ON AREA RATIO)
# 3 = REGULAR SHAPED (MANY PARALLEL EDGES)
# 4 = CONVEX POLYGONS
# 5 = CONCAVE POLYGONS
ADDATTRIBUTE|FTYPE=POLYGON;building=*;BUILDTYPE!1;FNUMVERT<10;FNUMPERPANG>3;FNUMNOTPAR<2|BUILDTYPE|3 ADDATTRIBUTE|FTYPE=POLYGON;building=*;BUILDTYPE!1;BUILDTYPE!3;FCONVEX=1|BUILDTYPE|4 ADDATTRIBUTE|FTYPE=POLYGON;building=*;BUILDTYPE!1;BUILDTYPE!3;BUILDTYPE!4|BUILDTYPE|5 # # Classify industrial/commercial buildings ADDATTRIBUTEIFINSIDE|FTYPE=POLYGON;building=*|LUCODE=16|BUILDCAT|INDUSTRIAL ADDATTRIBUTEIFINSIDE|FTYPE=POLYGON;building=*|LUCODE=15|BUILDCAT|COMMERCIAL # # Add attribute for roof type ADDATTRIBUTE|FTYPE=POLYGON;building=*;FWIDTH>5|ROOFTYPE|PEAKED_ALL
# Remove complex buildings
# Create buildings autogen
EXPORTAGN|P3D v2|C:UserstestDocumentsPrepar3D v4 Add-onsAddon Scenerytexture
In just a few steps Prepar3D default scenery and terrain can be enhanced to improve and customize the Prepar3D flying experience!