Class: Map::Gdal::NdviService
- Inherits:
-
Object
- Object
- Map::Gdal::NdviService
- Includes:
- Base
- Defined in:
- lib/map/gdal/ndvi_service.rb
Instance Attribute Summary
Attributes included from Base
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(tif_red, tif_near_red) ⇒ NdviService
constructor
A new instance of NdviService.
Methods included from Base
#add_to_clean, #clean, #gdal_running?, #get_file_name_with_path, #get_layer_name, #get_path_to_temp_file, #options_to_command_line, #run_command, #store_kml, #tmp_file
Constructor Details
#initialize(tif_red, tif_near_red) ⇒ NdviService
Returns a new instance of NdviService.
6 7 8 9 |
# File 'lib/map/gdal/ndvi_service.rb', line 6 def initialize(tif_red, tif_near_red) @tif_red = tif_red @tif_near_red = tif_near_red end |
Instance Method Details
#call ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/map/gdal/ndvi_service.rb', line 11 def call tif_out = get_path_to_temp_file('calculated', 'tif') add_to_clean(tif_out) add_to_clean("#{tif_out}.aux.xml") run_command( %{ gdal_calc.py --overwrite -B #{@tif_red} -A #{@tif_near_red} --outfile=#{tif_out} --calc="(A.astype(float)-B)/(A.astype(float)+B)" --overwrite --type=Float32 --NoDataValue=-9999 }.squish ) tif_out end |