Overlay Locations on a 3D Map

posted in: Apps, Graphing | 1

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.


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.


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.


2. 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.


3. 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.

4. 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.


Create a Sphere from Parametric Function

1. Click on the yellow “I” icon Overlay_World_Map_on_Sphere_08 and select Add on the fly-out context menu three times to add three matrix objects.

2. Click on the yellow icon Overlay_World_Map_on_Sphere_08 again and choose in the context menu to activate the 2nd matrix object.

3. Click on the yellow icon again and select Properties to bring up dialog. Under Options node, set Data Type drop-down option as Double(8).

4. Repeat step 2 and 3 from 3rd and 4th matrix objects to set their data types as double, too.

5. Activate the 2nd matrix object by clicking on the 2nd thumbnail on top of matrix window and right click on it to select Set Matrix Values… to bring up dialog. Input formula

cos(y/180*pi)*cos(x/180*pi) in Cell(i,j) edit box and click OK button to apply.



6. For 3rd and 4th matrix objects, input formula cos(y/180*pi)*sin(x/180*pi) and sin(y/180*pi) to set values respectively.

7. Activate the 4th matrix object and go to menu Plot: 3D Surface: Color Map Surface to create a surface plot.

8. Double click on the graph to bring up Plot Details – Plot Properties dialog. Check Parametric Surface box on Surface tab page and select Mat(2) as X MatrixMat(3) as Y Matrix.


9. Click OK button to apply the settings and click Rescale button Overlay_World_Map_on_Sphere_11 docked on the top right to rescale the plot to show the sphere.


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”.


2. 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.

3. 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.

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




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:



4. Similarly, input formula cos(col("Latitude")/180*pi)*sin(col("Longitude")/180*pi)  for column Y Coordinate and formula  sin(col("Latitude")/180*pi)  for column Z Coordinate, respectively.

5. 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 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.


3. 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 Ball and Size as 15.


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

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


6. 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.

7. 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:





One Response

  1. nurkanat

    very usefull! thanks a lot! i did the same for earthquakes? awesome!

Leave a Reply