Q&A - Question

Converting KML to SHP

Question
PetH asked on December 08, 2016, keyword: Developer Kernel
Hi im trying to convert from kml tp shape with this code:

TGIS_LayerKML kml = new TGIS_LayerKML();
            kml.Path = inputFile;
            kml.Open();

            TGIS_LayerSHP shp = new TGIS_LayerSHP();
            shp.Path = outputFile;
            

            foreach (TGIS_FieldInfo fi in kml.Fields)
            {
                shp.AddField(fi.Name, fi.FieldType, fi.Width, fi.Decimal);
              
            }

            foreach (TGIS_Shape sh in kml.Items)
            {
                TGIS_Shape newShape = shp.AddShape(sh);
                foreach (TGIS_FieldInfo fi in kml.Fields)
                {
                    newShape.SetField(fi.Name, sh.GetField(fi.Name));
                }
            }


            shp.SaveAll();

And it works but when i try to import the shape file in my gis software i get the message "coordinate system not defined falling back to WGS84" how do i define the coordinate system to WGS84 ?
Answers
Artur Redzko (TatukGIS) replied December 08, 2016
You can try to set :

shp.CS = kml.CS

before adding shapes. But easier would be using the ImportLayer method that does everything for you.
If you would like to answer the question please Sign In.
*
*
Please review our recent Privacy Policy.
If you have any questions or requests, please contact us.
Rules
The Questions and Answers (Q & A) is intended to provide a means of communication between TatukGIS customers.
 
  1. Licensed users (with active maintenance play) of TatukGIS products may contribute to the Q & A content. Read-only access is available to anyone.
  2. Keep the content positive and professional.
  3. Be courteous to others by posting information when a question or issue asked on the Q & A is answered or resolved by other means (such as with help from TatukGIS technical support). Offer others at least a hint how the posted question was answered or the issue was resolved.
  4. The Q & A is not a replacement for TatukGIS technical support. TatukGIS team may or may not regularly follow or contribute content.