I imported polylines and annotations from DGN file. Polylines are pipelines. Annotation layer contains pipe diameters. There is no common ID's. The goal is to assign diameters from annotation to nearest pipe. Anybody knows how to do that?
Your best bet to solve this will be to use some version of a spatial join.
There are a couple of ways to make it work, and the best method will depend on your existing data. In both cases, the lines need to have a unique ID. This will enable joining of annotation attributes back to line attributes after spatial join is completed.
- Spatial Join from Lines to Annotation: Perform a spatial join operation from the lines to the annotation layer. This should add the attributes of the lines to the closest annotation. Note, this will only work if you have lines that are relatively separated and don't get close to overlapping annotation. If lines are too close together, and thus the annotation is close, it may be have the attributes of the wrong line joined to it.
- Spatial join from midpoint of line to annotation: Generate a point layer with the midpoints of the lines in question and their attributes. Do spatial join to annotation using this point layer. This will reduce the likelihood of annotation being assigned incorrect line attributes because one end of the line is too close to the annotation of another line.
The Spatial Join using the midpoint will work best if the annotation is located near the midpoint of the line. This is a common labeling area from CAD systems, so is likely to work. Another common label point is to the midpoint of the first segment of the line. This is something else that can be pulled out with a bit of python wizardry on the line.
As with anything, your mileage may vary. There will need to be an error checking process, especially in areas with a large concentration of lines, like through pump stations or at congested intersections. In general though, this method should give you pretty solid results. This should be a pretty easy operation that may be performed using any of the common GIS packages out there, so no need to specify commands, etc.