Choose Language Hide Translation Bar
Level III

How to select data that falls within a given boundary on map?



I have a large on-road GPS dataset. How can I select the data that fall within a give boundary? (see the attachment, I imported the boundary using ESRI to JMP add-in)? I know I can do it manually with the Lasso but was wondering if there is an easier way.


Super User

Re: How to select data that falls within a given boundary on map?


Assuming your data files has latitude and longitude and your boundary is definfed by a sequence of latitude and longitude, there is a function that can be useful called InPolygon(). If your data file has numerous points, the brute force method shown in the script below is likely not efficient. 

Here is the script. The picture is shown below and the log output shows that points 2 and 3 are within the area.

Names Default To Here( 1 );

xpt = [11 44 75];
ypt = [75 40 50];

New Window( "Example",
	Graph Box(
		Fill Color( "red" );
		Polygon( [10 30 90], [88 22 44] );
		Marker( Marker State( 3 ), xpt, ypt ) 
For(i=1, i<=ncol(xpt), i++,
 if(InPolygon(xpt[1,i], ypt[1,i], [10 30 90], [88 22 44]), Insert into (res,xpt[1,i]*[1 0] + ypt[1,i]*[0 1] ) );



The Log shows res = {[44 40], [75 50]};


You might be able to create a Map file where selection by named area might be easier. Others might have more efficient methods.


If you have a large file, I might define a rectangle that bounds your boundary to quickly screen points obviously not in your boundary area.


Wll be interesting to see other suggested methods.


Article Labels

    There are no labels assigned to this post.