Stefan Donath wrote:

> I have a layer with cities. Each cities may consist of several pieces. I 
> need to group this pieces so that I will have one piece per city. The 
> problem is: the only column to group the layer is City_Name. But there 
> are cities, that have equal names but don't belong together. I was 
> thinking about grouping only those pieces that intersects AND do have 
> equal names.


You simply don't have enough data to complete your task, but assuming your
"pieces" are polygons, you can get a long way towards your goal with a few
simple steps.    

If you have a lot of cities with multiple separate parts, the manual review
phase below may be cumbersome. You may want to make a Voronoi diagram of
each polygon centroid as an intermediate step: Two "pieces" that are close
neighbors (but fdon't border each other) and have the same name probably
represent the same city.  But in the end, there's no escaping manual review.

Before going through all the steps below, perhaps you have boundaries for
larger geographic areas (such as Bundesländer) somewhere.  If so, you can
add those larger areas' names to the pieces table using "Table->Update
Column".    


Hope this helps
Spencer

Assume your "pieces" are like this:

 ___ ___
| A | A |
|___|___|___    ___ ___ ___    
| A | B | B |  | A | B | A |
|___|___|___|  |___|___|___|

1. Create a new empty table with a "City_Name" column. 
2. Put the table with the "pieces" in a map window with the new table.
   The "pieces" table should be the top layer and the new table should be 
   the bottom layer.   The new table should be the editable layer.
3. Use "Query -> Select all" to select all of the "pieces".
4. Use "Table->Combine Objects Using Column" to combine the "pieces" by
   city_name, storing the combined objects in the new, empty table.  
   Make sure that city_names from the pieces are stored in the city_name
   field of the new table.
5. When this is complete, you will have one object per distinct city_name. 
   MapInfo also finish with the new objects selected rather than the 
   "pieces". (a lower case letter labels a separate part of an individual 
   Object):

 ___ ___
|       |
| A  ___|___   ___ ___ ___    
|   |   B   | | a | b | a |
|___|_______| |___|___|___|

6. Now use "Objects ->Disaggregate..." to explode multi-part objects.  
   This will separate all of the cities with the same name from each other. 

 _______
|       |
| A  ___|___   ___ ___ ___    
|   |   B   | | A | B | A |
|___|_______| |___|___|___|


Now, here's why this isn't enough:  You may have cities that have multiple
separate "parts" (think of how the Swiss canton of Schaffhausen is in three
separate pieces).  In our little diagram, perhaps the middle "A" is part of
the same city as the leftmost "A".   Since you say you don't have any more
information than city_name, you will need to manually review these.

1. Use Query->SQL Select to select city_name,count(*) from new_city group by
city_name.  
2. Use Query->SQL select to select city_name and count (which will appear as
COL2) from the selection table created by the last step, where COL2>1,
ordering by COL2.   This gives you a list of all duplicated city names.
Print this out or save to a permanent table.
3. Add a "City_ID" column to your new table.   Use "Table=>Update column" to

initialize the CITY_ID column with ROWID. 
 _______
|  1-A  |
|    ___|___   ___ ___ ___    
|   |  2-B  | |3-A|4-B|5-A|
|___|_______| |___|___|___|

4. Go through each name in the list of duplicated city names and look at
each polygon associated with the name.  If two polygons represent the same
city, copy the CITY_ID from one part and paste it into the CITY_ID of the
other.
 _______
|  1-A  |
|    ___|___   ___ ___ ___    
|   |  2-B  | |1-A|4-B|5-A|
|___|_______| |___|___|___|

5. When you're finished, you can use "Table->Combine Objects Using Column" 
on CITY_ID instead of CITY_NAME to get your final set of city polygons.







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

Reply via email to