Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

340
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda