Overlay Locations on a 3D Map

With the introduction of Maps Online app in Origin 2016, now you are able to fetch map from a WMS server either as an image or as matrix data. In this blog, I will show you how to import map data into Origin, and create a 3D map from it and then overlay the location information as scatter on the map.

Overlay_World_Map_on_Sphere_01a

If you are willing to walk through the steps with me, please download this Sample Data.zip file we have prepared and extract to open the project file Sample Data.opj. You should see a workbook with the latitudes and longitudes of capitals for a few countries, which will be overlaid as scatter on the world map as shown above.

Overlay_World_Map_on_Sphere_02

Create a 3D World Map

To create a spherical world map, we need to fetch map data from WMS server first and use it as the colormap of a sphere created from parametric function.

Import Map Data to a Matrix
  1. Click on the Maps Online app icon on Apps Gallery window to launch the app.

Overlay_World_Map_on_Sphere_03

  1. Set the options in the dialog as shown below. Click this button Overlay_World_Map_on_Sphere_05 to bring up Load Into and Area options.

Overlay_World_Map_on_Sphere_04

  1. Click this button Overlay_World_Map_on_Sphere_05 again and go to Area menu and select 90ºN, 180ºW ~ 90ºS, 180ºE.

  2. Click OK button to apply the settings and load map data to a matrix window. It might take seconds for the data to be loaded from WMS server.

Overlay_World_Map_on_Sphere_07

Create a Sphere from Parametric Function

1.  Click on the yellow “I” icon Overlay_World_Map_on_Sphere_08 and select Insert on the fly-out context menu three times to insert three matrix objects before the map.

2.  With 1st object selected, click on the yellow icon and select Properties to bring up dialog. Under Options node, set Data Type drop-down option as Double(8).

3.  Click >> button in Matrix Properties dialog and repeat step 2 to set 2nd and 3rd matrix objects’ data types as double(8) as well.

4.  With 1st matrix object active, choose Matrix: Set Values… or press Ctrl+Q . Enter sin(y/180*pi) in Cell(i,j) = edit box

5.  Click >> button and enter cos(y/180pi)cos(x/180*pi) in Cell(i,j) = edit box. 

Overlay_World_Map_on_Sphere_09

 

 

 

 

 

 

 

 

6.  Click >> button and enter cos(y/180pi)sin(x/180*pi) in Cell(i,j) = edit box. 

7.  Choose the Plot->3D -> Parametric Surface  template. It will plot 1st matrix object as Z and set 2nd and 3rd matrix objects as X and Y automatically.

     

Colormap the Sphere with Map Data
  1. Double click on the plot to bring up Plot Details – Plot Properties dialog. Go to Fill tab and under Front Surface group check Fill piece by piece radio box. With By Points tab active, select RGB:  Mat(1): “wms.png”.

Overlay_World_Map_on_Sphere_13

  1. Go to Colormap/Contours tab and uncheck Enable Contours box to disable contours and then go to Mesh tab uncheck Enable box to disable mesh.

  2. To turn off Speed Mode is ON watermark on the plot, highlight Layer1 node on the left panel and go to Size/Speed tab on the right panel. Uncheck Matrix data, maximum points per dimension box under Speed Mode, Skip Points if needed group.

  3. Click OK button you will see the spherical world map is created.

Overlay_World_Map_on_Sphere_14

 

 

Overlay Locations as Scatter on the World Map

Convert Latitude and Longitude Data to XYZ Coordinates

To display the scatter plot on the XYZ cartesian coordinate, we will need to convert the latitude and longitude values into X, Y, Z coordinates. To do so, follow steps below:

  1. Activate Book1 and click Add New Columns button Overlay_World_Map_on_Sphere_15 three times to add 3 new columns.

  2. Set the long name of three columns as X Coordinate, Y Coordinate, Z Coordinate, respectively.

  3. Highlight column X Coordinateand right click to select Set Column Values… to bring up Set Values dialog. Input formula below:

cos(col("Latitude")/180*pi)*cos(col("Longitude")/180*pi)

 

Overlay_World_Map_on_Sphere_16

  1. Similarly, input formula cos(col(“Latitude”)/180pi)sin(col(“Longitude”)/180pi)  for column Y Coordinate and formula sin(col(“Latitude”)/180pi)  for column Z Coordinate, respectively.

  2. To make a 3D scatter plot, we will need to set the column designations of X Coordinate, Y Coordinate, Z Coordinate as XYZ. To do so, highlight these three columns and right click to select Set As: XYZ XYZ.

Overlay_World_Map_on_Sphere_17

Overlay the Scatter with Labels on the World Map

Now the scatter data is ready, we can add it to the world map plot. To do so, follow steps below:

1.Activate the Graph1 window, double click on the layer icon Overlay_World_Map_on_Sphere_18 to bring up Layer Contents dialog.

2.Select the drop-down option as Worksheets in Folder, highlight the Z Coordinate column and click the down arrow button in the middle to select 3D Scatter/Trajectory/Vector. Then click right arrow button to add it to right panel and click OK to apply settings.

Overlay_World_Map_on_Sphere_22

  1. Now we want to further customize the plot. Double click on the plot to bring up Plot Details – Plot Properties dialog. Expand the second plot node under Layer1 node on the left panel to highlight Original node, then go to Symbol tab on the right panel. Set Shape as Sphere and Size as 15.

Overlay_World_Map_on_Sphere_20

  1. Go to Drop Lines tab, uncheck Parallel to Z Axis box.

  2. Go to the Label tab and set the options as shown below:

Overlay_World_Map_on_Sphere_21

  1. Eventually we do not want all the planes, to do so highlight Layer1 node on the left panel. Go to Planes tab on the right panel, uncheck XY, YZ, ZX three checkboxes. Click OK button to apply all the settings.

  2. You can delete the color scale on the graph, resize the graph and rotate the sphere to a proper position similar as the one below:

Overlay_World_Map_on_Sphere_01a

 

 

 

One Comment on “Overlay Locations on a 3D Map”

Leave a Reply

Your email address will not be published. Required fields are marked *