I have a shapefile of size 224 MB. I am using ArcGIS to convert it to a KML file. The process involves converting the shapefile to a feature layer and then converting the layer to KML.
An alternative method that I have tried is using ogr2ogr.
In both the cases, the KML file produced is around 500 MBs. I need it to be less than 250 MBs, so I can import it as a Google Fusion table.
I was informed that one of the best ways to cut size is to reduce precision of the coordinates to 5 decimal places (from its current 10 or so).
How do I go about changing the decimal places using either ogr2ogr or ArcGIS? Is there some other software that may help in this and also, are there any other strategies I may use to reduce the size of the KML file?
I tried using Notepad++ to open the KML file and then use regular expressions to change coordinate precision but for some reason this method is not working. If I make the change and try and save the file, all the data gets deleted and the KML file size changes to 0 bytes.
An alternative strategy that I was thinking of was to split my shapefiles into two or three files and convert them to KML separately, upload them to Google fusion tables and then append those. However, I am not sure of two things.
- How to split shapefiles into two or three smaller shapefiles?
- Whether I can easily append fusion tables together to create a larger fusion table?
Best Answer
Having come across the same problem, I have develop a rudimentary workaround, which is pretty quick and dirty. It almost halves the KML size but with a cost, it removes of all HTML popups and symbology/style specifications. It is good for pure viewing purposes.
I usually prefer using Generalize tool (requires at least Editor licence) to test various options until I am satisfied with the shapes that I want to process. Usually a value in between 0.5 and 0.8 meters gives me a decent outcome. A warning, the Generalize tool modifies the input data, so the best practice is to take a copy of it beforehand.
After reading the suggestions and doing some research, I have decided to develop a pretty rough python script for KML stripping process by using regular expression (intentionally avoiding XML parsing process). The code is as follows: