How to Make a 3D Globe from 2D Vector Data

Liz Sanderson
Liz Sanderson
  • Updated

FME Version

Introduction

This example shows how a 2D map in latitude and longitude can be converted into a 3D globe.

In this tutorial, we will be walking through how to create the resulting workspace found in the Files section to the right. The workspace takes a shapefile with very generalized country shapes, chops all the countries into separate points and calculates 3D coordinates for each point separately, rebuilds polygons in 3D, and extrudes them according to the extrusion vectors also calculated within the workspace.

 

Step-By-Step Instructions

Part 1: Create Data

image.png

 

1. Open FME Workbench

Open FME Workbench and click New to create a new workspace.

 

2. Add the Data to the Canvas

Add the “simpleWorld” shapefile to the canvas by downloading the file from the Files section and dragging the file onto the canvas. Click OK. 

 

3. Add an AttributeCreator and a FeatureColorSetter

Add an AttributeCreator and a FeatureColorSetter to the canvas and connect them sequentially to the simpleWorld reader feature type. Set the FeatureColorSetter Color Scheme to Random in the parameters. In the AttributeCreator create three new attributes as follows:
 

New Attribute Attribute Value
_layer countries
_radius 6100
_elevation 1000

 

4. Creating the Background and Graticule

Add a Creator and another AttributeCreator to the canvas and connect the new AttributeCreator_2 to the Creator. The Creator parameters will be as follows:

  • Geometry Source: 2D Min/Max Box
  • Coordinate List: -180 -90 180 90
  • Coordinate System: [blank]
  • Number to Create: 1
  • Create at End: No
  • Creation Instance: _creation_instance


image.png

In the AttributeCreator_2 create new attributes as follows:
 

New Attribute Attribute Value
_layer graticule
_radius 6000
_elevation 1000

 

5. Add a Tiler

Add a Tiler to the workspace and connect it to both the AttributeCreator Output ports. In the Tiler parameters, set Define Tiles By to  Dimensions in Ground Units, Starting Corner to lower left, Width (x): 5, Height (y): 5, and the Output Attribute Names will be set to Row: _row and Column: _column, respectively. 

image.png

 

6. Validate Geometry

Add a GeometryValidator to the canvas, connect it to the Tiles output port of the Tiler, and change the Set of Issues to Detect to “Basic Integrity”.

 

7. Creating Polygons and Providing them with Unique IDs

Add a Deaggregator and a Counter to the canvas, connect the Deaggregator to the Passed output port of the GeometryValidator and the Counter to the output port of the Deaggregator. Leave all parameters as defaults for the Deaggregator. In the Counter, set the Count output attribute to “polyID”.

 

Part 2: Vertex Recalculation

In this part we will be recalculating vertices to geocentric coordinates.

image.png
 

1. Add the Chopper

Add a Chopper to the canvas and connect it to the output port of the Counter. The Chopper parameters include setting the Mode to By Vertex, Maximum Vertices to 1, and Aggregate Handling to Deaggregate. 

 

2. Add a Counter and CoordinateExtractor

Add another Counter to the canvas and connect it to the Chopper. In the parameters,set the Count Output Attribute to vertexID.

Next, add a CoordinateExtractor and connect it to the Counter_2. The parameters include setting the Mode to Specify Coordinate, Coordinate Index to 0, and having the output attributes for X,Y,Z to be long, lat, _z, respectively. 

 

3. Add an AngleConverter

Connect an AngleConverter to the CoordinateExtractor. In the parameters, set Covert Angles On to Attributes Only. Then select lat, and long as the Attributes Containing Angles. Finally, the Source Angle Type is Decimal Degrees, and the Target Angle Type is Radians. 

 

4. Calculate the Geocentric Coordinates

Add another AttributeCreator, in the parameters, create the following three attributes, these will calculate the geocentric coordinates: 

New Attribute Attribute Value
x @Value(_radius)*cos(@Value(long)+3.14159)*sin(@Value(lat)+3.14159/2.0)
y @Value(_radius)*sin(@Value(long)+3.14159)*sin(@Value(lat)+3.14159/2.0)
z @Value(_radius)*cos(@Value(lat)-3.14159/2.0)

 

