I'm using the Planet Labs Scenes API and need to get the results of a (large) search I'm making as a shapefile. Any hints on how to go about it? I'm comfortable with command line tools like the command line interface of the Planet Python Client and OGR, but not quite up for custom python coding.
1 Answer
There are a few different ways of doing this, but if we stick to command line tools, you can get all the footprints as a Shapefile with a simple OGR command.
The Planet Scenes API returns the results of a search as valid GeoJSON, which is a format that OGR understands. Therefore, if you run the search in your browser (https://api.planet.com/v0/scenes/ortho/ ...) and save the results as results.json
, you can generate the Shapefile like this:
ogr2ogr results.shp results.json
The new search.shp
will contain the footprints of all the scenes as well as the associated metadata.
If you are using the Planet CLI tool, then you can do this is in two steps:
planet search --where ... POLYGON((...)) > results.json
ogr2ogr results.shp results.json
You can also do it in one single command:
planet search --where ... POLYGON((...)) | ogr2ogr results.shp /vsistdin/
All of these OGR commands will probably warn you that some strip_id
numbers were not successfully recorded in the Shapefile. This is because OGR interprets these as floating point numbers, which will have a different representation from the source GeoJSON. This is only important if you need the strip_id
to be accurate in the Shapefile; otherwise, you can ignore this warning.
Disclaimer: I work for Planet Labs.