I have a shapefile that consists of a list of archaeological sites with the x and y coordinates.

I have an Natural Earth shapefile for the countries of world.

I was wondering how I go about creating a new field for the country of each archaeological site using the field calculator?

I am relatively new to QGIS and not that familiar with the field calculator.


Two options.

1.) Perform an intersect of the points with the countries. Use Vector > Geoprocessing Tools > Intersect...

For the intersect tool, make the input your arch sites (points) and your intersect layer as the countries (polygons).

That will produce a point file with the attributes from the countries attached to each point.

2.) If you know that the points do not overlap more than one polygon, then it's also possible to use the field calculator to do that quickly.

Install the refFunctions plugin for QGIS.

You can calculate a new field quickly in QGIS 2.8.1 by highlighting your arch points layer in the layer list, then pressing the Field Calculator button. Or do it from the attribute table.

field calculator button

Then use the new geomintersects function in the Reference list:
geomintersects('target layer','target field')

Where target layer is the name of the countries layer, and target field is the field of the named countries to attach to the points.

calculate intersects field

There are some other functions like geomwithin that may work in this case too.


You would probably not use the field calculator.

Rather you want a spatial join. So from the menu:

Vector>Data Management Tools>Join Attributes By Location

This will create a new shapefile with the "Target vector layer" as your archaeological sites layer and the Natural Earth dataset as your "Join Vector Layer".

Then just delete all of the other Natural Earth attributes, other than country, that you do not need.


Use the 'Point sampling tool' plugin. With this plugin you can pick any column, from any polygon layer and raster layers, that your archaeological sites fall within.

enter image description here

enter image description here

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.