[gdal-dev] Ruby bindings and geotiff...

Roger André randre at gmail.com
Thu Jul 23 15:31:46 EDT 2009


Assuming that you know the row and column of the pixel you want, and
that column = iX, and row = iY, something like this example in Python
should work:

      # GET RASTER VALUE AT SPECIFIC ROW/COLUMN OFFSET IN RASTER
      iX = offset[0]
      iY = offset[1]
      src_data = src_band.ReadAsArray(0,iY,src_ds.RasterXSize,1)
      col_values = src_data[0]
      raster_value = col_values[iX]
      print "%s|%f" % (city.strip(), raster_value)
-----------

On Tue, Jul 21, 2009 at 3:27 AM, Adam
Fowler<adam.fowler at actionfinder.co.uk> wrote:
> Hi All,
>
> I'm trying to write a Ruby app to read the new and fantastic NASA
> ASTER Elevation DEM. This is of course in GeoTiff format.
>
> I'm wondering if anyone has examples in any language of using GDAL to
> read a particular location's data from a geotiff file? I can do the
> calculations to figure out which of the 3601x3601 data elements I need
> to read is, but I can't find an example of using GDAL to load only
> that pixel's information.
>
> If anyone has an example that would be great.
>
> I'm also having issues installing GDAL on OS X even when using
> macports. I can build and install fine without the ruby bindings, but
> using them (via editing the port file to include --with-ruby) gives
> me:
>
> libtool: link: /usr/bin/g++-4.0 gdal_wrap.o -o gdal.so
> -L/opt/local/lib
> -L/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib
> -L/opt/local -L/usr/X11/lib
> -L/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_science_gdal/work/gdal-1.6.0
> /opt/local/lib/libgdal.dylib /opt/local/lib/libproj.dylib -lm
> /opt/local/lib/libgif.dylib /opt/local/lib/libSM.dylib
> /opt/local/lib/libICE.dylib /opt/local/lib/libX11.dylib
> /opt/local/lib/libXau.dylib /opt/local/lib/libXdmcp.dylib -lgeotiff
> /opt/local/lib/libtiff.dylib /opt/local/lib/libjpeg.dylib -lc
> /opt/local/lib/libpng12.dylib -lz -ldl -lruby
> Undefined symbols:
>  "_main", referenced from:
>    start in crt1.10.5.o
> ld: symbol(s) not found
> collect2: ld returned 1 exit status
> make[3]: *** [gdal.so] Error 1
> make[2]: *** [build] Error 2
> make[1]: *** [build] Error 2
> make: *** [swig-modules] Error 2
>
> Error: Status 1 encountered during processing.
>
> I'm assuming it can't find ruby to link to, but not quite sure how to
> resolve this. Does --with-ruby have any extra undocumented options?
>
> If I figure it out I'd be happy to add to the Ruby WIKI page - who
> should I email to get access/contribute information?
>
> Thanks in advance.
>
> Regards,
>
> Adam.
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>


More information about the gdal-dev mailing list