I have ~200 shapefiles with data in neighborhoods by census blocks across the city. I want to join each of these shapefiles back to the main census block file so that a count column in each of the neighborhood shapefiles gets joined back to the original city census blocks shapefile. I thought I could do this in a batch process using the "join attributes table" function but it seems like this batch process will create 200 joined files, instead of just appending each joins onto the city shapefile table. Does anyone know how I can do this in QGIS? I am using QGIS 2.14.3
I would also recommend using PostGIS as mentioned by DPSSpatial but in QGIS, you could use a bit of python to loop through all your layers and perform a joins operation.
It uses a common field to join the main layer to each individual layer in the group. It only joins a field called "Count" from each individual layer. Edit the code to fit your layer/group/field names and paste into the Python Console:
# Define layer tree root and group
root = QgsProject.instance().layerTreeRoot()
layer_group = root.findGroup('Layer group')
# Define main layer and common fields from main layer and layers stored in group
main_layer = QgsMapLayerRegistry.instance().mapLayersByName('main_layer_name')
main_layer_field = 'Field'
childField = 'Field'
# Iterate through each layer in group and join to main layer using defined fields
for layer in layer_group.children():
joinObject = QgsVectorJoinInfo()
joinObject.joinLayerId = layer.layerId()
joinObject.joinFieldName = childField
joinObject.targetFieldName = main_layer_field
joinObject.memoryCache = True
Your main layer should contain the "Count" field from the individual layers.