Skip to main content
Bounty Ended with 150 reputation awarded by ReutKeller
Post Undeleted by Kadir Şahbaz
added 93 characters in body
Source Link
Kadir Şahbaz
  • 78k
  • 57
  • 257
  • 404

Save result array (rf_array) as in the following lines: (You don't need to reshape the array)

rf_array = df_join['Prediction'].values # returns numpy.ndarray
rf_array = rf_array.reshape(img.shape[0], img.shape[1])
# rf_array = rf_array.reshape(869, 1202)

with rasterio.open('path/to/new.tif', 
                   'w',
                   driver='GTiff',
                   height=imgheight=rf_array.shape[0],
                   width=imgwidth=rf_array.shape[1],
                   count=1,
                   dtype=imgdtype=rf_array.dtypes[0]dtype,
                   crs=img.crs,
                   nodata=None, # change if data has nodata value
                   transform=img.transform) as new_file:

    new_file.write(rf_array, 1)

When you open the two images in QGIS they will overlap.

Save result array (rf_array) as in the following lines: (You don't need to reshape the array)

rf_array = df_join['Prediction'].values # returns numpy.ndarray

with rasterio.open('path/to/new.tif', 
                   'w',
                   driver='GTiff',
                   height=img.shape[0],
                   width=img.shape[1],
                   count=1,
                   dtype=img.dtypes[0],
                   crs=img.crs,
                   transform=img.transform) as new_file:

    new_file.write(rf_array, 1)

When you open the two images in QGIS they will overlap.

Save result array (rf_array) as in the following lines:

rf_array = df_join['Prediction'].values # returns numpy.ndarray
rf_array = rf_array.reshape(img.shape[0], img.shape[1])
# rf_array = rf_array.reshape(869, 1202)

with rasterio.open('path/to/new.tif', 
                   'w',
                   driver='GTiff',
                   height=rf_array.shape[0],
                   width=rf_array.shape[1],
                   count=1,
                   dtype=rf_array.dtype,
                   crs=img.crs,
                   nodata=None, # change if data has nodata value
                   transform=img.transform) as new_file:

    new_file.write(rf_array, 1)
Post Deleted by Kadir Şahbaz
Source Link
Kadir Şahbaz
  • 78k
  • 57
  • 257
  • 404

Save result array (rf_array) as in the following lines: (You don't need to reshape the array)

rf_array = df_join['Prediction'].values # returns numpy.ndarray

with rasterio.open('path/to/new.tif', 
                   'w',
                   driver='GTiff',
                   height=img.shape[0],
                   width=img.shape[1],
                   count=1,
                   dtype=img.dtypes[0],
                   crs=img.crs,
                   transform=img.transform) as new_file:

    new_file.write(rf_array, 1)

When you open the two images in QGIS they will overlap.