Shape Files

I want to take a look at how shape files are organised and how you can create your own custom shapes.  I’ll also take a look at an add-in that will help you digitize your shapes.  But first I’ll give a short overview of the use of shape files within JMP.

For a while now JMP has supported the use of shape files.  Included in JMP are some standard map shapes for use with geographic data.  One of the great features of JMP is that it automatically recognises shape names.  Here is a simple example.

I create a table containing a few UK county names and associate some numeric data with them (it could represent house prices, crime rates, etc):

simple-counties

Next I open graph builder and assign County and Value to the Map Shape and Color Value roles respectively:

In this trivial example I’ve only included a few of the counties for the whole of the UK.  To put these into context I can show the missing shapes:

This is great if you have geographic data.  But you can also create your own shape files, below for example, is the floor plan for a squash court:

squashcourt

So how do you create your own custom shapes?

Shapes are defined in two tables – one containing the shape names and the other containing the x-y coordinates.  To illustrate this I’ll create the tables containing two simple shapes, a square and a triangle.

The “names” table will look like this:

demo-name-1

The second column contains the name that I will use to identify the shape.  The first column contains a unique identifier that is used to cross reference the “xy” table. These identifiers should be numeric and in ascending order.  My “xy” table looks like this:

demo-data

The first 4 rows give the coordinates for my square shape (with a shape ID of 1) and the next 3 rows give the coordinates for my triangle shape (shape ID of 2).  The Part ID column is required but I won’t be using it ( each part is made up of one or more shapes).

Both of these tables need to be saved.  The first table should take the name xxxx-Name.jmp and the second xxxx-XY.jmp.  For ‘xxxx’ use whatever is descriptive, for example ‘squashcourt’ or ‘ukmap’.  In my example is is simply ‘Demo’.

Place these files in the right location and you are done.  If I have some demo data that contains a column with the the names Square and Triangle then JMP will automatically pick up my shape coordinates when I assign that column to the map shape role within Graph Builder.

On Windows, JMP installs built-in shape files in the following location:

C:\Program Files\SAS\JMP\<Version Number>\Maps

This is where I place my shape files, although in the corporate world you are unlikely to have permission to do that.  The recommended location for custom map files is:

C:\Users\<user name>\AppData\Local\SAS\JMP\Maps

There is another way – simple place the files in the same folder as your data table and take advantage of some special column properties.  I’ll take a closer look at how this is done:

First I need a data table in addition to my shape tables.  Here is a trivial example again:

demo-data

Using column properties I can tell graph builder how to resolve the shape information contained in the MyShape column.  I do this by using the Map Role property:

map-role-1

The property tells JMP that the values inthe MyShape column of my data table are identified by the Name column in the Demo-Name table.

Logically sufficient information has now been provided but JMP won’t be happy unless the  shape definition column is also identified explicitly in the xxxx-Name table.  So the Map Role property also needs to be assigned in this table:

map-role-2

Note that the assignment in the data table was “shape name use” whereas here it is “shape name definition”.

Now I’m good to go.  Here is my demo data in Graph Builder:

shapes

Defining the coordinates yourself, by hand or through the use of a formula is the most precise method of ensuring the correct geometry of the shapes, but in some instances shapes are irregular or the coordinates are not precisely known.

Another method of creating the shape “xy” data is by setting a background image and digitizing the coordinates.  This can be done by writing a script.  Fortunately this script has already been written – there is an add-in custom map creator on the JMP file exchange that will do this for you.  The add-in is well documented, but I still find it a little fiddle to you, so here is an 6 minute video illustrating how it works:

 

4 thoughts on “Shape Files”

  1. Hi, How you display the original drawing onto the traced geometry? For instance, I have this plant layout that I completely digitized and I can display all the data but I cannot seem to figure out how to display the plant image. Can you help? Thanks!!!

    1. Hi Tomas

      You should be able to display the original plant image as a background image. You might need to tweak the scale of the axes to get the actual map shapes to align correctly with it.

      Dave

Leave a Reply to Scott Cancel reply

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