Question

I've got a netcdf data file described as: https://gist.github.com/4198037

I've opened this file with a tool called 'ncview' and I've found the EXACT value I need:

Current: (i=397, j=137) 14 (x=18.75, y=21.25)

enter image description here

THAT value of 14 is the money-maker. It corresponds to the color output on the map... and I need to be able to get that value for a given input Lat/Lng.

Does anyone happen to know the specific ruby code which I could input a (lat, lng) and get that value ?

Was it helpful?

Solution

This requires use of the gem "ruby-netcdf", "0.6.6.1" gem ( which involves a lengthly install process) ... however once its installed you can easily grab the values like so:

require "rubygems"
require "numru/netcdf"    
@global_biome = NumRu::NetCDF.open("netcdf/vegtype.nc")
@global_biome_num = @global_biome.var("vegtype")[397,137,0,0][0]
p @global_biome_num
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top