ThinkGeo.com    |     Documentation    |     Premium Support

Merge shape file

hello all,


i'd like to create a new shp file and merge two different shape file. one is point shape (point.shp), the other is line shape (road.shp).


first, i get the center coordinate form each line.


second, i want to create a new shp file of point shape and add all coordinate and column of roadid.


third,  add point.shp data to new shp file


the follows code can't run, i don't know how to modify it.


shapeCollect.Add(NointerList(i), New MultilineShape(features.Item(i).GetShape()))


i attach my code as follows.


on the other question...


if i want to add new coordinate in exist shp file, how can i do?


(if i want to add new coordinates and data in point.shp)


 



1596-fix.txt (6.19 KB)

Carol, 
  
 If you want to add center coordinate of line to a point.shp with roadid, the point.shp must already has roadid column.  
 And if you want to get center coordinate of each line, you can call lineShape.GetCenterPoint(), you don’t need calculate by yourself. 
  
 And you said the code can’t run, what’s that mean? Is there any exception throw? Can you tell me what message it throw? 
  
 I don’t have point.shp and road.shp, so I can’t recreate your problem. Please give me more information to help solve problem. 
  
 Thanks 
 James 


Thanks for your help, James 
  
 the follows code can’t run, it shows errow message: 
  
 it can’t change ObjectType of ‘ThinkGeo.MapSuite.Core.MultilineShape’ to ObjectType of ‘System.Collections.Generic.IEnumerable`1[ThinkGeo.MapSuite.Core.LineShape]’。 
  
         Dim features As New Collection(Of Feature) 
         For i As Integer = 0 To NointerList.Count - 1 
             features = r_originalShapeFileFeatureLayer.QueryTools.GetFeaturesByColumnValue(“roadid”, NointerList(i)) 
         Next 
  
         Dim shapeCollect As New Dictionary(Of String, MultilineShape) 
         For i As Integer = 0 To features.Count - 1 
             shapeCollect.Add(NointerList(i), New MultilineShape(features.Item(i).GetShape() 
         Next

Carol, 



The exception message is obviously, when you new a MultilineShape, you need input a 'System.Collections.Generic.IEnumerable`1[ThinkGeo.MapSuite.Core.LineShape]', but you input a 'ThinkGeo.MapSuite.Core.MultilineShape' because the result of features.Item(i).GetShape() is a MultilineShape. 



If you want to solve this problem, you have two ways: 

1, input a collection which contains lineShapes not multilineShape, 

2, use another overload constructor, you can input well known text or well know binary. 



Thanks 

James