{"_id":"5ac66419ec5e4e005de8e28a","project":"55faeacad0e22017005b8265","version":{"_id":"55faeacad0e22017005b8268","project":"55faeacad0e22017005b8265","__v":36,"createdAt":"2015-09-17T16:31:06.800Z","releaseDate":"2015-09-17T16:31:06.800Z","categories":["55faeacbd0e22017005b8269","55faf550764f50210095078e","55faf5b5626c341700fd9e96","55faf8a7825d5f19001fa386","560052f91503430d007cc88f","560054f73aa0520d00da0b1a","56005aaf6932a00d00ba7c62","56005c273aa0520d00da0b3f","5601ae7681a9670d006d164d","5601ae926811d00d00ceb487","5601aeb064866b1900f4768d","5601aee850ee460d0002224c","5601afa02499c119000faf19","5601afd381a9670d006d1652","561d4c78281aec0d00eb27b6","561d588d8ca8b90d00210219","563a5f934cc3621900ac278c","5665c5763889610d0008a29e","566710a36819320d000c2e93","56ddf6df8a5ae10e008e3926","56e1c96b2506700e00de6e83","56e1ccc4e416450e00b9e48c","56e1ccdfe63f910e00e59870","56e1cd10bc46be0e002af26a","56e1cd21e416450e00b9e48e","56e3139a51857d0e008e77be","573b4f62ef164e2900a2b881","57c9d1335fd8ca0e006308ed","57e2bd9d1e7b7220000d7fa5","57f2b992ac30911900c7c2b6","58adb5c275df0f1b001ed59b","58c81b5c6dc7140f003c3c46","595412446ed4d9001b3e7b37","59e76ce41938310028037295","5a009de510890d001c2aabfe","5a96f89c89442e002041144b"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"v1","version_clean":"1.0.0","version":"1"},"category":{"_id":"5ac2956b2e75480053d84c36","project":"55faeacad0e22017005b8265","version":"55faeacad0e22017005b8268","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2018-04-02T20:41:15.403Z","from_sync":false,"order":4,"slug":"raster-data-access-guide","title":"Raster Data Access (RDA) Guide"},"user":"55fae9d4825d5f19001fa379","__v":0,"parentDoc":null,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2018-04-05T17:59:53.768Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":3,"body":"# How to Get GDAL with the RDA Driver\n\nTo get get GDAL with the RDA driver, see [How to Get the GDAL RDA Driver](doc:how-to-get-the-rda-gdal-driver) \n\nThe GDAL 2.3.0 release will include the RDA driver. GDAL 2.3.0 is currently a pre-release version, and is not fully supported. \n\nFor more information, see [RDA GDAL Driver](http://www.gdal.org/frmt_rda.html).  \n\n# Quickstart Tutorial\nThis tutorial illustrates how to get an image chip with GDAL, the RDA Template API, and the DigitalGlobeStrip template.\n\n## Sample Image\nFor this tutorial, we'll be using image 10400E0001DB6A00.  The whole strip looks like this:\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/7392413-RDA_full_strip_image_1.png\",\n        \"RDA_full_strip_image_1.png\",\n        1752,\n        1456,\n        \"#9f9694\"\n      ],\n      \"caption\": \"Image 1: This is the original image used in the example.\"\n    }\n  ]\n}\n[/block]\n## Get image metadata\nThe command [gdalinfo](http://www.gdal.org/gdalinfo.html) prints out general image information:\n```\ngdalinfo '{\"template-id\": \"DigitalGlobeStrip\", \"params\": [{\"crs\": \"EPSG:4326\", \"bands\": \"MS\", \"catalogId\": \"10400E0001DB6A00\", \"draType\": \"None\", \"correctionType\": \"DN\", \"bandSelection\": \"All\"}]}'\n```\n\nThe results of the gdalinfo command:\n\n```\nDriver: RDA/DigitalGlobe Raster Data Access driver\nFiles: none associated\nSize is 12622, 10605\nCoordinate System is:\nGEOGCS[\"WGS 84\",\n    DATUM[\"WGS_1984\",\n        SPHEROID[\"WGS 84\",6378137,298.257223563,\n            AUTHORITY[\"EPSG\",\"7030\"]],\n        AUTHORITY[\"EPSG\",\"6326\"]],\n    PRIMEM[\"Greenwich\",0,\n        AUTHORITY[\"EPSG\",\"8901\"]],\n    UNIT[\"degree\",0.0174532925199433,\n        AUTHORITY[\"EPSG\",\"9122\"]],\n    AUTHORITY[\"EPSG\",\"4326\"]]\nOrigin = (36.866078880000003,33.977969486180378)\nPixel Size = (0.000011606180381,-0.000011606180381)\nImage Structure Metadata:\n  INTERLEAVE=PIXEL\nCorner Coordinates:\nUpper Left  (  36.8660789,  33.9779695) ( 36d51'57.88\"E, 33d58'40.69\"N)\nLower Left  (  36.8660789,  33.8548859) ( 36d51'57.88\"E, 33d51'17.59\"N)\nUpper Right (  37.0125721,  33.9779695) ( 37d 0'45.26\"E, 33d58'40.69\"N)\nLower Right (  37.0125721,  33.8548859) ( 37d 0'45.26\"E, 33d51'17.59\"N)\nCenter      (  36.9393255,  33.9164277) ( 36d56'21.57\"E, 33d54'59.14\"N)\nBand 1 Block=256x256 Type=UInt16, ColorInterp=Undefined\nBand 2 Block=256x256 Type=UInt16, ColorInterp=Undefined\nBand 3 Block=256x256 Type=UInt16, ColorInterp=Undefined\nBand 4 Block=256x256 Type=UInt16, ColorInterp=Undefined\nBand 5 Block=256x256 Type=UInt16, ColorInterp=Undefined\nBand 6 Block=256x256 Type=UInt16, ColorInterp=Undefined\nBand 7 Block=256x256 Type=UInt16, ColorInterp=Undefined\nBand 8 Block=256x256 Type=UInt16, ColorInterp=Undefined\n```\n\n## Get a chip using a pixel-based window\nThe [gdal_translate](http://www.gdal.org/gdal_translate.html) command allows you to transform the image and write out the transformed image.  We will transform the image by selecting a subset of the image based on a pixel window.  Our pixel window is the 2048x2048 pixel square in the upper-left corner of the image.  The window is shown below in green:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/8255b1a-RDA_GDAL_srcwin_footprint-image2.png\",\n        \"RDA GDAL srcwin_footprint-image2.png\",\n        1746,\n        1460,\n        \"#9f9694\"\n      ],\n      \"caption\": \"Image 2: The green square indicates the subset of the image selected based on a pixel window.\"\n    }\n  ]\n}\n[/block]\nThe gdal_translate command to get this window (in tif format) is:\n```\ngdal_translate -srcwin 0 0 2048 2048 '{\"template-id\": \"DigitalGlobeStrip\", \"params\": [{\"crs\": \"EPSG:4326\", \"bands\": \"MS\", \"catalogId\": \"10400E0001DB6A00\", \"draType\": \"None\", \"correctionType\": \"DN\", \"bandSelection\": \"All\"}]}' srcwin.tif\n```\n\nThe resulting image chip looks like this:\n\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/bdf077e-RDA_GDAL_srcwin_example-image3.png\",\n        \"RDA GDAL srcwin_example-image3.png\",\n        1470,\n        1433,\n        \"#836c63\"\n      ],\n      \"caption\": \"Image 3: This is the resulting image chip.\"\n    }\n  ]\n}\n[/block]\n## Get a chip using a map-projected window\nThe gdal_translate command also allows you  to specify a window in the projection system of the image (in this case Lat/Long WGS84 or EPSG:4326).  An example projected window is shown below in blue:\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/b909a83-RDA_GDAL-prjwin_footprint-image4.png\",\n        \"RDA GDAL-prjwin_footprint-image4.png\",\n        1742,\n        1448,\n        \"#9f9694\"\n      ],\n      \"caption\": \"Image 4: The blue square shows the example projected window.\"\n    }\n  ]\n}\n[/block]\nThe gdal_translate command to get this projected window as a tif is:\n```\ngdal_translate -projwin 36.9393 33.9164 36.9433 33.9124 '{\"template-id\": \"DigitalGlobeStrip\", \"params\": [{\"crs\": \"EPSG:4326\", \"bands\": \"MS\", \"catalogId\": \"10400E0001DB6A00\", \"draType\": \"None\", \"correctionType\": \"DN\", \"bandSelection\": \"All\"}]}' prjwin.tif\n```\n\nThe resulting image chip looks like:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/3a50e8c-RDA_GDAL_prjwin_example-image5.png\",\n        \"RDA GDAL prjwin_example-image5.png\",\n        1470,\n        1454,\n        \"#c3c6cd\"\n      ],\n      \"caption\": \"Image 5: This is the resulting image chip from the projected window.\"\n    }\n  ]\n}\n[/block]\n## Image processing options supported by DigitalGlobeStrip template\nThe DigitalGlobeStrip template used in this tutorial supports many of the common image processing options required to peform analytics on DigitalGlobe imagery including orthorectification to various projection systems, atomoshpheric compensation, pan-sharpening, band selection, and dynamic-range adjustment.  The processing options are set by changing the values for the 'params' in the gdal connection string.  Here are some example connections strings that demonstrate the different processing options:\n\n### Map projection\nSpecify the map projection to use during orthorectification by setting the 'crs' parameter to a valid EPSG map projection code.\n\nWeb-mercator map projection:\n```\n'{\"template-id\": \"DigitalGlobeStrip\", \"params\": [{\"crs\": \"EPSG:3857\", \"bands\": \"MS\", \"catalogId\": \"10400E0001DB6A00\", \"draType\": \"None\", \"correctionType\": \"DN\", \"bandSelection\": \"All\"}]}'\n```\n\nUTM is a special case where we will automatically find the most appropriate UTM zone if you specify 'UTM' for the 'crs' parameter:\n```\n'{\"template-id\": \"DigitalGlobeStrip\", \"params\": [{\"crs\": \"UTM\", \"bands\": \"MS\", \"catalogId\": \"10400E0001DB6A00\", \"draType\": \"None\", \"correctionType\": \"DN\", \"bandSelection\": \"All\"}]}'\n```\n\n### Atmospheric correction\nThe atmospheric correction options include 'DN' (no correction, pixels values are raw DN values), 'TOA' (top-of-atmoshpere reflectance), and 'AComp' (surface reflectance).  The previous examples demonstrate 'DN'.  For Acomp use:\n```\n'{\"template-id\": \"DigitalGlobeStrip\", \"params\": [{\"crs\": \"EPSG:3857\", \"bands\": \"MS\", \"catalogId\": \"10400E0001DB6A00\", \"draType\": \"None\", \"correctionType\": \"DN\", \"bandSelection\": \"All\"}]}'\n```\n\n### Panchromatic, multispectral, swir, and pan-sharpened multispectral output\nThe bands combination to process is specified by setting the 'bands' parameter.  Valid options are 'PAN', 'MS', 'SWIR', and 'Pansharp'.  'PAN', 'MS', and 'SWIR' select the panchromatic (one band), multispectral (4 or 8 bands depending on satellite), and short-wave infrared bands (8 band) respectively.  Not all satellites support all options.  For example the WorldView 1 satellite only support 'PAN' since it only has a panchromatic sensor.  Only swir images shot using WorldView 3 support the 'SWIR' option.\n\n### Dynamic range adjustment\nThe 'draType' parameters controls weather or not DRA is applied.  Current options are \"None\" (for no-dra) and \"HistogramDRA\".  \"HistogramDRA\" will apply RDA's default DRA (linear histogram stretch with clip and gamma adjustment).\n\n### Band Selection\nThe 'bandSelection' parameters controls which bands are included in the image.  Options are 'All' for all available bands and 'RGB' for true-color (red-green-blue) only.\n\n# Additional Resources\nTo learn more about RDA, see the [Raster Data Access (RDA) Course](doc:raster-data-access-course).\n\nTo see a quickstart tutorial for getting an image chip using gbdxtools, see [Quickstart tutorial with gbdxtools](https://gbdxdocs.digitalglobe.com/v1/docs/raster-data-access-course#section-quickstart-tutorial-for-getting-an-rda-chip-using-gbdxtools).","excerpt":"This tutorial describes how to get an RDA chip using GDAL, the RDA Template API, and the DigitalGlobeStrip template.","slug":"how-to-get-a-chip-with-gdal","type":"basic","title":"How to Get a Chip with GDAL and the RDA Template API"}

How to Get a Chip with GDAL and the RDA Template API

This tutorial describes how to get an RDA chip using GDAL, the RDA Template API, and the DigitalGlobeStrip template.

# How to Get GDAL with the RDA Driver To get get GDAL with the RDA driver, see [How to Get the GDAL RDA Driver](doc:how-to-get-the-rda-gdal-driver) The GDAL 2.3.0 release will include the RDA driver. GDAL 2.3.0 is currently a pre-release version, and is not fully supported. For more information, see [RDA GDAL Driver](http://www.gdal.org/frmt_rda.html). # Quickstart Tutorial This tutorial illustrates how to get an image chip with GDAL, the RDA Template API, and the DigitalGlobeStrip template. ## Sample Image For this tutorial, we'll be using image 10400E0001DB6A00. The whole strip looks like this: [block:image] { "images": [ { "image": [ "https://files.readme.io/7392413-RDA_full_strip_image_1.png", "RDA_full_strip_image_1.png", 1752, 1456, "#9f9694" ], "caption": "Image 1: This is the original image used in the example." } ] } [/block] ## Get image metadata The command [gdalinfo](http://www.gdal.org/gdalinfo.html) prints out general image information: ``` gdalinfo '{"template-id": "DigitalGlobeStrip", "params": [{"crs": "EPSG:4326", "bands": "MS", "catalogId": "10400E0001DB6A00", "draType": "None", "correctionType": "DN", "bandSelection": "All"}]}' ``` The results of the gdalinfo command: ``` Driver: RDA/DigitalGlobe Raster Data Access driver Files: none associated Size is 12622, 10605 Coordinate System is: GEOGCS["WGS 84", DATUM["WGS_1984", SPHEROID["WGS 84",6378137,298.257223563, AUTHORITY["EPSG","7030"]], AUTHORITY["EPSG","6326"]], PRIMEM["Greenwich",0, AUTHORITY["EPSG","8901"]], UNIT["degree",0.0174532925199433, AUTHORITY["EPSG","9122"]], AUTHORITY["EPSG","4326"]] Origin = (36.866078880000003,33.977969486180378) Pixel Size = (0.000011606180381,-0.000011606180381) Image Structure Metadata: INTERLEAVE=PIXEL Corner Coordinates: Upper Left ( 36.8660789, 33.9779695) ( 36d51'57.88"E, 33d58'40.69"N) Lower Left ( 36.8660789, 33.8548859) ( 36d51'57.88"E, 33d51'17.59"N) Upper Right ( 37.0125721, 33.9779695) ( 37d 0'45.26"E, 33d58'40.69"N) Lower Right ( 37.0125721, 33.8548859) ( 37d 0'45.26"E, 33d51'17.59"N) Center ( 36.9393255, 33.9164277) ( 36d56'21.57"E, 33d54'59.14"N) Band 1 Block=256x256 Type=UInt16, ColorInterp=Undefined Band 2 Block=256x256 Type=UInt16, ColorInterp=Undefined Band 3 Block=256x256 Type=UInt16, ColorInterp=Undefined Band 4 Block=256x256 Type=UInt16, ColorInterp=Undefined Band 5 Block=256x256 Type=UInt16, ColorInterp=Undefined Band 6 Block=256x256 Type=UInt16, ColorInterp=Undefined Band 7 Block=256x256 Type=UInt16, ColorInterp=Undefined Band 8 Block=256x256 Type=UInt16, ColorInterp=Undefined ``` ## Get a chip using a pixel-based window The [gdal_translate](http://www.gdal.org/gdal_translate.html) command allows you to transform the image and write out the transformed image. We will transform the image by selecting a subset of the image based on a pixel window. Our pixel window is the 2048x2048 pixel square in the upper-left corner of the image. The window is shown below in green: [block:image] { "images": [ { "image": [ "https://files.readme.io/8255b1a-RDA_GDAL_srcwin_footprint-image2.png", "RDA GDAL srcwin_footprint-image2.png", 1746, 1460, "#9f9694" ], "caption": "Image 2: The green square indicates the subset of the image selected based on a pixel window." } ] } [/block] The gdal_translate command to get this window (in tif format) is: ``` gdal_translate -srcwin 0 0 2048 2048 '{"template-id": "DigitalGlobeStrip", "params": [{"crs": "EPSG:4326", "bands": "MS", "catalogId": "10400E0001DB6A00", "draType": "None", "correctionType": "DN", "bandSelection": "All"}]}' srcwin.tif ``` The resulting image chip looks like this: [block:image] { "images": [ { "image": [ "https://files.readme.io/bdf077e-RDA_GDAL_srcwin_example-image3.png", "RDA GDAL srcwin_example-image3.png", 1470, 1433, "#836c63" ], "caption": "Image 3: This is the resulting image chip." } ] } [/block] ## Get a chip using a map-projected window The gdal_translate command also allows you to specify a window in the projection system of the image (in this case Lat/Long WGS84 or EPSG:4326). An example projected window is shown below in blue: [block:image] { "images": [ { "image": [ "https://files.readme.io/b909a83-RDA_GDAL-prjwin_footprint-image4.png", "RDA GDAL-prjwin_footprint-image4.png", 1742, 1448, "#9f9694" ], "caption": "Image 4: The blue square shows the example projected window." } ] } [/block] The gdal_translate command to get this projected window as a tif is: ``` gdal_translate -projwin 36.9393 33.9164 36.9433 33.9124 '{"template-id": "DigitalGlobeStrip", "params": [{"crs": "EPSG:4326", "bands": "MS", "catalogId": "10400E0001DB6A00", "draType": "None", "correctionType": "DN", "bandSelection": "All"}]}' prjwin.tif ``` The resulting image chip looks like: [block:image] { "images": [ { "image": [ "https://files.readme.io/3a50e8c-RDA_GDAL_prjwin_example-image5.png", "RDA GDAL prjwin_example-image5.png", 1470, 1454, "#c3c6cd" ], "caption": "Image 5: This is the resulting image chip from the projected window." } ] } [/block] ## Image processing options supported by DigitalGlobeStrip template The DigitalGlobeStrip template used in this tutorial supports many of the common image processing options required to peform analytics on DigitalGlobe imagery including orthorectification to various projection systems, atomoshpheric compensation, pan-sharpening, band selection, and dynamic-range adjustment. The processing options are set by changing the values for the 'params' in the gdal connection string. Here are some example connections strings that demonstrate the different processing options: ### Map projection Specify the map projection to use during orthorectification by setting the 'crs' parameter to a valid EPSG map projection code. Web-mercator map projection: ``` '{"template-id": "DigitalGlobeStrip", "params": [{"crs": "EPSG:3857", "bands": "MS", "catalogId": "10400E0001DB6A00", "draType": "None", "correctionType": "DN", "bandSelection": "All"}]}' ``` UTM is a special case where we will automatically find the most appropriate UTM zone if you specify 'UTM' for the 'crs' parameter: ``` '{"template-id": "DigitalGlobeStrip", "params": [{"crs": "UTM", "bands": "MS", "catalogId": "10400E0001DB6A00", "draType": "None", "correctionType": "DN", "bandSelection": "All"}]}' ``` ### Atmospheric correction The atmospheric correction options include 'DN' (no correction, pixels values are raw DN values), 'TOA' (top-of-atmoshpere reflectance), and 'AComp' (surface reflectance). The previous examples demonstrate 'DN'. For Acomp use: ``` '{"template-id": "DigitalGlobeStrip", "params": [{"crs": "EPSG:3857", "bands": "MS", "catalogId": "10400E0001DB6A00", "draType": "None", "correctionType": "DN", "bandSelection": "All"}]}' ``` ### Panchromatic, multispectral, swir, and pan-sharpened multispectral output The bands combination to process is specified by setting the 'bands' parameter. Valid options are 'PAN', 'MS', 'SWIR', and 'Pansharp'. 'PAN', 'MS', and 'SWIR' select the panchromatic (one band), multispectral (4 or 8 bands depending on satellite), and short-wave infrared bands (8 band) respectively. Not all satellites support all options. For example the WorldView 1 satellite only support 'PAN' since it only has a panchromatic sensor. Only swir images shot using WorldView 3 support the 'SWIR' option. ### Dynamic range adjustment The 'draType' parameters controls weather or not DRA is applied. Current options are "None" (for no-dra) and "HistogramDRA". "HistogramDRA" will apply RDA's default DRA (linear histogram stretch with clip and gamma adjustment). ### Band Selection The 'bandSelection' parameters controls which bands are included in the image. Options are 'All' for all available bands and 'RGB' for true-color (red-green-blue) only. # Additional Resources To learn more about RDA, see the [Raster Data Access (RDA) Course](doc:raster-data-access-course). To see a quickstart tutorial for getting an image chip using gbdxtools, see [Quickstart tutorial with gbdxtools](https://gbdxdocs.digitalglobe.com/v1/docs/raster-data-access-course#section-quickstart-tutorial-for-getting-an-rda-chip-using-gbdxtools).