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
- Click on the Maps Online app icon on Apps Gallery window to launch the app.
- Set the options in the dialog as shown below. Click this button to bring up Load Into 、 Area options.
- Click this button again and go to Area menu and select 90ºN, 180ºW ~ 90ºS, 180ºE.
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
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.
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
- 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”.
- 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.
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.
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:
- Activate Book1 and click Add New Columns button three times to add 3 new columns.
Set the long name of three columns as X Coordinate, Y Coordinate, Z Coordinate, respectively.
Highlight column X Coordinate, and right click to select Set Column Values… to bring up Set Values dialog. Input formula below:
- 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.
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:
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.
- 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 、 Size as 15.
- Go to Drop Lines tab, uncheck Parallel to Z Axis box.
Go to the Label tab and set the options as shown below:
- 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.
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: