- Go 100%
| example/items-and-assets | ||
| .air.toml | ||
| .gitignore | ||
| assets.go | ||
| client.go | ||
| go.mod | ||
| go.sum | ||
| item_type.go | ||
| lefthook.yml | ||
| order.go | ||
| README.md | ||
| search.go | ||
go-planet
This is an API client for the Planet API in go. It aims to support all operations of the API.
Items
In my wrath I'm going to write what I can about what limitations I'm finding with Planet's demo account. Here is the list of "items" the demo account has access to:
| id | name | description |
|---|---|---|
| PelicanScene | Pelican Scene | "One tile of a Pelican strip collection" |
| PSScene | PlanetScope Scene | "8-band PlanetScope imagery that is framed as captured." |
| REOrthoTile | RapidEye Ortho Tile | "RapidEye orthorectified 5-band imagery as 25km x 25km UTM tiles" |
| REScene | RapidEye Basic Scene | "RapidEye basic 5-band imagery with strip-based framing" |
| SkySatCollect | SkySat Collect | "SkySat imagery with strip-based framing" |
| SkySatScene | SkySat Scene | "SkySat imagery that is framed as captured" |
| SkySatVideo | SkySat Video | "SkySat video product" |
| TanagerScene | Tanager Scene | "Tanager Hyperspectral Imagery" |
| TanagerMethane | Tanager Methane | "Tanager Methane Derived Products" |
Assets
| id | name | description |
|---|---|---|
| basic_l1a_all_frames | Zip file containing all L1A frames, RPCs, and pinhole json files | Compressed folder with all basic l1a panchromatic frames and accompanying RPCs and pinhole json files that make up the collect |
| analytic | Analytic image (4 Band) | Radiometrically-calibrated analytic image stored as 16-bit scaled radiance |
| analytic_sr | Atmospherically corrected surface reflectance (4 Band) | PlanetScope atmospherically corrected surface reflectance product |
| analytic_xml | Analytic image metadata (4 Band) | Radiometrically-calibrated analytic image metadata |
| basic_analytic | Basic analytic image (4 Band) | Unorthorectified radiometrically-calibrated analytic image stored as 16-bit scaled radiance |
| basic_analytic_4b_rpc | Unprojected top of atmosphere radiance (4 Band) rational polynomial coefficients for rectification | Rational polynomial coefficients for unorthorectified analytic image |
| basic_analytic_4b | Unprojected top of atmosphere radiance (4 Band) | Unorthorectified radiometrically-calibrated analytic image stored as 16-bit scaled radiance. |
| basic_analytic_4b_xml | Unprojected top of atmosphere radiance (4 Band) metadata | Unorthorectified radiometrically-calibrated analytic image metadata. |
| basic_analytic_8b | Unprojected top of atmosphere radiance (8 Band) | Unorthorectified radiometrically-calibrated analytic image stored as 16-bit scaled radiance. |
| basic_analytic_8b_xml | Unprojected top of atmosphere radiance (8 Band) metadata | Unorthorectified radiometrically-calibrated analytic image metadata |
| basic_analytic_b1 | Blue Band (Band1) of the Analytic Basic scene | RapidEye band 1 (Blue) scaled Top of Atmosphere Radiance (at sensor) and Sensor corrected, Basic Scene product designed for users with advanced image processing and geometric correction capabilities. Scene based framing and not projected to a cartographic projection. |
| basic_analytic_b1_nitf | Blue Band (Band1) of the Analytic Basic scene in the NITF format | RapidEye band 1 (Blue) scaled Top of Atmosphere Radiance (at sensor) and Sensor corrected, Basic Scene product in the NITF format, designed for users with advanced image processing and geometric correction capabilities. Scene based framing and not projected to a cartographic projection. |
| basic_analytic_b2 | Green Band (Band2) of the Analytic Basic scene | RapidEye band 2 (Green) scaled Top of Atmosphere Radiance (at sensor) and Sensor corrected, Basic Scene product designed for users with advanced image processing and geometric correction capabilities. Scene based framing and not projected to a cartographic projection. |
| basic_analytic_b2_nitf | Green Band (Band2) of the Analytic Basic scene in the NITF format | RapidEye band 2 (Green) scaled Top of Atmosphere Radiance (at sensor) and Sensor corrected, Basic Scene product in the NITF format, designed for users with advanced image processing and geometric correction capabilities. Scene based framing and not projected to a cartographic projection . |
| basic_analytic_b3 | Red Band (Band3) of the Analytic Basic scene | RapidEye band 3 (Red) scaled Top of Atmosphere Radiance (at sensor) and Sensor corrected, Basic Scene product designed for users with advanced image processing and geometric correction capabilities. Scene based framing and not projected to a cartographic projection. |
| basic_analytic_b3_nitf | Red Band (Band3) of the Analytic Basic scene in the NITF format | RapidEye band 3 (Red) scaled Top of Atmosphere Radiance (at sensor) and Sensor corrected, Basic Scene product in the NITF format, designed for users with advanced image processing and geometric correction capabilities. Scene based framing and not projected to a cartographic projection. |
| basic_analytic_b4 | Red Edge Band (Band4) of the Analytic Basic scene | RapidEye band 4 (Red Edge) scaled Top of Atmosphere Radiance (at sensor) and Sensor corrected, Basic Scene product designed for users with advanced image processing and geometric correction capabilities. Scene based framing and not projected to a cartographic projection. |
| basic_analytic_b4_nitf | Red Edge Band (Band4) of the Analytic Basic scene in the NITF format | RapidEye band 4 (Red Edge) scaled Top of Atmosphere Radiance (at sensor) and Sensor corrected, Basic Scene product in the NITF format, designed for users with advanced image processing and geometric correction capabilities. Scene based framing and not projected to a cartographic projection. |
| basic_analytic_b5 | NearInfrared Band (Band5) of the Analytic Basic scene | RapidEye band 5 (Near-infrared) scaled Top of Atmosphere Radiance (at sensor) and Sensor corrected, Basic Scene product designed for users with advanced image processing and geometric correction capabilities. Scene based framing and not projected to a cartographic projection. |
| basic_analytic_b5_nitf | Near Infrared Band (Band5) of the Analytic Basic scene in the NITF format | RapidEye band 5 (Near Infrared) scaled Top of Atmosphere Radiance (at sensor) and Sensorcorrected, Basic Scene product in the NITF format, designed for users with advanced image processing and geometric correction capabilities. Scene based framing and not projected to a cartographic projection. |
| basic_analytic_dn | Basic analytic digital number image | Unorthorectified non-radiometrically-calibrated analytic image stored as 12-bit digital numbers |
| basic_analytic_dn_rpc | RPC for basic analytic digital number image | Rational polynomial coefficients for unorthorectified non-radiometrically-calibrated analytic image |
| basic_analytic_rpc | Unprojected top of atmosphere radiance (4 Band) rational polynomial coefficients for rectification | Rational polynomial coefficients for unorthorectified analytic image |
| basic_analytic_sci | Spacecraft Information XML Metadata file | The RapidEye Spacecraft Information XML Metadata file. |
| basic_analytic_udm | Basic Analytic UDM | Unorthorectified unusable data mask |
| basic_analytic_udm2 | Basic Analytic UDM2 | Unorthorectified usable data mask (Cloud 2.0) |
| basic_analytic_xml | Basic analytic image metadata (4 Band) | Unorthorectified radiometrically-calibrated analytic image metadata |
| basic_analytic_xml_nitf | Basic analytic image metadata in NITF format | Unorthorectified radiometrically-calibrated analytic image metadata in NITF format |
| basic_beta_udm | Basic UDM | Unorthorectified usable data mask (in beta), in GeoTIFF format. |
| basic_l1a_panchromatic | Basic level 1A panchromatic scaled radiance image | Unorthorectified Radiometrically-calibrated panchromatic image stored as 16-bit scaled radiance |
| basic_l1a_panchromatic_rpc | RPC for Basic level 1A panchromatic scaled radiance image | Rational polynomial coefficients for Unorthorectified Radiometrically-calibrated panchromatic image |
| basic_l1a_panchromatic_dn | Basic level 1A panchromatic digital number image | Unorthorectified non-radiometrically-calibrated panchromatic image stored as 12-bit digital numbers |
| basic_l1a_panchromatic_dn_rpc | RPC for basic level 1A panchromatic digital number image | Rational polynomial coefficients for unorthorectified non-radiometrically-calibrated panchromatic image |
| basic_panchromatic | Basic Scene Panchromatic scaled radiance Image | Unorthorectified Radiometrically-calibrated panchromatic image stored as 16-bit scaled radiance |
| basic_panchromatic_dn | Basic Scene Panchromatic | This is a Basic Scene Panchromatic DN Image |
| basic_panchromatic_dn_rpc | Basic Panchromatic RPC File | This is a Basic Panchromatic DN RPC File |
| basic_panchromatic_rpc | Basic Panchromatic RPC File | Rational polynomial coefficients for unorthorectified panchromatic image |
| basic_panchromatic_udm2 | Basic Panchromatic UDM2 | Unorthorectified usable data mask (Cloud 2.0) |
| basic_radiance_hdf5 | Basic Top of Atmosphere Radiance | Unorthorectified, Top of atmosphere radiance (at sensor) calibrated, in HDF5 format. Not projected to a cartographic projection. |
| basic_sr_hdf5 | Basic Surface Reflectance | Unorthorectified, atmospherically corrected surface reflectance product, in HDF5 format. Not projected to a cartographic projection. |
| basic_udm | Basic UDM | Unorthorectified usable data mask |
| basic_udm2 | Unprojected UDM2 | Unorthorectified usable data mask (Cloud 2.0) Read more about this new asset here. |
| browse | Basic Scene browse image | Visual browse image for the Basic Scene product. |
| ql_ch4_json | Preliminary Plume Metadata | Preliminary plume locations, length, size in kg/hr and confidence measure indicating the level of visual interpretation certainty, in GeoJSON form at. |
| geolocation_array | Geolocation Array | Longitudes and Latitudes in WGS84 of centers of pixels, in GeoTIFF format. |
| ortho_analytic | Orthorectified Analytic Image | Orthorectified 16-bit 4-Band radiometrically corrected Image |
| ortho_analytic_3b | Orthorectified top of atmosphere radiance (3 Band) | Radiometrically-calibrated 3-band analytic image stored as 16-bit scaled radiance. |
| ortho_analytic_3b_xml | Orthorectified top of atmosphere radiance (3 Band) metadata | Radiometrically-calibrated analytic image metadata. |
| ortho_analytic_4b | Orthorectified top of atmosphere radiance (4 Band) | Radiometrically-calibrated 4-band analytic image stored as 16-bit scaled radiance. |
| ortho_analytic_4b_sr | Orthorectified atmospherically corrected surface reflectance (4 Band) | PlanetScope atmospherically corrected surface reflectance product. |
| ortho_analytic_4b_xml | Orthorectified atmospherically corrected surface reflectance (4 Band) metadata | Radiometrically-calibrated analytic image metadata. |
| ortho_analytic_8b | Orthorectified top of atmosphere radiance (8 Band) | Radiometrically-calibrated 8-band analytic image stored as 16-bit scaled radiance. |
| ortho_analytic_8b_sr | Orthorectified atmospherically corrected surface reflectance (8 Band) | PlanetScope atmospherically corrected surface reflectance product. |
| ortho_analytic_8b_xml | Orthorectified atmospherically corrected surface reflectance (8 Band) metadata | Radiometrically-calibrated analytic image metadata. |
| ortho_analytic_dn | Orthorectified Analytic Image | Orthorectified 16-bit 4-Band DN Image |
| ortho_analytic_sr | Atmospherically corrected surface reflectance product | Orthorectified product, radiometrically calibrated and atmospherically corrected to surface reflectance |
| ortho_analytic_udm | Orthorectified Analytic UDM | Orthorectified 16-bit 4-Band DN Image Unuseable Data Mask |
| ortho_analytic_udm2 | Ortho Analytic UDM2 | Orthorectified usable data mask (Cloud 2.0) |
| ortho_beta_udm | Orthorectified UDM | Orthorectified usable data mask (in beta), in GeoTIFF format. |
| ortho_ql_ch4 | Preliminary Plume Intensity | Preliminary 8-bit scaled methane plume intensity in (ppm-m) parts-per-million-meter, in GeoTIFF format. The image will contain an alpha channel indicating pixels with no plume detections. |
| ortho_panchromatic | Orthorectified Panchromatic scaled radiance Image | Orthorectified Radiometrically-calibrated panchromatic image stored as 16-bit scaled radiance |
| ortho_panchromatic_dn | Orthorectified Panchromatic Image | Orthorectified 16-bit 1-band Image |
| ortho_panchromatic_udm | Orthorectified Panchromatic UDM | Orthorectified 16-bit 1-band Image Unuseable Data Mask |
| ortho_panchromatic_udm2 | Ortho Panchromatic UDM2 | Unorthorectified usable data mask (Cloud 2.0) |
| ortho_pansharpened | Orthorectified Pansharpened Image | Orthorectified 16-bit 4-band Pansharpened Image |
| ortho_pansharpened_udm | Orthorectified Pansharpened UDM | Orthorectified 16-bit 4-band Pansharpened Image Unuseable Data Mask |
| ortho_pansharpened_udm2 | Ortho Pansharpened UDM2 | Orthorectified usable data mask (Cloud 2.0) |
| ortho_radiance_hdf5 | Orthorectified Top of Atmosphere Radiance | Orthorectified, Top of atmosphere radiance (at sensor) calibrated, in HDF5 format. |
| ortho_sr_hdf5 | Orthorectified Surface Reflectance | Orthorectified, atmospherically corrected surface reflectance product, in HDF5 format. |
| ortho_udm2 | Orthorectified UDM2 | Usable data mask (Cloud 2.0) |
| ortho_visual | Orthorectified color corrected visual image product (3 Band) | Visual image with color-correction |
| recent_monthly_mosaic | Recent Monthly Mosaic | RGB contextual baselayer from the most recent PlanetScope Global Monthly Mosaic, in GeoTIFF format. |
| udm | UDM | Usable data mask |
| video_file | mp4 video file | Video mp4 file of all overlapping basic l1a panchromatic frames |
| video_frames | Zip file containing all video frames and RPCs | Compressed folder with all basic l1a panchromatic frames and accompanying RPCs that make up the video file |
| video_metadata | video metadata | JSON document describing the composite location of the video capture, as well as time, elevation angle, and azimuth angle at the start and end of the colle |
| ction | ||
| visual | Visual image (3 Band) | Visual image with color-correction |
| visual_xml | Visual image metadata | Visual image metadata |
Finding Assets
From a conversation with the Planet AI:
I'm working on a free trial. I'm trying to test the API for getting assets. I make a GET request to https://api.planet.com/data/v1/item-types/PSScene/items/20260609_022123_81_2562/assets/ HTTP/2.0. I get back a status 200 and an empty response. What does that mean?
A 200 response with an empty body from the /assets endpoint almost always means your account does not have download permissions for that item. Assets empty response
How to confirm
Make a GET request to the item itself (without /assets):
GET https://api.planet.com/data/v1/item-types/PSScene/items/20260609_022123_81_2562/
In the response, check the _permissions and assets fields:
If _permissions is empty ([]), your account does not have download access to this item.
If _permissions lists entries like "assets.ortho_analytic_4b:download", you do have access.
What to do on a free trial
On a free trial, your download permissions are limited. To find items you do have access to, use the Planet Python SDK with the permission filter, which ensures search results only include items you can download:
planet data filter | planet data search PSScene
Or in Python, use the permission_filter when searching. Assets empty response
In short: the empty response is not a bug — it reflects that your trial account lacks download permissions for that specific scene.
Answer based on the following sources:
Assets link returning empty content? Data API community.planet.com/data-access-and-management-apis-99
Items and Assets in the Data API docs.planet.com/develop
Is there somewhere I can see the list of valid permissions to use in the filter?
The knowledge sources do not contain enough information to provide a complete list of valid permission values for the PermissionFilter. However, based on what is shown in the knowledge sources, the documented permission values are:
assets:download — matches any downloadable asset [Permission Filters](https://docs.planet.com/develop/apis/data/item-search/#permission-filters)
assets.<asset_type>:download — matches a specific asset type, for example assets.analytic:download or assets.ortho_analytic_4b:download [Data API Introduction](https://github.com/planetlabs/notebooks/blob/master/jupyter-notebooks/api_guides/data_api/planet_data_api_introduction.ipynb)
For a full list of valid asset types (which can be used in the assets.<asset_type>:download pattern), the knowledge sources point to the Item Types pages in the Planet docs — for example, the PSScene asset types page lists all available assets for that item type. Filter by asset
For the most authoritative and complete reference, I'd recommend checking the Data API reference documentation directly, as the knowledge sources don't include an exhaustive enumeration of all valid permission strings.
Searching
Quick Search
The SearchRequest struct supports all the filter types below. Pass a filter as the Filter field—the JSON serialization matches the Planet Data API exactly.
client, _ := planet.NewClient()
ctx := context.Background()
req := planet.SearchRequest{
ItemTypes: []string{"PSScene"},
Filter: planet.AndFilter{
Type: "AndFilter",
Config: []any{
planet.DateRangeFilter{
Type: "DateRangeFilter", FieldName: "acquired",
Config: planet.DateRangeConfig{
GTE: "2024-01-01T00:00:00Z",
LTE: "2024-01-31T00:00:00Z",
},
},
planet.StringInFilter{
Type: "StringInFilter", FieldName: "quality_category",
Config: []string{"standard"},
},
planet.RangeFilter{
Type: "RangeFilter", FieldName: "cloud_cover",
Config: planet.RangeConfig{LTE: ptr(0.1)},
},
planet.AssetFilter{
Type: "AssetFilter", Config: []string{"ortho_analytic_8b"},
},
planet.PermissionFilter{
Type: "PermissionFilter", Config: []string{"assets:download"},
},
},
},
}
resp, err := doPost[planet.SearchRequest, planet.SearchResponse](ctx, *client, "data/v1/quick-search", req)
Filter Types
DateRangeFilter
Filter by timestamp properties (acquired, published, updated).
planet.DateRangeFilter{
Type: "DateRangeFilter",
FieldName: "acquired",
Config: planet.DateRangeConfig{
GT: "2023-12-31T00:00:00Z",
LTE: "2024-01-31T00:00:00Z",
},
}
GeometryFilter
Filter by geographic footprint. Config accepts any GeoJSON-serializable struct. Use the Relation field to control the spatial predicate (intersects, contains, within, disjoint).
// Point
planet.GeometryFilter{
Type: "GeometryFilter",
FieldName: "geometry",
Config: planet.PointGeo{Type: "Point", Coordinates: []float64{-122.4, 37.8}},
}
// Polygon
planet.GeometryFilter{
Type: "GeometryFilter",
FieldName: "geometry",
Relation: planet.RelationContains,
Config: planet.PolygonGeo{
Type: "Polygon",
Coordinates: [][][]float64{{{
{-120.27, 38.34},
{-120.27, 38.74},
{-119.76, 38.74},
{-119.76, 38.34},
{-120.27, 38.34},
}}},
},
}
// Features API reference (as the search geometry, not the filter)
planet.SearchRequest{
ItemTypes: []string{"PSScene"},
Filter: ...,
Geometry: planet.FeatureRef{Type: "ref", Content: "pl:features/my/collection-id/feature-id"},
}
RangeFilter
Filter by numeric properties (cloud_cover, view_angle, gsd, etc.). Pointers distinguish 0 from "not set".
func ptr(v float64) *float64 { return &v }
// cloud_cover <= 0.1
planet.RangeFilter{
Type: "RangeFilter", FieldName: "cloud_cover",
Config: planet.RangeConfig{LTE: ptr(0.1)},
}
// 0.5 <= gsd <= 3.0
planet.RangeFilter{
Type: "RangeFilter", FieldName: "gsd",
Config: planet.RangeConfig{GTE: ptr(0.5), LTE: ptr(3.0)},
}
NumberInFilter
Match exact numeric values.
planet.NumberInFilter{
Type: "NumberInFilter", FieldName: "gsd",
Config: []float64{0.5, 3.0},
}
StringInFilter
Match string or boolean properties. Multiple values are OR'd.
// quality_category is 'standard' or 'test'
planet.StringInFilter{
Type: "StringInFilter", FieldName: "quality_category",
Config: []string{"standard", "test"},
}
// Boolean property: ground_control is true
planet.StringInFilter{
Type: "StringInFilter", FieldName: "ground_control",
Config: []string{"true"},
}
UpdateFilter
Match items where a property changed on or after a date (republishing events).
planet.UpdateFilter{
Type: "UpdateFilter", FieldName: "ground_control",
Config: planet.DateRangeConfig{GT: "2020-04-15T00:00:00Z"},
}
AssetFilter
Match items that have published specific asset types.
planet.AssetFilter{
Type: "AssetFilter",
Config: []string{"ortho_analytic_8b", "ortho_analytic_4b_sr"},
}
// Require BOTH assets (use AndFilter)
planet.AndFilter{
Type: "AndFilter",
Config: []any{
planet.AssetFilter{Type: "AssetFilter", Config: []string{"analytic_sr"}},
planet.AssetFilter{Type: "AssetFilter", Config: []string{"udm2"}},
},
}
PermissionFilter
Limit results to items you can download. Must be combined with other filters.
planet.PermissionFilter{
Type: "PermissionFilter",
Config: []string{"assets:download"},
}
Logical Filters: AndFilter, OrFilter, NotFilter
Combine filters for complex criteria.
// All conditions must match (typical top-level filter)
planet.AndFilter{
Type: "AndFilter",
Config: []any{
planet.DateRangeFilter{...},
planet.RangeFilter{...},
planet.AssetFilter{...},
planet.PermissionFilter{...},
},
}
// At least one condition must match
planet.OrFilter{
Type: "OrFilter",
Config: []any{
planet.RangeFilter{Type: "RangeFilter", FieldName: "visible_percent", Config: planet.RangeConfig{GTE: ptr(90)}},
planet.RangeFilter{Type: "RangeFilter", FieldName: "usable_data", Config: planet.RangeConfig{GTE: ptr(0.9)}},
},
}
// Negate a single filter
planet.NotFilter{
Type: "NotFilter",
Config: planet.StringInFilter{
Type: "StringInFilter", FieldName: "quality_category",
Config: []string{"test"},
},
}
Orders
Create an Order
Orders request the Planet platform to produce assets (clipped, reprojected, etc.) for one or more items or mosaics.
client, _ := planet.NewClient()
ctx := context.Background()
order, err := client.CreateOrder(ctx, planet.OrderRequest{
Name: "my-scene-order",
SourceType: planet.SourceTypeScenes,
Products: []planet.OrderProduct{{
ItemIDs: []string{"20260609_022123_81_2562"},
ItemType: "PSScene",
ProductBundle: planet.BundleAnalyticUDM2,
}},
})
With clip tool
Clip the output to an AOI geometry:
order, err := client.CreateOrder(ctx, planet.OrderRequest{
Name: "clipped-scene",
SourceType: planet.SourceTypeScenes,
Products: []planet.OrderProduct{{
ItemIDs: []string{"20260609_022123_81_2562"},
ItemType: "PSScene",
ProductBundle: planet.BundleAnalyticUDM2,
}},
Tools: map[string]any{
"clip": planet.ClipToolAOI(planet.PointGeo{
Type: "Point", Coordinates: []float64{-122.4, 37.8},
}),
},
})
With TOAR and reproject tools
order, err := client.CreateOrder(ctx, planet.OrderRequest{
Name: "reprojected-scene",
SourceType: planet.SourceTypeScenes,
Products: []planet.OrderProduct{{
ItemIDs: []string{"20260609_022123_81_2562"},
ItemType: "PSScene",
ProductBundle: planet.BundleAnalyticUDM2,
}},
Tools: map[string]any{
"toar": planet.TOARToolConfig(10000),
"reproject": planet.ReprojectToolConfig("EPSG:4326", "cubic"),
},
})
Cloud delivery (GCS)
order, err := client.CreateOrder(ctx, planet.OrderRequest{
Name: "gcs-order",
SourceType: planet.SourceTypeScenes,
Products: []planet.OrderProduct{{
ItemIDs: []string{"20260609_022123_81_2562"},
ItemType: "PSScene",
ProductBundle: planet.BundleAnalyticUDM2,
}},
Delivery: &planet.OrderDelivery{
GoogleCloudStorage: &planet.GCSDestination{
Bucket: "my-bucket",
Credentials: "{...service-account-json...}",
},
},
})
Hosting on Sentinel Hub
order, err := client.CreateOrder(ctx, planet.OrderRequest{
Name: "hosted-order",
SourceType: planet.SourceTypeScenes,
Products: []planet.OrderProduct{{
ItemIDs: []string{"20260609_022123_81_2562"},
ItemType: "PSScene",
ProductBundle: planet.BundleAnalyticSRUDM2,
}},
Hosting: &planet.OrderHosting{
SentinelHub: &planet.SentinelHubHosting{},
},
})
Basemaps order (by geometry)
order, err := client.CreateOrder(ctx, planet.OrderRequest{
Name: "mosaic-order",
SourceType: planet.SourceTypeBasemaps,
Products: []planet.OrderProduct{{
MosaicName: "global_monthly_2022_01_mosaic",
Geometry: planet.PolygonGeo{
Type: "Polygon",
Coordinates: [][][]float64{{{
{4.607406, 52.353994},
{4.680005, 52.353994},
{4.680005, 52.395523},
{4.607406, 52.395523},
{4.607406, 52.353994},
}}},
},
}},
})
Basemaps order (by quad IDs)
order, err := client.CreateOrder(ctx, planet.OrderRequest{
Name: "mosaic-by-quads",
SourceType: planet.SourceTypeBasemaps,
Products: []planet.OrderProduct{{
MosaicName: "global_monthly_2022_01_mosaic",
QuadIDs: []string{"1050-1374", "1050-1375"},
}},
})
Wait and Download
Orders process asynchronously. Use WaitForOrder to poll until completion, then download each result:
// Wait for the order to finish (polls every 10 seconds)
order, err = client.WaitForOrder(ctx, order.ID, 10*time.Second)
if err != nil {
log.Fatal(err)
}
// Download each output asset
for i, result := range order.Results {
if result.Delivery != "success" {
continue
}
body, err := client.DownloadOrderResult(ctx, result.Location)
if err != nil {
log.Printf("download %s: %v", result.Name, err)
continue
}
defer body.Close()
f, err := os.Create(result.Name)
if err != nil {
log.Fatal(err)
}
defer f.Close()
io.Copy(f, body)
fmt.Printf("downloaded %s\n", result.Name)
}
Manage Orders
// Get a single order
order, err := client.GetOrder(ctx, "order-id-here")
// List all orders (last 3 months)
orders, err := client.ListOrders(ctx, planet.ListOrdersParams{
State: planet.OrderStateSuccess,
SortBy: "created_on DESC",
Limit: 10,
})
// List all orders in a specific state
orders, err = client.ListOrders(ctx, planet.ListOrdersParams{
SourceType: planet.SourceTypeScenes,
State: planet.OrderStateQueued,
})
// Cancel a queued order
err = client.CancelOrder(ctx, "order-id-here")
// Bulk cancel specific orders
result, err := client.BulkCancelOrders(ctx, []string{"order-1", "order-2"})
fmt.Printf("cancelled %d, failed %d\n", result.Cancelled, result.Failed)
// Bulk cancel all queued orders
result, err = client.BulkCancelAllQueued(ctx)
// Get aggregated order stats
stats, err := client.GetOrderStats(ctx)
fmt.Printf("queued: user=%d org=%d\n", stats.User.Queued, stats.Organization.Queued)