Import from QGIS (KML or DXF)

Hi,

I am using QGIS (Geographical Information System software) to draw areas (for solar projects). Then i want to import those faces into Sketchup to then design the photovoltaic plant.
There are 2 ways to do this.

Method 1)
Export the face from Qgis into a KML. Then convert the KML to KMZ (with https://mygeodata.cloud). But when importing the KMZ, Sketchup says “import failed” without any other explanation.
Although:
-The KMZ file is correct when opened in Google Earth;
-In Sketchup i did geolocate the drawing beforehand.

Method 2)
Export the face from QGIS into a DXF. When importing the DXF into sketchup, when it works, i don’t get a face; instead the edge of the face is a set of 2 lines with a surface (face) inbetween (up to 1m distance between the 2 lines). As if the DXF line was given a thinkness in sketchup…

Other info :
-When opening the DXF file with TrueView or Autocad, is not a face but a poyline (and only one).

I attach the KMZ and DXF files.
20200831_-_field_1.kmz (1.4 KB)
20200831 - field1.dxf (20.4 KB)

Has anyone an idea of what could be an explanation or other another method?

another way:
Open DXF file in Autocad > select the polyline > Explode it > Save.
Import in SketchUp > Draw a rectangle over > face is created

or

Import your actual dxf in SketchUp and clean it

The odd thing about the DXF import is that in DWG TrueView the polyline appears to have a width of 0 but it gets imported into SketchUp as a “wide” polyline. I suspect a bug in the importer but I should check if it happens with all polyline entities.
Edit: I tested with a file of my own and polyline widths were imported correctly. I wonder if this happens only with “3D” polylines as the objects in my file were 2D LWPOLYLINEs
Edit2: The border in Mikael’s DXF is a LWPOLYLINE too. I wonder what makes it gain “width” when imported.
Edit3: I looked at the file in Notepad. The polyline has its width set to -1.0 . When I change that into 0.0 it imports without width. It seems that Qgis has an oddity in its DXF export.

1 Like

Thanks you Mihai.

I have Autocad on another computer at work so i’ll try that out in a few days. If i can avoid this step (with additionnal software) it’s better but it’s good to know.

In your second GIF, how do you manage to select (and erase) the whole inner line? It seems like it’s a polyline but in skp i only know simple lines which i can only select one by one.

You’re welcome!

With left mouse button triple-click on an edge.

Thanks a lot, you’ve just taught me the magic i needed to know !

1 Like

Note that the exact border might lay in the middle between those two lines. The Qgis exporter has added a -1.0 units line width to the polyline.

Thanks a lot Anssi, this does work, that’s a pretty fast solution.
I reported the bug to the QGIS Community on GitHub.

Dear Anssi,
did you replace the LWPOLYLINE values via search and replace? I tried that, but SKP says “Import failed”.
Could you please be more specific which string you “search and replace”, please?

Where would I change the values to 0.0?
Thank you!
Ronen

Width is group code 43. You should try changing the text “-1.0” that is on the line under the number 43 to “0.0” (not sure if plain 0 works) Omit the quotes.

2 Likes

@Anssi
Oh, wonderful, thanks a lot. You saved my day!
Thanks.
R

Dear @Anssi,
do you as well know about the other way around? Importing georeferenced data from Sketchup into QGIS.
Actually, DXF files can contain georeferenced data. But how do I export a georeferenced DXF file from Sketchup?
I had high hopes on the KML/ KMZ file format created from Sketchup, which works perfectly when imported to Google Earth, but will not work when imported to QGIS. (Other KMLs created in Google Earth work fine when imported to QGIS).

Do you have a workflow for that?
Thanks,
Ronen

I just found out:

If I export a DXF from QGIS, import it to Sketchup with the option “preserve drawing origin” ticked on, don’t scale and move or relocate in SU, make adjustments in Sketchup, re-export it from Sketchup to DXF and import it again to QGIS with the “AnotherDXFImporter”, will do the job.

When SketchUp exports or imports a kmz file, it writes/reads the model data into a collada (.dae) file inside the kmz archive. SketchUp ignores any kml files in the kmz.

So, you’re saying, when I export a KMZ from Sketchup, there’s actually no KML info inside, only Collada data, which is the reason why QGIS won’t be able to import these?

Exactly (assuming QGIS is looking for kml).

I know it is weird concept, but QGIS, just like any other professional software, looks for the things it’s been asked to look for… I understand it is another dimension of time and space for Sketchup “developers”.

Snark aside, Google is to blame for this.

Back when they owned SketchUp, they wanted a way to let users create 3D buildings to populate Google Earth for free. But because kml uses (lat, lon, altitude) coordinates, it makes a very strange and awkward medium for drawing buildings. Verticals are not parallel, the ground is not flat, horizontal dimensions are measured in angles, etc. So they bought SketchUp, which models in the sort of 3D (x,y,z) coordinates people are used to, and decided that the way to get those into Google Earth was to use a non-proprietary 3D modeling format: Collada (.dae). They created the kmz file format to allow them to combine geolocation information to place the the 3D model on the earth. But they never implemented a way for SketchUp to load or create kml itself.

Google subsequently found other ways to get 3D buildings, lost interest in SketchUp, and finally sold it to Trimble. SketchUp never did create any kml other than the geolocation coordinates, and it remains that way today.

1 Like

Thank you @slbaumgartner for the insight. Really appreciate it!