Skip to content

Instantly share code, notes, and snippets.

@surmon-china
Last active June 5, 2022 11:21
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save surmon-china/fcd06fa53357859c6c83adf496b340f8 to your computer and use it in GitHub Desktop.
Save surmon-china/fcd06fa53357859c6c83adf496b340f8 to your computer and use it in GitHub Desktop.
Export footprint JSON from Apple photos.
Application("Photos").mediaItems().filter(item => {
const [latitude, longitude] = item.location()
return Boolean(latitude) && Boolean(longitude)
}).map(item => {
return [
item.date().getTime() / 1000,
item.location()
]
})
Application("Photos")
.mediaItems()
.reduce((result, item) => {
const [latitude, longitude] = item.location();
if ((latitude, longitude)) {
const date = item.date()
result.features.push({
type: "Feature",
geometry: {
type: "Point",
coordinates: [longitude, latitude],
},
properties: {
date: date.getTime() / 1000,
year: date.getFullYear(),
month: date.getMonth() + 1
},
});
}
return result
}, {
type: "FeatureCollection",
features: [],
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment