Skip to main content
replaced http://gis.stackexchange.com/ with https://gis.stackexchange.com/
Source Link

With the answer on my previous questionmy previous question, I was able to set up reading a raster by blocks. I did some computation and now I try to write the result into another raster. However, the program fails with error code 139 and Segmentation fault (core dumped). My code:

with rasterio.drivers():
    with rasterio.open(asterPath,'r') as src:
        with rasterio.open(ndviPath,'w',driver='GTiff', width=src.shape[0], height=src.shape[1], count=1, dtype=np.float32) as dst:
            for index, window in src.block_windows(2):
                red = src.read(2, window=window)
                nir = src.read(3, window=window)
                #compute ndvi as NumPy 2d array, dtype float32
                dst.write_band(1,ndvi,window=window)

As a sanity check, I tried to fill ndvi array with zeros. It worked outside the loop, but not within, so I must have misunderstood something about writing by block with rasterio. All I know about rasterio is this manual (including the other doc files in the same repository). So how to save the NDVI data to a raster by block?

I'm on Ubuntu 14.04 and I use Python 2.7, Gdal 1.10.1, NumPy 1.8.2 and Rasterio 0.26.0 installed from source the way suggested for Linux at the Rasterio site.

With the answer on my previous question, I was able to set up reading a raster by blocks. I did some computation and now I try to write the result into another raster. However, the program fails with error code 139 and Segmentation fault (core dumped). My code:

with rasterio.drivers():
    with rasterio.open(asterPath,'r') as src:
        with rasterio.open(ndviPath,'w',driver='GTiff', width=src.shape[0], height=src.shape[1], count=1, dtype=np.float32) as dst:
            for index, window in src.block_windows(2):
                red = src.read(2, window=window)
                nir = src.read(3, window=window)
                #compute ndvi as NumPy 2d array, dtype float32
                dst.write_band(1,ndvi,window=window)

As a sanity check, I tried to fill ndvi array with zeros. It worked outside the loop, but not within, so I must have misunderstood something about writing by block with rasterio. All I know about rasterio is this manual (including the other doc files in the same repository). So how to save the NDVI data to a raster by block?

I'm on Ubuntu 14.04 and I use Python 2.7, Gdal 1.10.1, NumPy 1.8.2 and Rasterio 0.26.0 installed from source the way suggested for Linux at the Rasterio site.

With the answer on my previous question, I was able to set up reading a raster by blocks. I did some computation and now I try to write the result into another raster. However, the program fails with error code 139 and Segmentation fault (core dumped). My code:

with rasterio.drivers():
    with rasterio.open(asterPath,'r') as src:
        with rasterio.open(ndviPath,'w',driver='GTiff', width=src.shape[0], height=src.shape[1], count=1, dtype=np.float32) as dst:
            for index, window in src.block_windows(2):
                red = src.read(2, window=window)
                nir = src.read(3, window=window)
                #compute ndvi as NumPy 2d array, dtype float32
                dst.write_band(1,ndvi,window=window)

As a sanity check, I tried to fill ndvi array with zeros. It worked outside the loop, but not within, so I must have misunderstood something about writing by block with rasterio. All I know about rasterio is this manual (including the other doc files in the same repository). So how to save the NDVI data to a raster by block?

I'm on Ubuntu 14.04 and I use Python 2.7, Gdal 1.10.1, NumPy 1.8.2 and Rasterio 0.26.0 installed from source the way suggested for Linux at the Rasterio site.

added 210 characters in body
Source Link
Pavel V.
  • 1.5k
  • 3
  • 16
  • 47

With the answer on my previous question, I was able to set up reading a raster by blocks. I did some computation and now I try to write the result into another raster. However, the program fails with error code 139 and Segmentation fault (core dumped). My code:

with rasterio.drivers():
    with rasterio.open(asterPath,'r') as src:
        with rasterio.open(ndviPath,'w',driver='GTiff', width=src.shape[0], height=src.shape[1], count=1, dtype=np.float32) as dst:
            for index, window in src.block_windows(2):
                red = src.read(2, window=window)
                nir = src.read(3, window=window)
                #compute ndvi as NumPy 2d array, dtype float32
                dst.write_band(1,ndvi,window=window)

As a sanity check, I tried to fill ndvi array with zeros. It worked outside the loop, but not within, so I must have misunderstood something about writing by block with rasterio. All I know about rasterio is this manual (including the other doc files in the same repository). So how to save the NDVI data to a raster by block?

I'm on Ubuntu 14.04 and I use Python 2.7, Gdal 1.10.1, NumPy 1.8.2 and Rasterio 0.26.0 installed from source the way suggested for Linux at the Rasterio site.

With the answer on my previous question, I was able to set up reading a raster by blocks. I did some computation and now I try to write the result into another raster. However, the program fails with error code 139 and Segmentation fault (core dumped). My code:

with rasterio.drivers():
    with rasterio.open(asterPath,'r') as src:
        with rasterio.open(ndviPath,'w',driver='GTiff', width=src.shape[0], height=src.shape[1], count=1, dtype=np.float32) as dst:
            for index, window in src.block_windows(2):
                red = src.read(2, window=window)
                nir = src.read(3, window=window)
                #compute ndvi as NumPy 2d array, dtype float32
                dst.write_band(1,ndvi,window=window)

As a sanity check, I tried to fill ndvi array with zeros. It worked outside the loop, but not within, so I must have misunderstood something about writing by block with rasterio. All I know about rasterio is this manual (including the other doc files in the same repository). So how to save the NDVI data to a raster by block?

With the answer on my previous question, I was able to set up reading a raster by blocks. I did some computation and now I try to write the result into another raster. However, the program fails with error code 139 and Segmentation fault (core dumped). My code:

with rasterio.drivers():
    with rasterio.open(asterPath,'r') as src:
        with rasterio.open(ndviPath,'w',driver='GTiff', width=src.shape[0], height=src.shape[1], count=1, dtype=np.float32) as dst:
            for index, window in src.block_windows(2):
                red = src.read(2, window=window)
                nir = src.read(3, window=window)
                #compute ndvi as NumPy 2d array, dtype float32
                dst.write_band(1,ndvi,window=window)

As a sanity check, I tried to fill ndvi array with zeros. It worked outside the loop, but not within, so I must have misunderstood something about writing by block with rasterio. All I know about rasterio is this manual (including the other doc files in the same repository). So how to save the NDVI data to a raster by block?

I'm on Ubuntu 14.04 and I use Python 2.7, Gdal 1.10.1, NumPy 1.8.2 and Rasterio 0.26.0 installed from source the way suggested for Linux at the Rasterio site.

Source Link
Pavel V.
  • 1.5k
  • 3
  • 16
  • 47

Segmentation fault while writing an output raster by blocks with rasterio

With the answer on my previous question, I was able to set up reading a raster by blocks. I did some computation and now I try to write the result into another raster. However, the program fails with error code 139 and Segmentation fault (core dumped). My code:

with rasterio.drivers():
    with rasterio.open(asterPath,'r') as src:
        with rasterio.open(ndviPath,'w',driver='GTiff', width=src.shape[0], height=src.shape[1], count=1, dtype=np.float32) as dst:
            for index, window in src.block_windows(2):
                red = src.read(2, window=window)
                nir = src.read(3, window=window)
                #compute ndvi as NumPy 2d array, dtype float32
                dst.write_band(1,ndvi,window=window)

As a sanity check, I tried to fill ndvi array with zeros. It worked outside the loop, but not within, so I must have misunderstood something about writing by block with rasterio. All I know about rasterio is this manual (including the other doc files in the same repository). So how to save the NDVI data to a raster by block?