sentinel_s3

Gem Version

Ruby library for extracting Sentinel-2 tile metadata and downloading tile data from Amazon S3. This is the primary mechanism for retrieving data for the Sentinel-2 S3 Search API project.

Installation

Add this line to your application's Gemfile:

gem 'sentinel_s3'

And then execute:

$ bundle

Or install it yourself as:

$ gem install sentinel_s3

Usage

Initialize SentinelS3::Client

client = SentinelS3::Client.new("access_key_id", "secret_access_key")

Get productInfo.json object paths for all products by date: get_products("YYYY-MM-DD")

products = client.get_products("2017-12-14")
# =>
# [
# "products/2017/12/14/S2B_MSIL1C_20171214T230119_N0206_R015_T58FCD_20171214T234716/productInfo.json",
# "products/2017/12/14/S2B_MSIL1C_20171214T230119_N0206_R015_T58FCE_20171214T234716/productInfo.json",
# ]

Get product and tile metadata

# takes single productInfo.json path returned from get_products
product = "products/2017/12/15/S2B_MSIL1C_20171215T235729_N0206_R030_T57MVR_20171216T010047/productInfo.json"
 = client.get_product_info(product)
# =>
{
  :name => "S2B_MSIL1C_20171215T235729_N0206_R030_T57MVR_20171216T010047",
  :id => "eaedcad9-f287-41b8-944c-0cfed0b15db8",
  :path =>  "products/2017/12/15/S2B_MSIL1C_20171215T235729_N0206_R030_T57MVR_20171216T010047",
  :timestamp => "2017-12-15T23:57:29.027Z",
  :datatake_identifier => "GS2B_20171215T235729_004060_N02.06",
  :scihub_ingestion => "2017-12-16T01:46:29.112Z",
  :s3_ingestion => "2017-12-16T01:50:49.375Z",
  :tiles=>
    [
      {
        :path => "tiles/57/M/VR/2017/12/15/0",
        :timestamp => "2017-12-15T23:57:27.460Z",
        :utm_zone => 57,
        :latitude_band => "M",
        :grid_square => "VR",
        :epsg => "32757",
        :data_coverage_percentage => 31.21,
        :cloudy_pixel_percentage => 13.47
      }
    ]
}

Download tile data: download_tile_data(s3 tile path, file, output path)

client.download_tile_data("tiles/57/M/VR/2017/12/15/0", "B01.jp2", "/path/that/exists")

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/beaorn/sentinel_s3.

License

The gem is available as open source under the terms of the MIT License.