2

I'm trying to pull coordinate and pixel value data from a .TIF using rasterio. In recently updated documentation (April 2018) there appears to be a .xy() function to get the spatial coordinates of a pixel, with an example:

>>> dataset.xy(dataset.width // 2, dataset.height // 2)
(476550.0, 4149150.0)

However, when I run the same example:

import rasterio
dataset = rasterio.open('image.tif')
dataset.xy(dataset.width // 2, dataset.height // 2)

I receive error: "AttributeError: 'rasterio._io.RasterReader' object has no attribute 'xy'".

Am I misinterpreting the documentation or is this something like pre-documentation for a future version? Is there another method for this in current release / official documentation that I haven't seen?

Thank you!

Gbstox
  • 21
  • 4
  • 1
    I'm guessing you have version 0.36? There was a long pre-1.0 period, during which documentation was updated, but if you installed from pip without the flag `--pre`, you wouldn't have access to documented features. 1.0 was released recently though, so if you upgrade, you'll have access to the `xy` method. – jdmcbr Jul 23 '18 at 04:16
  • I can confirm that anaconda installs version 0.3x automatically (tested on Win 7) and that you have to manually choose the version to use this feature! – not_a_bot_no_really_82353 Nov 10 '19 at 03:13

0 Answers0