3

I have imported a shapefile into CartoDB (it is the only one I can get my hands on, since it's a small geographic region, non-US) - it includes shapes of all the municipalities in a federal state. It turns out though that the shapefile creates two seperate maps when imported into CartoDB, because of some bureaucratic distinction the state makes in regard to its municipalities.

I would like to have all the shapes of the municipalities in one map and one layer, so I can join sets of data (that normally just include all the municipalities in alphabetic order) easily and also use the info window function for all shapes.

I tried merge tables, but that function seems to be for different types of merges. I tried opening one of the maps and typing out the missing municipalities in new rows in the data window (to trick the column merge) but it appears that the column that has the geospatial info in it is not supported by the merge function.

1

You need an append functionality which you can achieve through a SQL statement. The merge functionality will merge your information in terms of columns, but you need it to be merged in terms of rows.

Imagine that the structure of your tables is (just noting the columns, and supposing that both are created with the same columns):

cartodb_id, the_geom, name, other_column, other_column2, created_at, updated_at

If your tables are named tableA and tableB, then you can run a query like the following one to append the records of tableB inside tableA:

INSERT INTO tableA(the_geom, name, other_column, other_column2) SELECT the_geom, name, other_column, other_column2 FROM tableB

Please notice that you don't need to include internal columns like cartodb_id or the timestamps are those are autogenerated by the system.

Edit: Take into account that you'd need to edit the names that appear in the query according to your specifics. If your table is not called tableA but "houses", you'd just need to replace them. The same applies for tableB and any column name.

  • I tried but it came up with the error "relation "tableA" does not exist", but it also said "no rows for this query", so that's good since I am looking to add those rows. I am guessing I don't have the entire query here and I need more parts to add into the query window right? – KBuchholz Aug 26 '15 at 15:05
  • I just fiddled with autocomplete a little and also decided to use my copies as backup and try to combine the original tables instead - and it workedddddd!!! so stoked thank you. – KBuchholz Aug 26 '15 at 15:13
  • Ouch, I totally forgot to add in my message that you must edit the name of the tables. Editing my message right now! – iriberri Aug 27 '15 at 8:58

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.