In QGIS I have two shapefiles: one point layer representing power plants (654 elements) and one polygon layer representing cities and villages connected to gas grid (1348 elements).
For every power plant I need to find all the areas, which are maximum in 10 km distance from the plant. What I can imagine in QGIS I need to find all the areas to whose border the distance from the point is smaller or equal 10 km.
As a result I want to obtain a table with the list of power plants, selected areas and their distances.
How can I make it in QGIS? I am familiar with Python, but never worked with PostGIS or GRASS.
Best Answer
Next PyQGIS code does the work.
I tested it with shapefiles (power_plants and cities) of next image:
After running the code at the Python Console of QGIS, it was obtained a memory layer (named 'selected_plants') whose attributes table has the list of power plants, their distances and selected areas (expressed as 'city_id').
Editing Note:
Creating in each shapefile its respective field name for each feature (in my example 'name_plant' and 'name_city'), next code put in these fields of memory layer the name of attribute that corresponds.
After running the above code, I got: