2

I’m trying to update geometry table using the following command but get

parse error – invalid geometry
HINT: "MULTIPOINT(" <-- parse error at position 11 within geometry
 Update geo_table
 Set geom =ST_ConvexHull(
 ST_GeomFromText('MULTIPOINT(co_ord_string)', 4326));
 WHERE 
 Id =1234;

originally I created this data with a perl script something like

 insert into geo_table (stuff,date, co_ord_string,geom) values (‘Hello’,’02-07-2018 00:00:00’, T_ConvexHull(ST_GeomFromText('MULTIPOINT($co_ord_string)', 4326));

The co_ord_string is a series of long lat points separated by a comma. These don’t create perfect polygons as they may contain internal points but using ST_ConvexHull a polygon is created.

Only by viewing the data in QGIS I can see there are errors in the original coordinates that need manually editing (Missing minus signs some points or other issues ) and the geometry recreating.

What is the correct syntax?

Vince
20.5k16 gold badges49 silver badges65 bronze badges
asked Jul 2, 2018 at 18:29
4
  • What is in coordstring? Commented Jul 3, 2018 at 7:16
  • "MULTIPOINT(", ‘Hello’ These are not ASCII quotes. Did you copy/paste everything correctly into this question? Commented Jul 3, 2018 at 11:16
  • @Ian Turton co_ord_string is the column name containing a list of Long Lat points separated by a comma. If this value is manually copied the query works. Commented Jul 4, 2018 at 17:47
  • @CL the Non ASCII Quotes are due to having to email question home in order to post I forgot to replace them sorry Commented Jul 4, 2018 at 17:48

1 Answer 1

1

I found out how to do this by concatenating the query so it gets the values from the database object co_ord_string

UPDATE geo_table
SET geom =ST_ConvexHull(
 ST_GeomFromText('MULTIPOINT(' || co_ord_string|| ')', 4326)
);
WHERE Id =1234;
PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
answered Jul 8, 2018 at 17:48
1
  • 2
    You can accept your own answer with the checkbox Commented Aug 9, 2018 at 9:03

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.