Q:

Creating sequential raster in Python

I would like to generate a raster file with a resolution of x (e.g. 0.00833 degrees) and a sequential numbering: e.g. from 1 to n where n is the number of pixels in the raster, such that each pixel has a unique id value. I would like to achieve this with Python. 

A:

You can do this with numpy and rasterio:
import numpy as np
import rasterio as rio
from rasterio import Affine

out_raster = 'path/to/output.tif'
xmin = 147.5
ymax = -34.5
res = 0.00833
cols = 100
rows = 150

profile = {
    'driver': 'GTiff',
    'dtype': 'uint32',
    'width': cols,
    'height': rows,
    'count': 1,
    'crs': 'epsg:4326',
    'transform': Affine(res, 0.0, xmin, 0.0, -res, ymax)}

ids = np.arange(1, rows*cols+1).reshape(rows, cols).astype(profile['dtype'])

with rio.open(out_raster, 'w', **profile) as out:
        out.write(ids, 1)

