Here is one way and I have tested this with some of my tables.  The Region
table I used is called Paste, and the address file is County_Addresses, you
will need to replace these with your specifics.  The unique ID field for the
Paste table is Buffer_Paste

The functions CentroidX and Y will give you locations for both the regions
and the addresses, PROVIDED the addresses are geocoded as point data, if
not, stop and do that.  The Distance function will give you distance from
the region centroid to the address points.  You can use Minimum aggregation
function to pull the address closet (lowest result, or Minimum, from the
Distance calculations) to the region centroid.  Read up on these funtions in
Help.

To make this work you need fields in both tables to hold the X,Y
coordinates, and the region table needs a unique ID field to group on,
Table>Maintence>Add.  What ever you name them they will be referenced in the
SQL- mine are x_coord and y_coord for both tables,  Update the new fields
Table>Update Column.  Have the new field (x_coord for example) in the pull
down list.  In the Value box, use the CentroidX for Longitude/Easting and
repeat using y_coord and CentroidY fro Lattitude/Northings, assign IDs to
the regions if needed.

In the SQL wizard-

Column section-
Paste.Buffer_Paste, County_Addresses.Property_Address,
Min(Distance(Paste.x_coord,Paste.y_coord,County_Addresses.x_coord,County_Add
resses.y_coord,"mi"))

>From Tables - Paste, County_Addresses

Where- County_Addresses.Obj Within Paste.Obj

Group By - Paste.Buffer_Paste

Into Table - What_ever_Table_name_you_like

The resulting table will yield the region ID characters, the address closest
to the centroid of the region, and the distance in miles, if you need
anymore data brought along, include the column names in the column section
of SQL).


Some notes -  for the coordinate updates to work properly, the objects in
the table must be uniform (all points or all regions), or the operation has
a hiccup at the first non object and you get an unable to fetch record
error.  To filter out, SQL each table and in the Where section put
Chr$(obj)="region" for the region table, and Chr$(obj)="Point" for the
address file.

Below is copied and pasted from MapBasic Window

Alter Table "County_Addresses" ( add x_coord Float,y_coord Float )
Interactive

Select * from County_Addresses where Str$(obj)="point" into Selection
Update Query1 Set y_coord = CentroidY(obj)
Update Query1 Set x_coord = Centroidx(obj)
Update Paste Set x_coord = Centroidx(obj)
Update Paste Set y_coord = Centroidy(obj)

Select Paste.Buffer_Paste, County_Addresses.Property_Address,
Min(Distance(Paste.x_coord,Paste.y_coord,County_Addresses.x_coord,County_Add
resses.y_coord,"mi")) from County_Addresses, Paste where
County_Addresses.Obj Within Paste.Obj group by Paste.Buffer_Paste into
Selection
Browse * From Selection

William "Woody" Woodruff
Zoning Administrator
Charter Township of Union, Isabella County, Michigan
-84.80947000 43.61095100
2010 S Lincoln Rd, Mt. Pleasant, MI  48858
(989) 772 4600 EXT 41
Visit our web site at http://www.geocities.com/ctuzoning/index.htm


-----Original Message-----
From: Apers Mathieu [mailto:[EMAIL PROTECTED]
Sent: April 05, 2004 22:07
To: Mapinfo help forum (E-mail)
Subject: MI-L Selecting record(s) from the centre of a polygon


Hi all

I am trying to load onto each polygon in a table the value of an address
from the centre of that polygon - i know how to make it pick up one address
from the address table below it, but i want it to choose the address closest
to the centre of the polygon.

does anyone know of an easy way to do this?

I don't use mapbasic so an SQL select command would be the easiest for me to
understand.

Cheers

Mathieu Apers
Mapping Co-ordinator

Letterbox Channel  |  NZPost Ltd




This email with any attachments is confidential and may be subject to legal
privilege.  If it is not intended for you please reply immediately, destroy
it and do not copy, disclose or use it in any way.

---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 11284



---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 11292

Reply via email to