How to automatically increment several Integer columns based on alphabetically ordered text columns?
Assumption:
These ID values will only be used for output/display and will not be used as Unique Keys or in other tables (as Foreign Keys), otherwise you'll need a lot of cascade updates and loss of performance as a single row insert would result in updating a huge part of the table and many other tables as well.
Solution:
You don't have to store these values. You can use window functions, e.g. DENSE_RANK() to calculate these number when needed.
SELECT 
    province, district, town,
    DENSE_RANK() OVER (ORDER BY province)
        AS province_id,
    DENSE_RANK() OVER (PARTITION BY province
                       ORDER BY district)
        AS district_id,
    DENSE_RANK() OVER (PARTITION BY province, district
                       ORDER BY town)
        AS town_id
FROM
    tableX AS t
 ;