1

I need to read LAS file using C# and then convert it to xml using C# for my project. Any help would be appreciated.

I need to read the specific headers and Data under them. The headers basically start with ~ in the LAS file. I have worked on creating an XML using C#. But having problem in reading the LAS file using C#. I have tried using libLAS libraries available on net, but getting errors.

@17-06-2010

I am using the libLAS library into my project to read a LAS file and I am getting this error

(Unable to load DLL 'liblas1.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)).  Any help???
emartel
  • 7,500
  • 1
  • 28
  • 56
Ningraj
  • 21
  • 1
  • 3
  • 7
    And what exactly is a LAS file? – Henk Holterman Jun 16 '11 at 13:07
  • its all ball-bearings these days, Ningraj – heisenberg Jun 16 '11 at 13:09
  • 1. Read your file. 2. Parse it. 3. Transform it to XML. Any questions left? – 0x434D53 Jun 16 '11 at 14:12
  • I need to read the specific headers and Data under them. The headers basically start with ~ in the LAS file. I have worked on creating an XML using C#. But having problem in reading the LAS file using C#. I have tried using libLAS libraries available on net, but getting errors. Any Help?? – Ningraj Jun 16 '11 at 14:35
  • 1
    @Henk LAS File Format info can be found here : http://www.cwls.org/docs/LAS12_Standards.txt . @Ningraj If you are getting crashes, it may be worth posting what they are and where they happen. – DaveShaw Jun 16 '11 at 19:37

3 Answers3

2

This links to a c# tutorial on the liblas.org site http://www.liblas.org/tutorial/csharp.html . Hope this helps. The latest release, libLAS-1.7.0b1 installs like a dream compared to the 1.6.1 nightmare (under windows). Chris

Chris
  • 629
  • 10
  • 20
0

WolfInSpace answered the second part of your question. You can find the answer to the first part in this thread:

Is there an R package to parse geophysical "Log Ascii Standard" Files (.las files)?

Moreover, in case you are into developing yourself, you can read this article on saving LAS files:

http://www.kgs.ku.edu/stratigraphic/PROFILE/HELP/Help-PC-SaveLASFile.html

Please let us know what did u end up doing. I am working on the same project as well. Best

Community
  • 1
  • 1
AleX_
  • 409
  • 7
  • 16
  • 1
    Link only answers are not nice, try to put in relevant code or summarize the process – Ani Oct 21 '13 at 16:37
0

You can create an XML document quite easily in C# using XmlWriter, contained in the System.Xml namespace. Here's an example of how you can use it:

using System.Xml;
using System.Collections.Generic;

namespace XmlExample
{
    class Program
    {
        static void Main(string[] args)
        {
            List<Student> students = new List<Student>();

            students.Add(new Student { ID = 1, Name = "Ryan", Grade = 99 });
            students.Add(new Student { ID = 2, Name = "Ann", Grade = 84 });
            students.Add(new Student { ID = 3, Name = "Rebecca", Grade = 83 });
            students.Add(new Student { ID = 4, Name = "Jon", Grade = 26 });

            using (XmlWriter xml = XmlWriter.Create("ComputerScience1234.xml"))
            {
                xml.WriteStartDocument();
                xml.WriteStartElement("COSC1234");

                foreach (Student s in students)
                {
                    xml.WriteStartElement("Student");

                    xml.WriteElementString("ID", s.ID.ToString());
                    xml.WriteElementString("Name", s.Name);
                    xml.WriteElementString("Grade", s.Grade.ToString());

                    xml.WriteEndElement();
                }

                xml.WriteEndElement();
                xml.WriteEndDocument();

            }
        }
    }
}
Geekatron
  • 116
  • 5