Inspire a community of professionals skilled in spatiotemporal analysis for community health and safety.
Write a tool that converts the example KMZ datasets into a normalized format.
Roy Hyunjin Han
We have some example datasets and we would like to normalize them so that downstream modules know how to load them.
20170912-1715 - 20170920-1700: 1 week actual
_ Load example kmz datasets _ Save kmz datasets _ Build a tool that extracts specific information from a kml file
20170912-1715 - 20170912-1815: 60 minutes
fastkml _ kmltogeojson _ pykml _ simplekml _ pygis + Find packages for handling kmz files
20170912-2130 - 20170912-2200: 30 minutes
After evaluating a bunch of packages, I think we should use
+ Decide which package we might use
20170920-1630 - 20170920-1700: 30 minutes
Maybe we can stick to GDAL for both loading and saving the KML. I don't feel like going into the specifics of KML format.
I think the reason fastkml exists is if you do not want any dependencies other than Python.
_ Use fastkml to load the example datasets
I probably could use fiona, but I would rather upgrade geometryIO as it has been on my list of things to do for a long time. But I would like to call it something different.
from os.path import expanduser dataset_path = expanduser('~/Experiments/Datasets/evi-20170819.kmz')
# Try fiona import pip pip.main(['install', 'fiona'])
import fiona # fiona.open(dataset_path) # Raises FionaValueError
It looks like fiona will not support kml: https://github.com/Toblerity/Fiona/issues/23
# Try geometryIO import geometryIO geometryIO.load(dataset_path)
The geometryIO package makes more progress, but it looks like it is not loading any geometries. We might have to put KML to CSV/SHP.ZIP as a separate tool.
import pip pip.main(['install', 'fastkml'])
%%bash cd ~/Downloads cp ~/Experiments/Datasets/evi-20170819.kmz . unzip evi-20170819.kmz ls -l
from fastkml.kml import KML from os.path import expanduser kml = KML() kml_text = open(expanduser('~/Downloads/doc.kml'), 'rb').read() kml.from_string(kml_text) len(list(kml.features()))
features = list(kml.features()) f = list(features.features()) f.__dict__
x = list(list(list(f.features()).features()).features()) x
It looks like kml is one of those strange nested file formats.
x = list(list(list(f.features()).features()).features()) x.__dict__
_ Examine KML of each example dataset _ Try gdal _ Load the different datasets _ Save the different datasets
We decided not to accept kml files for now.