- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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];
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: exporting x
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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];
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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");