19 January 2011

Importing contours from a SHP File

I've previously covered using the MAP Query command to transform a drawing between coordinate systems however the same Query command can also be used to set the elevation properties of a set of contours that have been imported from a SHP file.
The process involves importing the SHP file data with the contour elevations being saved to MAP Object data and then running a MAP Query to Alter Properties in order to set the polyline elevations to the appropriate value stored in the object data field.
The complete process is shown in the video below:
For a full description of the steps, please read on...
Firstly, use Map Import to bring in the SHP file to a new drawing. After browsing to the required SHP file, in the Import Dialog, set the Object Data to create by clicking in the Data column and then clicking the … button.
In the Resultant Dialog, Change the option to Create object data and then press the Select Fields button.
The ELEVATION Input and Target fields should be ticked.
Click OK in each of the Dialogs to return to the main Import Dialog, and then click OK in this to bring in the contours to the drawing. These should now be polylines with the elevation as object data. Now you need to Use the Map Query function to set each polyline’s elevation to its object data. You need to save the drawing with the imported contours, close it and create a new blank drawing. Use MAP->Query->Define Query (or adequery at the command line) to start the Map Query Dialog.
Under Query Type, press the location button and set the boundary type to ALL.
Back in the main Define Query Dialog set the Query Mode to Draw.
In the Options Side of the Dialog, click the Drawings button then Attach and attach the Imported SHP file contours drawing created earlier (You may need to create a Drive Alias in the Dialog used to browse to and select the required dwg file if you can’t see the required Drive letter).
Click OK to go back to the Define Query Dialog, and this time on the options side click the Alter Properties button.
In the Set Properties Alterations Dialog, first select Elevation as the Property and then click the Expression button.
In the Property Alteration Expression Dialog, expand the Object Data until you see the elevation object data field and highlight this.
Click OK to go back to the Property Alterations Dialog and then Click Add to place the Elevation Alteration into the List.
Click OK to return to the Define Query Dialog and then press Execute Query to create a new set of contour polylines with the elevation taken from the Object Data of the originals.

To remove the Query link to the original imported SHP drawing file, use MAP->Drawings->Define/Modify Drawing Set and detach the Drawing File.
This will then treats the new polyline entities as newly created and you can Save this new drawing and use it as required.

1 comment:

Svante said...

Very handy method!