diff --git a/lib/spatial_features/unzip.rb b/lib/spatial_features/unzip.rb
index <HASH>..<HASH> 100644
--- a/lib/spatial_features/unzip.rb
+++ b/lib/spatial_features/unzip.rb
@@ -1,14 +1,9 @@
+require 'fileutils'
+
 module SpatialFeatures
   module Unzip
     def self.paths(file_path, find: nil)
-      dir = Dir.mktmpdir
-      paths = []
-
-      entries(file_path).each do |entry|
-        path = "#{dir}/#{entry.name}"
-        entry.extract(path)
-        paths << path
-      end
+      paths = extract(file_path)
 
       if find = Array.wrap(find).presence
         paths = paths.detect {|path| find.any? {|pattern| path.include?(pattern) } }
@@ -18,6 +13,20 @@ module SpatialFeatures
       return paths
     end
 
+    def self.extract(file_path, output_dir = Dir.mktmpdir)
+      [].tap do |paths|
+        entries(file_path).each do |entry|
+          path = "#{output_dir}/#{entry.name}"
+          FileUtils.mkdir_p(File.dirname(path))
+          entry.extract(path)
+          paths << path
+        end
+      end
+    rescue => e
+      FileUtils.remove_entry(output_dir)
+      raise(e)
+    end
+
     def self.names(file_path)
       entries(file_path).collect(&:name)
     end
Fix bug that prevented import of KMZs with folders

When unzipping, we are tasked with creating folders for all zipfile entries. If there is a subfoldered entry, we need to also create that folder too.