SpaTools: Import KML in AutoCAD
KML, or 'Keyhole Markup Language', is an XML based file format for modeling and storing geographic features such as points, lines, images, polygons, and models for display in Google Earth, Google Maps and other applications. KML uses a tag-based structure with nested elements and attributes and is based on the XML standard. KML files can be created using Google Earth user interface or using any simple text editor by writing XML tags, attributes and values in the form of raw KML. The compressed form of KML files is KMZ archive file having extension of KMZ.
KML/KMZ files are frequently shared over the internet via email to display the location, extent and orientation. Anyone can view the KML/KMZ files using Google Earth application.
It is often required to overlay the KML files in AutoCAD drawings for further cartographic activities.
Every feature in the KML file have a tag with ending tag of Placemark . Under Placemark tag, there are various tags which are used to store some specific properties. The most important tags which define the topology and geometry of the feature are Point, LineString , and Polygon with respective ending tags.
The spatial information is stored is always contained in tag Coordinates with an ending tag of Coordinates . The tag is child element of Point, LineString or Polygon tags. The spherical coordinates (Latitude, Longitude & Height) are in the form of comma delimited 3-tuples delimited with space.
For example, a KML file stores the coordinates of a Polygon as shown below:
The spherical coordinates (Latitude, Longitude and Height) of the geometric features in KML file are based on WGS 84 ellipsoid. It is always required to plot these coordinates on a projected coordinate system.
KMLIN is a tool developed to plot the geometric features (Points, Polylines and Polygons) in AutoCAD. The tool is included into SpaTools.DLL. It takes a KML file as input and plots all the features (points, polylines and polygons) along with names (as text objects) into AutoCAD drawing. It detects the UTM Zone along with hemisphere (Northern / Southern) and transform all the spherical coordinates into projected coordinates.
A KML file depicted below has four point features, four polyline features and five polygons.
The file can be imported and plotted in AutoCAD by a command KMLIN as shown below:
The DLL can be downloaded from here.
Note: This tool is further extendable to import the information from CDATA tags, customized construction of AutoCAD objects (such as Text heights, Polyline properties, Blocks for points etc) and transformation to different coordinate systems used all over the world. Your suggestions to improve and enhance this tool will be appreciated.
Thanks so much for this. This is an added knowledge to what I have known before.
ReplyDeletebro pls how did u get urs i cant download it, pls help a brother
DeleteWaooh!!!! I tested it and it worked as I expected...
ReplyDeleteThanks.
i could not download that url saying "This Path Doesn't Exist." how to download please
Deletecan any one suggest
Thanks so much for your contribution to knowledge!
ReplyDeleteWhile using i am having an issue like "Index was outside the bounds of the array".
ReplyDeleteCan you help me out from this...
Much Thanks....!
send the KML file to info@cadomation.com to check why there is issue.
DeleteIs there any blog that explains how to transform all the spherical coordinates into projected coordinates in AutoCAD.
Deletepls sir I can download it is there any way I can get it into my pc?
ReplyDelete