I have two tables. An exploded points parcels layer
create table a as
select id, (ST_Dumppoints(geom)).geom as geom FROM tableblah;
and another parcels table call it b which is a polygon
I wrote a a query that calculates the shortest distance from the exploded parcels/as points to layer b
select id,min(st_distance(a.geom,b.geom)) as min_distance
from a join b on a.id = b.id group by a.id
Now I want to be able to create that minimum line from the points to the parcel. I am unsure how to format this part. I know I probably need st_makeline.
should I convert the layer b parcels to points as well?
UPDATE
I converted layer b too a points also
create table b_points as
select b.id,(ST_Dumppoints(geom)).geom as geom from b;
then i ran
select distinct on(a.id) a.id, st_makeline(a.geom,b_points.geom) as geom
from a join b_points on a.id = b_points.id order by
a.id,st_distance(a.geom,b.geom)
this gives me this which is somewhat correct, but the parcel I converted to points only produced 4 points...
ANSWERED:
ended up using st_shortestline too replace my use of st_makeline. I converted both my polygon parcels table to lines and ran it.as you can see below the results from using st_shortestline is more accurate than st_makeline in regards to finding the shortest path from the parcels boundaries