4

I want to know how I can fill in a column of a layer based on a certain relation criteria to another layer. In my case I want the column "straat" in my "bomen" shapefile filled in with the value's of "Staatnaam" in the shapefile "straat". However, the value that will be filled in is linked to a certain criteria relation. In this case, since "Bomen" is a point shapefile, each point forms a circle of 36 meters in radius (so 36 meters in every direction). The name for the closest street that intersects/crosses the "circle", needs to be added into the "Bomen" shapefile in the "straat" column.

How do I do this? If you guys can still not understand this what I am asking, here is an illustration. The "Bomen" and Straat shapefiles are the PostGIS layers, but this part is not important.

enter image description here

2 Answers 2

5

Assuming that a point doesn't form a circle of 36 meters (because it is a point), you may try to join the shapefile using a spatial relationship.

As a first step, create a new buffer layer from your point shapefile: this task is simply performed using the Fixed distance buffer algorithm from Processing Toolbox and setting the distance of 36 meters as Distance parameter.

Then, run the Join attributes by location algorithm from Processing Toolbox using these parameters:

enter image description here

The result will be a new layer which stores the same fields of the buffer_layer shapefile, plus the fields from the roads_layer shapefile when there is an intersection between the two layers.

If you want to save the attributes in the original point shapefile, run again the Join attributes by location algorithm, but this time use the point shapefile as Target vector layer and the joined layer as Join vector layer parameter.

5
  • I think your process is a lot simpler than mine :)
    – Joseph
    Commented Mar 28, 2017 at 10:00
  • 1
    @Joseph we answered at the same time. =) I thought using Processing would be easier, but I'm sure your solution also will be useful!
    – mgri
    Commented Mar 28, 2017 at 10:03
  • Thank you for the response, while this is a simple I want to ask if there is another way that does makes sure this happens automaticly if a new object is created in the bomen shapefile? Do not get me wrong this option is great, but might become tedious after while. My job is to make a green inventory shapefile as easy and efficient as possible. I see that you can make it also a batch process for both the buffering and joining? Commented Mar 28, 2017 at 10:52
  • I'm glad you found it helpful. If you want to automate the whole process, you may simply add the same operations described above in a model (QGIS Modeler). I'm sorry but, in your original question, you didn't specify you wanted an automatical procedure to accomplish the task so, if you don't know how to automate the whole process, I think that the best would be asking a new separate question by explaining what exactly you want to do (it seems that my answer solved you problem as it was posted, so please accept it if it helped you before asking the new question).
    – mgri
    Commented Mar 28, 2017 at 11:03
  • 1
    While my question is somewat I answered take this as an aswer. However there is one problem I see with this. The column I orriginally wanted to fill is actually not filled. I forgot to say that the name of the streetname column in the straten shapefile is different in de bomen schapefile. Because (and do not ask me why) there is a left streetname and a right street name and they are named the same (Why they did this I will never understand). So I only actually need to use one column. I think I will ask this somewhere else. Commented Mar 28, 2017 at 11:07
4

I would probably do the following:

  1. Make sure your "Bomen" layer has a field containing unique values to act like an identifier for your features. If not, you can create a new field using an expression like:

    $id
    

  1. Buffer your "Bomen" layer with a distance of 36 meters (make sure the layer uses the correct CRS):

    Vector > Geoprocessing Tools > Fixed distance buffer
    

  1. (Optional). Edit the Attribute Table for the buffered layer and delete all fields except the ID field (or whatever you called the field in Step 1) and the straat field.

  1. Make sure you have the refFunctions plugin installed and enabled which you can find in:

    Plugins > Manage and Install Plugins...
    

    Run the Field Calculator on the buffered layer and use an expression like:

    geomintersects( 'Straten', 'straat')
    

    Your buffered layer should contain the values from the straat field from the "Straten" layer


  1. Then merge the attribute tables of your original "Bomen" layer with the buffered one using the ID fields:

    Processing Toolbox > QGIS geoalgorithms > Vector general tools > Join attributes table
    

Your Answer

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

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