Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

341
Views
How to create a table with geometry polygons and field_ID from another table containing field_ID and lat long point in postgis

I have the following table which contains coordinates of fields from a farm. I'm trying to create polygons using points coordinates as edges of those polygons.

CREATE TABLE field_point (
     field_id VARCHAR(64) PRIMARY KEY,
     point_latitude DOUBLE PRECISION,
     point_longitude DOUBLE PRECISION,
     point GEOMETRY(Point,4326),
);

I understand that by creating geometry points using latitude and longitude of each point.

I then collect the coordinates to create a point geometry in table field_point as such:

UPDATE field_point SET point = ST_Transform(ST_SetSRID(ST_MakePoint(point_longitude, point_latitude), 4326),4326);

Lastly, I collect the newly created point and run convex_hull function on another table called field to return polygons as such:

INSERT INTO field (polygon) SELECT ST_ConvexHull(ST_Collect(point)) FROM field_point GROUP BY field_id;

I'm now not able to bring the field_id from the first table. Could you help?

Expected resuld should be the following table

CREATE TABLE field (
     field_id VARCHAR(64) PRIMARY KEY,
     polygon GEOMETRY(polygon,4326),
);

one row should the polygon created from all points defining field_id from the field_point table.

Thanks!

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Please use below query,

INSERT INTO field (field_id, polygon) 
SELECT field_id, ST_ConvexHull(ST_Collect(point)) FROM field_point;
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!