cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP Security Notice: CVE-2026-109618 and CVE-2026-109619

    JMP promptly initiated a review of its products, services, and relevant infrastructure for exposure to CVE-2026-109618 and CVE-2026-109619.

    Our assessment of JMP products has not identified exposure to these vulnerabilities. Where remediation was required within supporting environments, appropriate security updates and controls have been applied and validated.

    We have identified no evidence of successful exploitation or unauthorized access to JMP systems or customer information associated with these vulnerabilities.

    JMP continues to monitor the issue and relevant vendor guidance. No action is required by JMP customers at this time.

  • Don’t miss your chance to experience Discovery Summit Europe at our best available rate! Early bird registration through 31 Oct.
  • Graph Builder Toolbar streamlines interactive graphing. Creates shortcuts on Report and GraphBuilder Helpers toolbars. Download and install the extension.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
fever
Level III

exporting x&y values (coordinates) from graph builder once jmp automatically finds centroid points for a polygon

How can I export x&y coordinates for the centroid points jmp automatically finds within my polygons (n=2455) on a graph builder map? I would like to make lat/long columns for these points in order to make contour and heat maps, but all I have currently are the many vertices coordinates for the mapshape polygons. These are municipalities in Mexico, so there is no determined point location (city) for the ad on to find (if it could), but the centroid points jmp finds is perfect for me. I don't know how to write script.

1 ACCEPTED SOLUTION

Accepted Solutions
johnmoore
Level IV

Re: exporting x&y values (coordinates) from graph builder once jmp automatically finds centroid points for a polygon

Fever,

 

Here is a quick script I wrote to find the centroids based on the XY shape file.  Please try and let me know how it works for you.

dt = Current Data Table();
shapeList = Associative Array( Column( dt, "Shape ID" ) << get values ) << get keys;
dtCentroids = New Table("Centroids", New Column( "Shape ID", numeric, continuous ),
	New Column( "X", numeric continuous ),
	New Column( "Y", numeric, continuous )
);
For( i = 1, i <= N Items( shapeList ), i++,
	targetRows = dt << get rows where( Column( dt, "Shape ID" )[Row()] == shapeList[i] );
	centroid = Polygon Centroid( Column( dt, "X" )[targetRows], Column( dt, "Y" )[targetRows] );
	dtCentroids << add rows( 1, "at end" );
	Column( dtCentroids, "Shape ID" )[i] = i;
	Column( dtCentroids, "X" )[i] = centroid[1];
	Column( dtCentroids, "Y" )[i] = centroid[2];
);

View solution in original post

7 REPLIES 7
fever
Level III

Re: exporting x&y values (coordinates) from graph builder once jmp automatically finds centroid points for a polygon

Using the crosshair tool manually on all the points and recording these isn't practical for me. Thanks

johnmoore
Level IV

Re: exporting x&y values (coordinates) from graph builder once jmp automatically finds centroid points for a polygon

Fever,

 

What I did was take the mean X and Y values (using table>summary) for each of my shapes in the XY polygon file.  This is not really a centriod, but it worked well enough for my purposes.

 

John


@fever wrote:

Using the crosshair tool manually on all the points and recording these isn't practical for me. Thanks


 

fever
Level III

Re: exporting x

Thanks, yes that works w most of the shapes. Good enough from a distance. Thought maybe there were a simple way to access the automatically generated centroid data
johnmoore
Level IV

Re: exporting x&y values (coordinates) from graph builder once jmp automatically finds centroid points for a polygon

Fever,

 

Here is a quick script I wrote to find the centroids based on the XY shape file.  Please try and let me know how it works for you.

dt = Current Data Table();
shapeList = Associative Array( Column( dt, "Shape ID" ) << get values ) << get keys;
dtCentroids = New Table("Centroids", New Column( "Shape ID", numeric, continuous ),
	New Column( "X", numeric continuous ),
	New Column( "Y", numeric, continuous )
);
For( i = 1, i <= N Items( shapeList ), i++,
	targetRows = dt << get rows where( Column( dt, "Shape ID" )[Row()] == shapeList[i] );
	centroid = Polygon Centroid( Column( dt, "X" )[targetRows], Column( dt, "Y" )[targetRows] );
	dtCentroids << add rows( 1, "at end" );
	Column( dtCentroids, "Shape ID" )[i] = i;
	Column( dtCentroids, "X" )[i] = centroid[1];
	Column( dtCentroids, "Y" )[i] = centroid[2];
);
fever
Level III

Re: exporting x&y values (coordinates) from graph builder once jmp automatically finds centroid points for a polygon

That worked after chopping up the file 5 ways (was 87k rows). Program kept freezing...But it looks good. Thanks!

johnmoore
Level IV

Re: exporting x&y values (coordinates) from graph builder once jmp automatically finds centroid points for a polygon

Glad to hear it worked.  Happy JMPing!

ian_jmp
Level X

Re: exporting x&y values (coordinates) from graph builder once jmp automatically finds centroid points for a polygon

FWIW, here is an alternative that uses plotted data directly:

NamesDefaultToHere(1);

// Table
dt = New Table( "Some States",
					New Column(
						"State",
						Character,
						Nominal,
						Set Values(
							{"Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado",
							"Connecticut", "Delaware", "Florida", "Georgia", "Hawaii"}
						)
					)
				);

// Map
gb = dt << Graph Builder(
						Show Control Panel( 0 ),
						Variables( Shape( :State ) ),
						Elements( Points( Legend( 5 ) ) )
					);

// Get x and y values from marker seg
gbRep = Report(gb);
frame = gbRep[FrameBox(1)];
mySeg = (frame << Find Seg( Marker Seg( 1 ) ));
xVals = mySeg << Get X Values;
yVals = mySeg << Get Y Values;
dt2 = asTable(xVals||yVals, << columnNames({"X", "Y"}));
dt2 << setName("Map Shape Centroids");

Recommended Articles