Global Mapper v25.0

comparing two layers

wmiswm
wmiswm Global Mapper UserTrusted User
edited May 2012 in Technical Support
I have two layers, say layer A and B.
Both layers A and B contain items (polyline) with the attribute called ST_CODE.
Each layer may have several lines having the same ST_CODE (different segments of the same road).
Can I compare the ST_CODE of layer A with that of layer B, and delete those items from layer B with the same value as layer A?
That is, I wish to delete those roads in layer B that are already on layer A, while retaining those absent in layer A.

Comments

  • global_mapper
    global_mapper Administrator
    edited April 2012
    You can use the Search->Find Duplicates menu command to find those features with duplicate ST_CODE values, then delete them if you want.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com
  • wmiswm
    wmiswm Global Mapper User Trusted User
    edited April 2012
    This will not work. Each road may have several segments, either joining or not joining. They will appear as items with the same ST_CODE in a single layer. Seach for duplicates will identify these road segments as duplicates.
  • global_mapper
    global_mapper Administrator
    edited April 2012
    Could you use the EDIT_VECTOR script command with DELETE_DUPLICATES=YES (see http://www.globalmapper.com/helpv13/ScriptReference.html#cmd_edit_vector) to find and eliminate the features that are exact duplicates? Or are there some differences between these features?

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com
  • wmiswm
    wmiswm Global Mapper User Trusted User
    edited May 2012
    The polylines are not the same, though they describe the same road. They are from different maps for different purposes.
  • global_mapper
    global_mapper Administrator
    edited May 2012
    How would you determine that they are duplicates if the shapes are now the same? Is there some other combination of attributes that would allow you to mark the features as duplicates in an automated way?

    One thing that might help is to split your features into layers by the ST_CODE attribute, then you could easily turn them on and off by that grouping. You can do that by right-clicking on the layer in the Control Center and selecting the split into layers by attribute values.

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com
  • wmiswm
    wmiswm Global Mapper User Trusted User
    edited May 2012
    How would you determine that they are duplicates if the shapes are now the same? --> if the ST_CODE of the item for layers A and B are the same, then they are duplicates on the two layers.

    Is there some other combination of attributes that would allow you to mark the features as duplicates in an automated way? --> this is the question that I am asking. Can I compare items of layer A with items of layer B (without inter-comparing items within the same layer)

    .
    One thing that might help is to split your features into layers by the ST_CODE attribute, then you could easily turn them on and off by that grouping. You can do that by right-clicking on the layer in the Control Center and selecting the split into layers by attribute values. --> I can split layer A and layer B into about 3000 layers, each layer having one road. What will then be the next step?
  • global_mapper
    global_mapper Administrator
    edited May 2012
    So to clarify, two items are duplicates if they have the same ST_CODE attribute but they are in different layers? Is there only one instance of each ST_CODE value in each layer then? If so wouldn't the normal duplicate finding work by finding duplicate ST_CODE values, or am I missing something? If there are multiple instances of the same ST_CODE in each layer, then that attribute alone isn't enough to determine a duplicate, but it sounds like the features aren't spatially identical either.

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com
  • wmiswm
    wmiswm Global Mapper User Trusted User
    edited May 2012
    Hi Mike, frankly, if you cannot understand what I am asking, then probably GM does not have this function. Anyway, for the benefit of GM development, I would explain in detail of what I am doing.

    I have two road maps, one comes from the Transport Department (layer/map A), and the other comes from the Lands Department (layer/map B). These maps are for different purposes.

    Map A is for driving navigation. Each of the line (i.e. each item) contains direction of drive, turn, speed, level, name, street code etc as attributes. One road can have several segments. For example, one road can have many entrances and exits, intersect by round-about etc. So, one road will have to be represented by several items in GM, each segment contains different driving information. However, one road is one road. All the segments of the same road will have the same name and street code. The term "street code" refers a unique identification number assigned to a road by the government, so that no single road will have the same street code (ST_CODE). All maps produced by the government, no matter from which department and for what purpose, will use the same street code for a given road. Since map A is for car navigation, it contains all roads for driving, and contains all driving information as attributes of the line. However, it does not contain any road which is not for driving purpose (pedestrian only roads). A point to note is that a road is represented by a polyline. The polyline is the middle of the driving lanes, not necessarily the geographic middle of a road. For example, a road can have road bank. In calculating the middle of the driving lane, the width of the road bank is excluded in the calculation.

    Map B comes from the Lands Department. The map produced by Lands Department is for survey purpose and production of printed maps. It contains all sorts of roads, no matter whether the road is for driving or for pedestrians. This map contains the geographic information all roads, but it does not contain any driving information as in map A. For the same reasons as map A, each road in map B may also be divided into several segments, and therefore may appears as several items in GM. Since map B is for survey and printing purpose, each road is represented a line of the geographic middle of the road. For example, if a road have road bank on one side of it, in calculating the mid-line of the road, the width of the road bank will also be taken into account.

    You can now see that though a polyline of map A and map B describe the same road, the polyline in map A is not exactly the same as that in map B. The only way to know whether a polyline in map A describe the same road as in map B is to read their street code (ST_CODE). If the ST_CODE is the same, then the two polylines describe the same road.

    I am in the process of production of an electronic map for both driving and walking. Obviously, I would have to use all the information of map A. The issue is with map B. If I include all the roads of map B into my map, then, all roads good for cars will have non-overlapping double entries. I have to use part of the information of map B, since only map B contains the pedestrian roads. What I wish to do is to delete away all the roads that have already been included in map A.

    As explained, I cannot simply use the "Search Duplicate" function of GM, since one single road in either map A or map B will have several segments and appear as several "duplicate" items in GM. My question is therefore how can I do this job in GM.

    By the way, is there any way in GM to export the index of polyline items? I can do this in say FME, but if GM can do it, I would prefer to use GM.
  • global_mapper
    global_mapper Administrator
    edited May 2012
    Ah now I see what you are after. You want to delete those roads in map B that have a ST_CODE that exists in map A. If a ST_CODE in map B does not exist in map A, then keep it. You are correct that there isn't any way to do this currently (other than using the SDK with a simple program, we can discuss that if you want), but I will add it to the todo list as something to add to the Find Duplicates function.

    As for exporting the index of polylines in a layer, you can right-click on a layer in the Control Center and select the CALC ATTR option, then create a new attribute based on the <Index in Layer> value. Then it will be exportable like any other attribute.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com
  • wmiswm
    wmiswm Global Mapper User Trusted User
    edited May 2012
    I cannot understand what you said. After creating an attribute base on the "Index in Layer", what to do next in order to obtain a csv file containing all the items?
  • wmiswm
    wmiswm Global Mapper User Trusted User
    edited May 2012
    by the way, what actually will happen if I "search duplicate", then choose "delete duplicate". Will there be one copy of the "duplicate" left behind?
  • wmiswm
    wmiswm Global Mapper User Trusted User
    edited May 2012
    I figured out a way to do this outside of GM.
    1. open layer A with GM
    2. delete all attributes except "ST_CODE"
    3. "Search Duplicate", then delete duplicate
    4. export vector, choose "TEXT" format. Close GM.
    5. rename the .xyz file to .txt
    6. open the .txt file with a third party text editor, sort the text and use "replace all" to remove all irrelevant information, retaining only the ST_CODE numerals, then save
    7. open the saved .txt file in Excel
    8. in the first row, add the header "ST_CODE" for column 1, and "DUPLICATE" for column 2
    9. fill column 2 value with the letter "Y", and save as .csv
    10. open layer B in GM
    11. "join table" of the saved .csv
    12. search for the attribute "DUPLICATE" with value "Y", select all, then delete

    This will delete all roads of map B that are already on map A.
  • wmiswm
    wmiswm Global Mapper User Trusted User
    edited May 2012
    ok, I find out an even more direct way to do the job. Not being able to edit the above post after the 5 minute time limit, I change the procedure as below:
    1. open layer A with GM.
    2. delete all attributes except "ST_CODE".
    3. "Search Duplicate", then "Delete Duplicate".
    4. "Search" for all items, "Select All", right click, "copy the selected result to clipboard as text". Close all overlays.
    5. open Notepad, paste, save as .txt, then close Notepad.
    6. rename the .txt to .csv, then open with Excel.
    7. delete all the irrelevant columns, retaining the "ST_CODE" column only.
    8. add the header "DUPLICATE" for column 2.
    9. fill column 2 value with the letter "Y", and save as .csv.
    10. open layer B in GM.
    11. "join table" of the saved .csv of step 9.
    12. search for the attribute "DUPLICATE" with value "Y", select all, then delete.

    This will delete all roads of map B that are already on map A. Open map A again in GM to obtain a complete road map.
  • global_mapper
    global_mapper Administrator
    edited May 2012
    Ah that's brilliant! I hadn't thought of using the JOIN functionality to make this work.

    It sounds like you figured the earlier questions out as well as part of your solution.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com
  • wmiswm
    wmiswm Global Mapper User Trusted User
    edited May 2012
    I actually have one more problem with this method, but might not be solvable by any automatic means.

    Some roads are difficult; The first part of the road is for cars, and the second part of the same road extends to pedestrians only section. This means, map A will contain the first part of the road, and map B contains the whole length of the road, inclusive of the pedestrian only section. If the road is selected by map A to be deleted in map B, then the whole road, including the pedestrian part will be lost.

    The ideal solution will be to only delete the cars segment in map B, but unfortunately, map B is not constructed for this purpose. There is no attribute in map B to specify whether the road is for car or pedestrian.