0

I'm using rasterio sample module and I want to convert my output (generator) to list. I know that I can just use list() but it raises error "too many values to unpack (expected 2)". When I just use the sample module I get generator:

sample = rasterio.sample.sample_gen(raster, ['754707','4248548'])

but trying to make a list with:

sample = list(rasterio.sample.sample_gen(raster, ['754707','4248548']))

raises an error. I found .items() method but it works for dictionaries, it's not useful for generators, I'm working for the first time with a generator object and I don't get what is wrong.

Edyficjum
  • 81
  • 6

1 Answers1

0

Try:

sample = list(rasterio.sample.sample_gen(raster, [('754707','4248548')]))

In your example, the strings in your list are Sequence-like and iterable so when unpacking them, they get 6 values and it is expecting two values. Those strings might need be int or float, I'm not sure though

myz540
  • 537
  • 4
  • 7