5. Calculating the Extrusion Vector

Next, we will be calculating the extrusion vector with another AttributeCreator. Connect the AttributeCreator_4 to the AttributeCreator_3. In the parameters, create the following three attributes:  

New Attribute Attribute Value
_vector_x -@Value(_elevation)*cos(@Value(long)+3.14159)*sin(@Value(lat)+3.14159/2.0)/10.0
_vector_y -@Value(_elevation)*sin(@Value(long)+3.14159)*sin(@Value(lat)+3.14159/2.0)/10.0
_vector_z -@Value(_elevation)*cos(@Value(lat)-3.14159/2.0)/10.0


Note that steps 3 and 4 could be combined into a single AttributeCreator, but were broken into two transformers for clarity. 

 

Part 3: Building Points and Assembling Polygons

image.png

1. Build 3D Points

Add a VertexCreator to the canvas and connect it to the AttributeCreator_4, it will have the “Replace with Point” mode set and have the X, Y, and Z values set to x, y,and z, respectively. Add a Sorter to the canvas and connect it to the output of the VertexCreator. Have the Sorter sorted by:

Attribute Alpha/Num Order
polyID Numeric Ascending
vertexID Numeric Ascending

 

2. Reassembling Polygons

Add a LineBuilder to the canvas and connect it to the Sorter. Add a LineCloser as well and connect it to the Line output port of the LineBuilder. In the LineBuilder parameters, enable Group Processing, then set the Grouped By to polyID. Leave the LineCloser parameters as default. 

 

Part 4: Output

image.png

 

1. Add an AttributeFilter

Add an AttributeFilter to the canvas and connect it to both the Polygon output of the LineBuilder and the output of the LineCloser. In the parameters, set Attributes to Filter By to _layer, then type in graticule and countries as the Possible Attribute Values. 

image.png

2. Graticule Output

Add a FeatureColorSetter to the graticule output port of the AttributeFilter and set the Unique Color Limit to 1. 

The globe can be written to any format that supports surfaces or meshes such as Sketchup, 3D PDF, AutoDesk FBX, etc. In this example, we will write to an Adobe 3D PDF and create two destination feature types for both the graticule and the countries. 

Add an Adobe 3D PDF writer to the canvas by typing in the canvas “Adobe 3D PDF”, selecting the writer, providing a path and name, with its Layer Definition set to Automatic, and connect it to the FeatureColorSetter_2 output port.

 

3. Countries Output

Add an Extruder to the canvas and connect it to the countries output port on the AttributeFilter. In the Extruder parameters, set the Direction to Specified. Next, for Extrusion Vector X, Y and Z, set it to the attributes _vector_x, _vector_y, and _vector_z, respectively. 

On the top menu bar, go to Writers > Add Feature Type, to add another Adobe 3D PDF layer; name this Layer countries. Connect the countries writer feature type to the Extruder. 

 

4. Run Workspace and Check your Output

Run the workspace with Feature Caching enabled to view the output in the Visual Preview window or check the output by opening the file in Adobe. The output should look like this:


Input:
image.png

Output in Adobe:
image.png

Globe Creation Process

image.png

Actually, attempts to make digital 3D globes started many years ago - around 1996. At the time, MicroStation 3D capabilities were amazing, and wanted to make something really cool. Creating a sphere, and covering the surface with an image representing the map of Saint Petersburg, Russia. (1) The globe was quite well received by colleagues, and one local newspaper published an article about the globe and city planners having fun at work.

Wondering how our geography, cartography or geodesy would look like if those who made our planet also would make the same error in trigonometry and use a cosine instead of a sine in this simple formula. (2) The next globe also was not quite right - countries didn't want to stick properly to Earth, which made an interesting effect. (3) Eventually, all the problems were resolved and got the final globe. (4)

 

Data Attribution

Data used in this tutorial originates from data made at Safe Software and example data that came with the MapInfo 2008 install. 

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.