1

I want update table A.localidad, using st_within table B.licalidad

I need make centroid from table a for more precision.

The error, is the subquery return more one row

update test.test set 
localidad = (select st_within (st_centroid(a.geom), b.geom) from test.test a, capas_gral.localidades_amba b)

ERROR: una subconsulta utilizada como expresión retornó más de un registro (translation via Google: a subquery used as an expression returned more than one record)

  • This has already been answered recently, and the answer is pure SQL, making this marginally off-topic. You do have a potential problem in that ST_Centroid can generate points outside the feature, and an inefficiency in that you didn't add an a.geom && b.geom and ... – Vince Mar 1 '18 at 22:55
1

Try the following:

Updates column localidad of table test.test to take value of table capas_gral.localidades_amba where the centroid of test.test is completely inside capas_gral.localidades_amba.

UPDATE test.test
SET localidad = b.localidad 
FROM capas_gral.localidades_amba b
WHERE ST_WITHIN(st_centroid(test.test.geom), b.geom)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.