Skip to main content
Tweeted twitter.com/StackGIS/status/1037355217925406720
added 408 characters in body
Source Link
user1186
  • 131
  • 2
  • 10
  • 29

To get a single pixel value at a point in a raster using rasterio, there is an example here: https://github.com/mapbox/rasterio/pull/275

However, is there a direct API within rasterio (and not the cli) which can be used to extract value at a single point in a raster?

-- EDIT

with rasterio.drivers():

    # Read raster bands directly to Numpy arrays.
    #
    with rasterio.open('C:\\Users\\rit\\38ERP.tif') as src:
        x = (src.bounds.left + src.bounds.right) / 2.0
        y = (src.bounds.bottom + src.bounds.top) / 2.0

        vals = src.sample((x, y))
        for val in vals:
            print list(val)

To get a single pixel value at a point in a raster using rasterio, there is an example here: https://github.com/mapbox/rasterio/pull/275

However, is there a direct API within rasterio (and not the cli) which can be used to extract value at a single point in a raster?

To get a single pixel value at a point in a raster using rasterio, there is an example here: https://github.com/mapbox/rasterio/pull/275

However, is there a direct API within rasterio (and not the cli) which can be used to extract value at a single point in a raster?

-- EDIT

with rasterio.drivers():

    # Read raster bands directly to Numpy arrays.
    #
    with rasterio.open('C:\\Users\\rit\\38ERP.tif') as src:
        x = (src.bounds.left + src.bounds.right) / 2.0
        y = (src.bounds.bottom + src.bounds.top) / 2.0

        vals = src.sample((x, y))
        for val in vals:
            print list(val)
Source Link
user1186
  • 131
  • 2
  • 10
  • 29

Getting pixel values at single point using rasterio

To get a single pixel value at a point in a raster using rasterio, there is an example here: https://github.com/mapbox/rasterio/pull/275

However, is there a direct API within rasterio (and not the cli) which can be used to extract value at a single point in a raster?