Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Correctly export LandXML surface (without additional triangulation)

jamesmac1201
Advocate

Correctly export LandXML surface (without additional triangulation)

jamesmac1201
Advocate
Advocate

I need some advice on how to properly export a surface in LandXML format AND the surface maintains it's original shape. I've attached two files of the same surface. One is a GeoTiff surface and the other is a LandXML surface. The GeoTiff surface is how the surface should look. The LandXML surface, however, adds additional triangulation to the surface upon export. Not sure why it does this. Any suggestions would be appreciated.

0 Likes
Reply
Accepted solutions (1)
6,220 Views
22 Replies
Replies (22)

BrianHailey
Mentor
Mentor

Are you sure you don't have that backwards?

 

Here's what the LandXML file looks like:

BrianHailey_0-1645630685562.png

And here's what the GeoTIF looks like:

BrianHailey_1-1645630718483.png

 

Brian J. Hailey, P.E.



GEI Consultants
My Civil 3D Blog

0 Likes

jamesmac1201
Advocate
Advocate

You're correct @BrianHailey. Interestingly, in Global Mapper, the results are reversed. Since the GeoTiff surface contains the extra triangulation, I can create a new surface, add the GeoTiff data then add an outer boundary to trim the extra triangulation.

0 Likes

BrianHailey
Mentor
Mentor

My guess on what happened (and, this is just a guess):

 

The surface was developed in Civil 3D and then exported out to a GeoTIF. When exporting out as a DEM (which is what a GeoTIF is), there's an option for the grid spacing. This is likely where the extra triangles come into play. the problem with a DEM is that is a grid and you can't have points between the grid points so you lose some detail in the surface, which is why there are often an absurd amount of points in a DEM. Assuming my guess is correct, if you can use the LandXML instead of the GeoTIF, that would be ideal.

Brian J. Hailey, P.E.



GEI Consultants
My Civil 3D Blog

0 Likes

jamesmac1201
Advocate
Advocate

Thanks for the update. In my scenario, I'm the one exporting the data for a client to use. I just want to make sure the end-user is receiving a surface without the additional triangulation. As you suggested, I prefer sending a LandXML.

0 Likes

jamesmac1201
Advocate
Advocate

Also in Infrawork, the LandXML surface behaves like the GeoTiff surface; it shows the extra triangulation, whereas the GeoTiff doesn't. That same LandXML surface is shown in the image below and it's showing the added tin

jamesmac1201_0-1645639131025.png

 

0 Likes

jamesmac1201
Advocate
Advocate

There is actually two different results for the GeoTiff surface depending on how you import the surface. If you choose the option "Create Surface from DEM" option, you have the results shown below:

jamesmac1201_0-1645640370052.png

 

If I create a new surface and add in the DEM file data, I get the results shown below:

jamesmac1201_1-1645640475076.png

 

Its interesting how Civil 3D processes the data based on the two different import options.

 

joesalveson
Participant
Participant

From my experience, exporting and xml from Civil3d keeps the triangulation shown in CAD.  I think it is Global Mapper that adds the additional triangles when the xml is imported. As long as your client imports the xml into Civil3D the surface will not have the added triangles. I can import your xml into Civil3d 22 and it looks fine.

0 Likes

jamesmac1201
Advocate
Advocate

You're correct. Importing the LandXML into Civil 3D will produce the correct triangulation. However, importing that same LandXML into Global Mapper and Infraworks will come in incorrectly (adding the additional tin). Alternatively, importing the GeoTIFF surface into Civil 3D produced the additional tin. Importing the GeoTIFF into Global Mapper and Infraworks came in correctly.

0 Likes

andrewpuller3811
Advisor
Advisor
Accepted solution

The problem is that when a triangle is deleted by the user in civil 3d, it seems the triangles definition remains in the surface but it is marked as deleted. When the surface is exported to XML, the deleted triangles are exported as well but have an extra attribute which tells software to "ignore" the triangles. The problem is that the majority of software that digest the xml files don't acknowledge or know about the ignore attribute, so the triangles that were deleted in civil 3d, get imported and used by other software.

 

If you look through the xml file you attached you will see some of the face definitions have i="1" in them. These are the surface triangles(faces) that are supposed to be ignored. See sample below.

 

<F n="146 148 151">624 32 33</F>
<F i="1" n="156 147 149">623 33 32</F>                          <= note ignore attribute
<F i="1" n="148 150 1322">623 32 622</F>                          <= note ignore attribute
<F i="1" n="1348 149 142">646 622 32</F>                          <= note ignore attribute
<F n="1350 147 152">625 624 33</F>

 

The only way I have found to get a clean surface is to extract the triangles from the surface in civil 3d, then create a new surface from those triangles and then export that surface to xml. 



If a post provides a fix for your issue, click on "Accept as Solution" to help other users find solutions to problems they might have that are similar to yours.

