Skip to content

Instantly share code, notes, and snippets.

@glostis
Created April 23, 2019 11:57
Show Gist options
  • Save glostis/0bdd5e93c07361a80b1ca7a29fa9eb25 to your computer and use it in GitHub Desktop.
Save glostis/0bdd5e93c07361a80b1ca7a29fa9eb25 to your computer and use it in GitHub Desktop.
from planet.api import ClientV1, filters
from simplekml import Kml, Style, Color
def get_items(item_type="SkySatScene", permission="assets.basic_panchromatic_dn:download"):
client = ClientV1()
query = filters.and_filter(filters.permission_filter(permission))
request = filters.build_search_request(query, item_types=[item_type])
result = client.quick_search(request)
bad_items = []
for item in result.items_iter(limit=None):
if permission not in item["_permissions"]:
bad_items.append(item)
return bad_items
def make_kml(items):
kml = Kml()
style = Style()
style.linestyle.color = Color.red
style.linestyle.width = 2
style.polystyle.color = Color.changealphaint(50, Color.white)
for item in items:
poly = kml.newpolygon(name=item["id"], outerboundaryis=item["geometry"]["coordinates"][0])
poly.style = style
return kml
if __name__ == "__main__":
_bad_items = get_items()
_kml = make_kml(_bad_items)
_kml.save("bad_items.kml")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment