태그 보관물: numpy

numpy

rasterio를 사용하여 단일 지점에서 픽셀 값 얻기 x = (src.bounds.left

rasterio를 사용하여 래스터의 한 지점에서 단일 픽셀 값을 얻으려면 여기에 예가 있습니다. https://github.com/mapbox/rasterio/pull/275

그러나 래스터의 단일 지점에서 값을 추출하는 데 사용할 수있는 직접 API가 rasterio (및 cli가 아닌) 내에 있습니까?

— 편집하다

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)


답변

rio-sample 명령을 지원하는 Python API 메소드는 다음에 문서화되어 있습니다. https://rasterio.readthedocs.io/en/latest/api/rasterio._io.html#rasterio._io.DatasetReaderBase.sample

src.sample() x, y 튜플에 대해 반복자를 가져옵니다. for val in src.sample([(x, y)]): print(val)


답변