I have a layer with thousands of polygons representing buildings, as is normal, buildings are concentrated in large population centers, but my map will be used mostly in rural areas. So I do not need so many buildings in big cities, but It is essential that all buildings that are far from the cities appear.

Concentrated builds around cities

What would be the best tool or method to achieve this?

I look for some type of tool or method of work that can eliminate "random" and in a spatially distributed way the small buildings, preferably those near / within the large population centers.

UPDATE-> I think that using a heatmap like "filter" to select features maybe will be a solution, but I don't know if is it possible.

NOTE: I convert polygon layer to centroids layer and I got a HeatMap.

You can get example shapefile here-> builds.shp

  • I have read about "heat maps", but I don't know is if possible to use it like a filter selection (maybe the negative of the heat map). Jan 3, 2017 at 15:35
  • Just to make sure, you want to filter (only select some of the buildings) and not mask (as in cover what you don't want to see)? Jan 4, 2017 at 1:50

3 Answers 3


Looks like the data you provided shows grossFloorArea and underneath that field is the value total (found in attribute table). The recommendation I have is to click the "select features" tool and draw a box around the major metropolitan areas (Jerez, Arcos de la Frontera, Villamartin, Prado del Rey etc.). Then you could write a query for a building value total of less than some desired amount. Afterwards, you could delete the results (polygons) that seem "too small". Hope that helps!

  • Thanks, Chelsea, the solution you give me, will be ok, but that's is only a very small zone to work, a example of a big problem, jeje, I have to do again but with all country (spain), so manually selection will be only the final option. I try to automate the process as much as I can Jan 3, 2017 at 19:01

Respond myself

I create a heat-map, previous I convert polygons to centroids, invert color of the heat-map and then save as geotiff

Inverse heat map save as geotiff

I add a integer field to polygon layer called "tiffvalue", that field will be update using a python script: ->Here the original code

Reading, modifying and writing a geotiff with GDAL in python

But here my modyfied code:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from osgeo import gdal,ogr
from gdalconst import * 


def GetCentroidValue(fc,rast):
    #open vector layer
    drv=ogr.GetDriverByName('ESRI Shapefile') #assuming shapefile?
    ds=drv.Open(fc,True) #open for editing

    #open raster layer
    gdal.UseExceptions() #so it doesn't print to screen everytime point is outside grid

    cols = src_ds.RasterXSize
    rows = src_ds.RasterYSize
    bands = src_ds.RasterCount
    band = src_ds.GetRasterBand(1)

    # Read full raster file into array
    data = band.ReadAsArray(0, 0, cols, rows)

    for feat in lyr:

        px = int((mx - gt[0]) / gt[1]) #x pixel
        py = int((my - gt[3]) / gt[5]) #y pixel

        try: #in case raster isnt full extent


            val=-9999 #or some value to indicate a fail




So I got a field called "tiffvalue" with high values (white into tiff) if the polygon is near cities and very low values (Black into tiff) is polygon is in rural zones. ;) Now, I will have only to select a feature ramdonly based on this field using it as probability the more high value the more posibilitities to be "deleted"/unselect.


This is a 'density' problem - you want to create a raster of cells whose values have a '# of buildings per square mile' type of value.

From there you simply extract the cells that contain the desired density - ie. those that define rural areas - then use those cells to select the source buildings...

You've somewhat done the same thing with the geotiff - but do the values have a real density value or just a color value that you're using as a proxy for density?

Even so, to extract cells from a raster based on a value of the cells is a tool found in the raster calculator, for example.

However: I did not find a good tool to create a point density layer, and have struggled with this with QGIS for some time, and so have others. The Heat Map and Interpolation tools don't quite cut the mustard for this. Perhaps someone else can weigh in?

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.