Sampling from one single point location using sample()


Alexander Jüstel
 

Hello, 
 
I would like to sample the value of my raster at one single point location. I have passed the coordinates as an iterable to the sample() function. However, I am not able to extract the value from the generator. The sampling works fine for more than one point. However, I need it to work for one point only. I have tried using list(gen) or next(gen) to get the value but nothing works so far.
 
Thanks for your support
Cheers
Alex


Sean Gillies
 

Hi Alex,

On Sun, Nov 15, 2020 at 9:06 AM Alexander Jüstel <alexander.juestel@...> wrote:
Hello, 
 
I would like to sample the value of my raster at one single point location. I have passed the coordinates as an iterable to the sample() function. However, I am not able to extract the value from the generator. The sampling works fine for more than one point. However, I need it to work for one point only. I have tried using list(gen) or next(gen) to get the value but nothing works so far.
 
Thanks for your support
Cheers
Alex

Is your approach any different than the examples in https://github.com/mapbox/rasterio/blob/master/tests/test_sampling.py?

--
Sean Gillies


Alexander Jüstel
 

Hey Sean, 

I made it work using your tests! Thanks for that ;)

Cheers Alex

On Mon, Nov 16, 2020 at 4:03 PM Sean Gillies via groups.io <sean=mapbox.com@groups.io> wrote:
Hi Alex,

On Sun, Nov 15, 2020 at 9:06 AM Alexander Jüstel <alexander.juestel@...> wrote:
Hello, 
 
I would like to sample the value of my raster at one single point location. I have passed the coordinates as an iterable to the sample() function. However, I am not able to extract the value from the generator. The sampling works fine for more than one point. However, I need it to work for one point only. I have tried using list(gen) or next(gen) to get the value but nothing works so far.
 
Thanks for your support
Cheers
Alex

Is your approach any different than the examples in https://github.com/mapbox/rasterio/blob/master/tests/test_sampling.py?

--
Sean Gillies