I have a database of around 100,000 postcodes each with lat/lon which I have converted to geom type in PostGIS. Each postcode also has one of 5 "regions". I wish to generate an accurate bounding polygon for each region, and have attempted to query it as so:
select region, count(*), ST_AsGeoJSON(ST_ConvexHull(ST_Collect(geom)))
group by region;
Despite the counts all being above 10,000 each, the resulting polygons are disappointingly simple and broad (e.g. around 10 sides only), with lots of overlaps.
Is there any way in PostGIS or other where I can achieve this goal of extracting highly detailed polygons? I need to do this because unfortunately the government body in question does not publish open data for these respective regions they have defined.