If you want to convert KML file to GeoJson file, refer below mention library for such conversion
In following example we are going use KML file from row folder and convert it in to GeoJson file and sore in SD Card.
Download Sample Code
Screenshot:
- library Name:osmbonuspack
- for installation refer following link :https://github.com/MKergall/osmbonuspack/wiki/HowToInclude
- for more reference follow this link: https://github.com/MKergall/osmbonuspack/wiki/Tutorial_4
- there are function name saveASKml,saveAsGeoJson use this function to convert the KMl file to GeoJson and vice versa
In following example we are going use KML file from row folder and convert it in to GeoJson file and sore in SD Card.
InputStream ins = getResources().openRawResource(
getResources().getIdentifier("pmc_election_ward_boundaries",
"raw", getPackageName())); //take file from row folder
kmlDocument = new KmlDocument();
kmlDocument.parseKMLStream(ins, null);
fCreated = kmlDocument.saveAsGeoJSON(new File(Environment.getExternalStorageDirectory() + "/sample.geojson"));
Download Sample Code
Screenshot:
- file name sample.geojson is converted from KML file to geoJosn
- GeoJson file plot on mapbox




