Skip to content

Instantly share code, notes, and snippets.

@joakimsk
Last active July 16, 2021 02:52
Show Gist options
  • Save joakimsk/2e387cc54932e6db1b325811ca978763 to your computer and use it in GitHub Desktop.
Save joakimsk/2e387cc54932e6db1b325811ca978763 to your computer and use it in GitHub Desktop.
PlanetScope data to QGIS

PlanetScope data to QGIS

https://medium.com/planet-stories/a-gentle-introduction-to-gdal-part-4-working-with-satellite-data-d3835b5e2971 A typical workflow to create an image from raw satellite data would be:

  1. Download data.
  2. Re-order or assemble bands into the desired order (red, green, blue; or near-infrared, red, green; etc.)
  3. Increase the resolution with pan-sharpening, if desired.
  4. Contrast-stretch and color-correct the imagery, either algorithmically or by hand.
  5. Restore georeferencing information, if necessary.
  6. Crop, re-project, and re-size image to merge with other data.

Joakim tries

gdalinfo 20170717_015226_1027_1B_AnalyticMS.tif

https://www.planet.com/docs/spec-sheets/sat-imagery/ Our data is Analytic Ortho, 4 band. (near-infrared, red, green, blue)

We get a lot of info. Bands are all 16 bit:

  1. R
  2. G
  3. B
  4. Undefined

Let us try reorder the bands, B G R:

gdal_translate 20170717_015226_1027_1B_AnalyticMS.tif 20170717_015226_1027_1B_AnalyticMS_rgb2.tif -b 3 -b 2 -b 1 -co COMPRESS=DEFLATE -co PHOTOMETRIC=RGB

Eeeh, dark, we need to stretch data. Read statistics: gdalinfo -mm 20170717_015226_1027_1B_AnalyticMS_rgb.tif

Band 1 Block=6600x1 Type=UInt16, ColorInterp=Red Computed Min/Max=1028.000,26802.000 NoData Value=0 Band 2 Block=6600x1 Type=UInt16, ColorInterp=Green Computed Min/Max=1941.000,21155.000 NoData Value=0 Band 3 Block=6600x1 Type=UInt16, ColorInterp=Blue Computed Min/Max=1683.000,28808.000 NoData Value=0

Then stretch to fill data, we see lowest and highest number: 1028 28808

gdal_translate 20170717_015226_1027_1B_AnalyticMS_rgb.tif 20170717_015226_1027_1B_AnalyticMS_rgb_scaled.tif -scale 1028 28808 0 65535 -exponent 0.5 -co COMPRESS=DEFLATE -co PHOTOMETRIC=RGB

There we have it, can see what is there, almost.

Try to set projection

gdal_translate -a_srs EPSG:32750 20170717_015226_1027_1B_AnalyticMS_rgb_scaled.tif out.tif

gdal_translate 20170717_015226_1027_1B_AnalyticMS.tif outgeotiff.tif -a_srs EPSG:32750

References

https://www.mapbox.com/help/processing-satellite-imagery/ https://www.planet.com/products/satellite-imagery/files/1610.06_Spec%20Sheet_Combined_Imagery_Product_Letter_ENGv1.pdf https://www.youtube.com/watch?v=5c7-KJoPle0&feature=player_embedded https://www.planet.com/pulse/color-correction/ https://support.planet.com/hc/en-us/articles/211459138--Using-Planet-GeoTIFFs-in-QGIS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment