Our World Statistics Day conversations have been a great reminder of how much statistics can inform our lives. Do you have an example of how statistics has made a difference in your life? Share your story with the Community!
Choose Language Hide Translation Bar
Staff
Creating a space-filling design for a map shape

One of my favorite new features in JMP 11 design of experiments is the Fast Flexible Filling (FFF) design in the Space Filling Design platform. When the JMP 11 Previews were released, Brad Jones showed an example of using FFF designs to place air quality monitors over the state of North Carolina. This blog post will demonstrate how to create a FFF design for a map using the state of Georgia.

In order to create a FFF design for a map shape, you need an XY-file with the latitude and longitude of the map boundaries (see Create Maps from the Essential Graphing book in the Help menu or online documentation for more details).

Get the map shape coordinates

I will assume you don’t have an XY-file of Georgia at your disposal. Go into the Maps directory (you can likely find it on Windows: C:/Program Files/SAS/JMP/11/Maps or Macintosh: /Library/Application Support/JMP/11/Maps) and open US-State-XY.jmp and US-State-Name.jmp. Notice from the State names file that Shape ID 11 corresponds to Georgia. Create a new data table using US-State-XY.jmp with the X and Y columns for the rows corresponding to Georgia. You can get the coordinates in a form usable by the Space Filling Design Platform using a simple script:

`dt = current data table();`

mymap = dt << get as matrix({X,Y});

xx = mymap[0,1];

yy = mymap[0,2];

show(min(xx), max(xx));

show(min(yy), max(yy));

show(xx,yy);

The result in the log for show(xx,yy) is the piece you need, and the minimum and maximum for latitude and longitude will be useful in the next step.

Setup for a FFF Design with disallowed combinations

We’re now ready to open up the Space Filling Design platform. Note that I renamed X1 and X2 longitude and latitude. Based on the minimum and maximum values of the map shape, I chose longitude to vary from -86 to -80, and latitude from 30 to 36. Make sure your ranges define a box that contains the map, and you should generally be OK. You will want to make sure you don’t define too big of a range that your map shape only makes up a small fraction of it. My factor table appears in the figure below.

You now have to declare that points should only occur within the map shape. The map shape is a polygon defined by the coordinates in the step above, so the JSL function “In Polygon” can specify the points need to occur within the map shape through disallowed combinations. Under the red triangle menu for Space Filling Design, select Disallowed Combinations.

JMP now supplies an edit box where you can paste in an expression that rules out infeasible input variable combinations. This expression should return a nonzero value for infeasible values. The Disallowed Combinations dialog is the same as that used in the Custom Designer. One way to do this is to create a Boolean expression that will evaluate to true or false. For example, if you have factors X1 and X2 that range from -1 to 1 and want points to occur within the unit circle, you would specify that disallowed combinations are X1^2 + X2^2 > 1. That is, disallow any points that fall outside of the unit circle. For this example, we need an expression that evaluates if a point falls outside of the map shape.

You need the vectors for the map shape, which you can get from show(xx,yy) above, and !In Polygon(longitude,latitude,xx,yy). Note the “!” in front of “!In Polygon”, since you want to disallow any points outside of the map shape. In this case, the script to copy into the window for disallowed combinations looks like:

`xx = [-83.108535, -83.3386899940506, -83.034712, -82.876864, -82.556835, -82.32448, -82.186154, -81.926336, -81.939737, -81.743835, -81.492253, -81.41866, -81.186829, -81.117234, -80.885517, -80.862814, -81.203572, -81.133493, -81.260076, -81.177254, -81.2884027924215, -81.493651, -81.444124, -81.949787, -82.043795, -82.036825, -82.165192, -82.214839, -84.864693, -85.002368, -85.107516, -85.041305, -85.140731, -85.061144, -84.890894303099, -85.007103, -84.96303, -85.1844, -85.605165, -84.321869];`

yy = [35.000771, 34.6820015115479, 34.483495, 34.475303, 33.945353, 33.820033, 33.62088, 33.462937, 33.344941, 33.14145, 33.009342, 32.629392, 32.464086, 32.117605, 32.0346, 31.969346, 31.719448, 31.623348, 31.54828, 31.517074, 31.211065104271, 30.977528, 30.709714, 30.827493, 30.729641, 30.377884, 30.358035, 30.568591, 30.711542, 31.000682, 31.186451, 31.540987, 31.857461, 32.134065, 32.2615038439169, 32.328362, 32.424244, 32.861317, 34.984678, 34.988408];

!In Polygon(longitude,latitude,xx,yy)

Click OK and Continue, and we’re ready to create the design. You’ll notice that because there are disallowed combinations, Fast Flexible Filling is the only choice available.

Create the Design

Change the number of runs to 100 to better visualize the result, and click the “Fast Flexible Filling” button to create the design.

The design will be displayed, and the Make Table button will create a data table containing the design. You can now take a look at the design through Graph Builder. Using the Background Map option, you should get something similar to the figure below.

The JSL to recreate this is:

Graph Builder(

Show Control Panel( 0 ),

Variables( X( :longitude ), Y( :latitude ) ),

Elements( Points( X, Y, Legend( 1 ), Jitter( 1 ) ) ),

SendToReport(

Dispatch(

{},

"longitude",

ScaleBox,

{Scale( "Geodesic US" ), Format( "Latitude DDD", 12, 0 ),

Min( -86.66255 ), Max( -79.83745 ), Inc( 1 ),

Minor Ticks( 0 )}

),

Dispatch(

{},

"latitude",

ScaleBox,

{Scale( "Geodesic US" ), Format( "Longitude DDD", 12, 0 ),

Min( 29.9 ), Max( 35.6 ), Inc( 1 ),

Minor Ticks( 0 )}

),

Dispatch(

{},

"Graph Builder",

FrameBox,

{Background Map( Boundaries( "US States" ) ), Grid Line Order( 2 ),

Reference Line Order( 3 )}

)

)

);

Final Thoughts

If you’re dealing with maps that come in separate parts (such as states that have multiple Part ID numbers), I would recommend creating FFF designs for each piece individually. Over a map, a FFF design is different than taking a simple random sample of points over the map shape. A FFF design is intended to make a more even spread of the design points, making for better coverage over the map.

Article Labels

There are no labels assigned to this post.

Article Tags