Adding Maps to Graphs with Built-In and Imported Shapefiles

Introduction

Origin has had support for adding maps to graphs for many versions via the Google Maps App. We’ve also supported using shapefiles in older versions of Origin, though the process was somewhat difficult. With Origin 2021b, support for using shapefiles has been made remarkably easy.

For those who are unfamiliar with shapefiles, they contain data about geographic or governmental boundaries. The data can be used to create map overlays on graphs.* All the graphs below have shapefile-based maps added.

Origin 2021b’s shapefile support comes from two sources: built-in shapefiles and imported shapefiles. As you will see, built-in shapefiles are accessible from the Insert menu while the Shapefile Data Connector can import external shapefiles (those acquired by the user) from Data: Connect to File: Shapefile menu.

In this blog post, I’ll show you both methods for adding maps to a series of graphs.

If you’d like to try for yourself, please download the companion files.

* Technically, the overlay is a line plot of the shapefile data.

A Caveat

Before I begin, I have an important caveat about adding shapefile-based maps to Origin graphs. The layer axes must be a longitude/latitude coordinate system based on -180 to 180 longitudinal degrees, not 0 to 360 degrees. For example, this won’t work:

But this will (observe the differences):

Also if you use latitude as X and longitude as Y, even if you exchanged X-Y axes to make the graph look like longitude X and latitude Y, the Insert Map will not work.

With that caveat out of the way, we can move on.

Built-In Shapefiles

As I stated in the introduction, Origin now ships with a set of built in shapefile maps which are available for use from the Insert menu when a graph with coordinate system axes is active. The shapefile maps available depend on the coordinates of the graph. Different coordinates create different Insert menu entries.

World Level Coordinates

When the graph coordinates are at or near the world level, then World Map is in the menu.

China National Level Coordinates

When the graph coordinates are at or near those of China, then Map of China and World Map are in the menu.

Continental US Level Coordinates

When the graph coordinates are at or near those of the Continental US, then Continental USA Map and World Map are in the menu.

Click the shape line to customize color, width, etc. of the line.

After inserting map this way, a Map Data folder is created in Project Explorer with data.

Importing Shapefiles

User-supplied shapefiles can be imported for use on maps using the Shapefile Data Connector. The easiest way to import a shapefile is to drag and drop the *.SHP file into the Origin workspace. Or with workbook window active, choose Data: Connect to File: Shapefile menu.

Then, to add the shapefile to a coordinate-based graph, simply drag and drop the shapefile data Y column onto the graph. Or select the longtitude X and Latitude Y columns and choose Copy for Plot button on mini toolbar. Then go to the corresponding graph, Ctrl+V to paste.

Click on the illustration below to watch an animated GIF of how to both import and add a shapefile to a graph. Also observe that I take a moment to use the Mini Toolbar to customize the shapefile boundaries on the graph!

As you can see importing a shapefile and adding it as a map to a graph is very simple.

Conclusion

As you can see, using shapefiles to and map boundaries in Origin 2021b has become super-easy. Thank you for taking the time to read this post.

About Chris Drozdowski

Chris Drozdowski is a Product Support Engineer at OriginLab. He loves to talk to customers and educate them. He particularly relishes diagnosing and solving difficult, edge-case issues. As well, he contributes code to help solve problems or enhance user experience. In his down time at work, he likes to research and write about esoteric product features. Outside of work, he enjoys spending time with his family, having fun with C++, working on his aquarium, and exploring craft beers.

View all posts by Chris Drozdowski →

Leave a Reply

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