Title: [Mapinfo-l] Create a point object at centroid
Dave,
 
You can use the SelectionInfo(SEL_INFO_TABLENAME) to find the nameof the base table that your selection has selected records from.
 
You can actually do this using just two statement:
 
Update Selection Set OBJ = Centroid(OBJ)
Commit Table SelectionInfo(SEL_INFO_TABLENAME)
 
This will replace the current object(s) on the records in selection with a point (here the centroid)
 
If you also need to update the columns with the X and Y, you should do this before the other:
Update Selection Set XCOORD = CentroidX(OBJ), YCOORD = CentroidY(OBJ)
Update Selection Set OBJ = Centroid(OBJ)
Commit Table SelectionInfo(SEL_INFO_TABLENAME)
 
But it is not necessary to update columns with coordinates just to alter the object.
 
Also be aware that this will actual replace the existing objects, and there is no easy way back here. So you might consider making a copy of the original table before updating the objects, or maybe insert the centroid into another table.
 
Peter Horsbøll Møller
GIS Developer
Geographical Information & IT
 
COWI A/S
Odensevej 95
5260 Odense S.
Denmark
 
Tel   + 45 6311 4900
Dir   +45 6311 4908
Mob +45 5156 1045
Fax  + 45 6311 4949
E-mail [EMAIL PROTECTED]


From: [EMAIL PROTECTED] on behalf of David Reid
Sent: Wed 16-Nov-05 07:40
To: MapInfo-L
Subject: [Mapinfo-l] Create a point object at centroid

Greetings List,

I'm trying to do a simple little routine here to mark the centroid of a
single section line (two node line) with a point object. I get to the point
of saving the active table then creating the point within it, but I don't
want to have to specify the table name (ie, I want this to work on any table
I have, all have the same two columns described below).



  Update Selection Set XCORD = CentroidX(Obj) 'Returns the xcoord of the
object
  Update Selection Set YCORD = CentroidY(Obj) 'Returns the yccord of the
object
  Delete Object From Selection 'Deletes only the graphic line object leaving
data

I presume that just as if you use the menu option to "Create Points", the
table must be saved first before you can insert an object at the centroid
from above. From here I'm a little stumped....

  Commit [currently_active_table] 'Save the table currently being edited
  Update [currently_active_table] 'Update currently active table
  Set obj = CreatePoint(xcord, ycord) 'Create a point object only for the
record updated previously



I may be going about this all wrong, or perhaps I will need to create a
temporary table from the selected object and work from it????

Would appreciate any help here.

Thanks,
Dave

--
Outgoing mail is certified Virus Free
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.13.2/170 - Release Date: 11/15/2005



_______________________________________________
Mapinfo-l mailing list
[email protected]
http://www.directionsmag.com/mailman/listinfo/mapinfo-l


_______________________________________________
Mapinfo-l mailing list
[email protected]
http://www.directionsmag.com/mailman/listinfo/mapinfo-l

Reply via email to