Solved

Converting KML to Dwg stretches the original shape


Hi

I drew a simple shape with google my map and export it to kml in my browser then i convert it to dwg/dxf with FME quick translator to modify the shape with Autocad, but the original map stretches out and shows a wrong map, it also happens when i convert dwg/dxf files to kml or gpx.

how can i fix it?

icon

Best answer by geosander 3 July 2017, 21:26

View original

4 replies

Badge +7

Hi @melikabustan,

My guess is that you're quite new to this stuff, so forgive me if I'm telling things that you already knew.

Your input KML has a geographic coordinate system called LL84 (standard for KML), which means that your rectangle is stored as latitude-longitude coordinates and the unit is in degrees. This coordinate system provides an accurate position on the globe. Note however that your rectangle already looks like a rotate parallelogram. This is not FME's mistake, but caused by the coordinate system of the KML. The problem is, that you have drawn your shape in Google Maps, which uses a projected coordinate system called Spherical Mercator(also known as EPSG:3857) that is used for the entire globe. This system uses metric units (well, kind of, but let's not make it more complicated). Typically, with any kind of map, projected coordinate systems are used, because it makes our world look better and we can use sensible units (meter, feet etc. instead of degrees) for distance and area measurements.

A word of advice though: don't ever use the Spherical Mercator projection for distance and area measurements, in case you were planning to do so in your CAD application. I'll come back to that later.

If you want to end up with exactly the same shape that you saw in Google Maps, you should tell the Quick Translator to reproject the KML into a Spherical Mercator projection. You can set this in the Coord. System field, like so:

Set the coordinate system to EPSG:3857 if you want to use the exact same one as Google Maps does. However, if you want to do distance and area measurements, use another projected coordinate system that is more suitable for your particular area of the world, which is Oberstdorf, Germany in this case. Often, they use the Deutsches Hauptdreiecksnetz (DHDN) system there, which is divided into several zones across the country. For you area, you would have to set the coordinate system to EPSG:31467 and FME will reproject to that system instead. It will lead to the least distortion and the metric distances you measure will be (almost) 100% correct.

Now there's a little caveat: by default, the DWG writer does not store the coordinate system. You need to explicitly instruct it to do so, by changing the "Coordinate System Storage" setting under Parameters > Advanced (see left button in image above). Then, it will create an auxiliary file (in the example below, a *.PRJ) that your CAD program (if you're lucky!) can read, so that it looks the same as in Google Maps. Note that choosing "Internal ESRI WKT" will not work in most applications, only when you have "ArcGIS for AutoCAD" or when you read it back in with FME. The safest option would be to choose "Both", probably.

If you want to convert the other way around, you should tell the ACAD Reader to explicitly use EPSG:3857 as the coordinate system, just in case. The KML Writer will always write to a LL84 coordinate system anyway.

Hi @melikabustan,

My guess is that you're quite new to this stuff, so forgive me if I'm telling things that you already knew.

Your input KML has a geographic coordinate system called LL84 (standard for KML), which means that your rectangle is stored as latitude-longitude coordinates and the unit is in degrees. This coordinate system provides an accurate position on the globe. Note however that your rectangle already looks like a rotate parallelogram. This is not FME's mistake, but caused by the coordinate system of the KML. The problem is, that you have drawn your shape in Google Maps, which uses a projected coordinate system called Spherical Mercator(also known as EPSG:3857) that is used for the entire globe. This system uses metric units (well, kind of, but let's not make it more complicated). Typically, with any kind of map, projected coordinate systems are used, because it makes our world look better and we can use sensible units (meter, feet etc. instead of degrees) for distance and area measurements.

A word of advice though: don't ever use the Spherical Mercator projection for distance and area measurements, in case you were planning to do so in your CAD application. I'll come back to that later.

If you want to end up with exactly the same shape that you saw in Google Maps, you should tell the Quick Translator to reproject the KML into a Spherical Mercator projection. You can set this in the Coord. System field, like so:

Set the coordinate system to EPSG:3857 if you want to use the exact same one as Google Maps does. However, if you want to do distance and area measurements, use another projected coordinate system that is more suitable for your particular area of the world, which is Oberstdorf, Germany in this case. Often, they use the Deutsches Hauptdreiecksnetz (DHDN) system there, which is divided into several zones across the country. For you area, you would have to set the coordinate system to EPSG:31467 and FME will reproject to that system instead. It will lead to the least distortion and the metric distances you measure will be (almost) 100% correct.

Now there's a little caveat: by default, the DWG writer does not store the coordinate system. You need to explicitly instruct it to do so, by changing the "Coordinate System Storage" setting under Parameters > Advanced (see left button in image above). Then, it will create an auxiliary file (in the example below, a *.PRJ) that your CAD program (if you're lucky!) can read, so that it looks the same as in Google Maps. Note that choosing "Internal ESRI WKT" will not work in most applications, only when you have "ArcGIS for AutoCAD" or when you read it back in with FME. The safest option would be to choose "Both", probably.

If you want to convert the other way around, you should tell the ACAD Reader to explicitly use EPSG:3857 as the coordinate system, just in case. The KML Writer will always write to a LL84 coordinate system anyway.

thank you very much for your great explanation, I was totally new to these stuffs now I can get them.

Badge +7

thank you very much for your great explanation, I was totally new to these stuffs now I can get them.

No problem! Glad my explanation proved useful :)

 

 

I have the same problem. It doesn't seem to be the matter of coordination. And the kml file supposed to keep the coordinates and all the data not to change it. In here in the left picture I have the correct file size and the right one is the dwg format that has been converted from kml and obviously tge rectangle is stretched.

Reply