0

I am trying to figure out how to group multiple polygons into the same record (using something like a spatial join tool) using CartoDB.

I'd prefer to keep the polygons as separate rather than joining them to create one larger polygon, but I need them to be part of the same record

  • didn't realize I could do this! I will take it into practice - thanks again, John. – user26190 Mar 12 '15 at 21:33
1

It isn't currently possible to have collections of geometries in CartoDB. However, it is built on a relational database, so it isn't a problem to keep them separate.

Table 1 multipolygons_table

the_geom, group_id, etc
MULTIPOLYGON, SOME_INT

Table 2 groups table

group_id, etc
SOME_UNIQUE_INT

Then, just join the two using a dynamic query in your dashboard,

SELECT 
  ST_Collect(a.the_geom) the_geom, 
  ST_Collect(a.the_geom_webmercator) the_geom_webmercator, 
  b.group_id, 
  b.cartodb_id, 
  b.etc 
FROM table_1 a, table_2 b
WHERE 
  a.group_id = b.group_id
GROUP BY 
  b.group_id

Hope that helps.

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.