0

I'm trying to read a folder containing ~80,000 .kmz files of vector data using sf::st_read.

The top-level folder contains a single large .kml file that I expect ties all of the other folders/data together.

These are arranged into a group of OSGB folders, e.g. folder contains four sub-folders and and four .kmz files that I presume describe the folder contents.

Each of these folders then contains a cluster of .kmz files where I presume the vector data is contained for each grid square (e.g. )

So the structure is: 1x top-level.kml

~400x grid square file.kmz

~400x grid square folder

~100x smaller grid square files.kmz

Or...do I simply take all of the small grid square .kmz files, unzip them and import each 1-by-1? I've not yet tried this in the hope that there's a more elegant solution somewhere

Apologies, if I've missed any earlier advice about this but I've searched StackExchange for a solution to this) Further apologies but the data isn't public domain so I'm not sure how best to share, either!

8
  • You shouldn't have to unzip KMZ to read them. Have you tried reading anything yet? What's stopping you trying to loop over all the files and read them? Try it on a subset first.
    – Spacedman
    Jun 2, 2020 at 14:00
  • Why do you "expect" the top-level KML to tie everything together? Can you not inspect it and tell us? How would it tie them together? What is an "OSGB Folder"? Presumably Ordnance Survey GB but that doesn't really say much. Names, contents? Descriptions as much as possible if you cant provide details - but the more details, the more help.
    – Spacedman
    Jun 2, 2020 at 14:03
  • As far as I know, sf::st_read can not open kmz directly. You have to convert them to the kml first. Or use another approach. Maybe this helps gis.stackexchange.com/questions/58131/reading-kml-file-into-r
    – Anatolii
    Jun 2, 2020 at 14:17
  • 1
    @Anatolii some kmz will read in perfectly well, some wont. Depends on the way it is structured. Impossible to tell what the questioner has unless they try and show us what happens.
    – Spacedman
    Jun 2, 2020 at 14:58
  • Hi Spacedman and Anatolii, many thanks for taking the time to comment. I think I need to try and create a reprex somehow. Yes, the "OSGB folder" was my shorthand for Ordinance Survey GB, because the folders are arranged into OSGB 4-char grid-ref with sub-folders in 6-char format, e.g. folder <SO22> contains <SO22>, <SO23>, <SO32>, <SO33>, and then <SO22> contains 101 .kmz files names <SO2020.kmz>, etc. I can read the whole nested structure in Google Earth but it feels like st_read cannot import the nested structure. Jun 3, 2020 at 6:57

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.