Andrew Puller
Maitland, NSW, Australia
Windows 11
Intel core i7 11800 @ 2.30 GHz with 32GB Ram
Civil 3d 2023

BrianHailey
Mentor
Mentor

Does this include the triangles removed by a boundary or just the ones removed via the "delete line" edit?

Brian J. Hailey, P.E.



GEI Consultants
My Civil 3D Blog

0 Likes

jamesmac1201
Advocate
Advocate

Very informative @andrewpuller3811 . I did not know about those parameters, although that makes a lot of sense. I'll try your method of extracting out the triangles and recreating that surface. Thanks again.

0 Likes

jamesmac1201
Advocate
Advocate

It must also include triangles deleted by a boundary since the surface in question had an outer boundary (destructive) applied to the surface.

DinhMinhDuc
Contributor
Contributor

Can you explain the parameters in [<F n="5 49 3">4 28 27</F>
]help me?

0 Likes

andrewpuller3811
Advisor
Advisor

<F n="5 49 3">4 28 27</F>

 

Based on the LandXML 1.2 schema definition -

 

  • the "F" part indicates a face element
  • the "n="5 49 3"" part indicates the adjoining faces in the surface - so this face is adjacent to faces 5, 49 and 3
  • the "4 28 27" part represents the surface points that the face is made up of - these are defined elsewhere in the surface element

The schema documentation can be view here - http://www.landxml.org/schema/LandXML-1.2/documentation/LandXML-1.2Doc.html 

You can view the documentation for the face element here - http://www.landxml.org/schema/LandXML-1.2/documentation/LandXML-1.2Doc_F.html

 

 



If a post provides a fix for your issue, click on "Accept as Solution" to help other users find solutions to problems they might have that are similar to yours.

Andrew Puller
Maitland, NSW, Australia
Windows 11
Intel core i7 11800 @ 2.30 GHz with 32GB Ram
Civil 3d 2023

matt_anderson_pe
Collaborator
Collaborator

I stumbled upon this little gem.  Python code that removes "deleted" faces from the LandXML. 

http://www.knickknackcivil.com/hacking-landxml.html

import lxml.etree as et
import os

# Input path to LandXML
landxmlpath = r'P:\File Path\'
in_XML = 'SJRA Siphon 39 Topo LandXMLOut.xml'
out_LXML = 'SJRA Siphon 39 Topo Final.xml'
landxml_in_file = os.path.join(landxmlpath,in_XML)
landxml_out_file = os.path.join(landxmlpath,out_LXML)
with open(r'P:\\San Jacinto River Authority\\1195 - Exxon Siphon 39\\3-0-Reference-Material\\3-3-Supplied-Drawings\\Survey\\Documents\\03-Design-Files\\03-References\\Survey\\Nov 2023\\SJRA Siphon 39 Topo LandXMLOut.xml', 'rb') as in_file:
    with open(os.path.join(landxmlpath,'SJRA Siphon 39 Topo Final.xml'), 'wb+') as out_file:
        xml = in_file.read().decode('iso-8859-1').encode('ascii')
        doc = et.XML(xml)
        surfaces = doc.getchildren()[-1]

        # LandXML could contain multiple surfaces
        for surface in surfaces:
            definition = surface.getchildren()[-1]  #Selecting surface definition
            faces = definition.getchildren()[-1]    #Selecting faces

            for face in faces:
                # If faces field includes an 'i' key, then it should be
                # removed from the surface
                if 'i' in face.attrib:
                    print(face.attrib)
                    attrib_items = face.attrib
                    #cleaned.items = attrib_items.remove('i')
                    #face.attrib.remove("i")
                    print(attrib_items)

                    #face.getparent().remove(face,"i")

        # Creating output landxml without internal faces and enabling 
        # pretty print which is easier to read and edit.
        out_xml = et.tostring(doc, encoding="UTF-8", pretty_print=True)
        out_file.write(out_xml)
        out_file.close 

 Took a little bit of debugging in Visual Studio Code with Jupyter Notebook.

Matthew Anderson, PE

dsmapping
Enthusiast
Enthusiast

How do you export the landxml out of Civil 3d? I have a dem from global mapper that I am trying to export out of Civil 3d as a tin surface landxml. But when I do so it tells me that there is no compatible landxml objects. How come?

0 Likes

joesalveson
Participant
Participant
Click on file menu, then "Export", then "Export to LandXML", then "pick from drawing", then select your surface and then "enter", then "OK", and choose folder and enter file name for xml file, then "Save".


0 Likes

dsmapping
Enthusiast
Enthusiast

Thanks for the response! I dont see that option - here is what I see attached.  

0 Likes

joesalveson
Participant
Participant
I'm not sure why that option does not appear the menu. You can also type in "landxmlout" on the command line to get to the point where you can select "Pick from drawing" to select the surface for export.
0 Likes