I have two different polygons layer : the first one represent buildings and the second one represent cities.

My goal is to extract the buildings which are in the cities.

I tried to use the Clip function but it returns :

Uncaught error while executing algorithm
        Traceback (most recent call last):
          File "/usr/share/qgis/python/plugins/processing/core/GeoAlgorithm.py", line 203, in execute
          File "/usr/share/qgis/python/plugins/processing/algs/qgis/Clip.py", line 71, in processAlgorithm
          File "/usr/share/qgis/python/plugins/processing/core/outputs.py", line 326, in getVectorWriter
            crs, options)
          File "/usr/share/qgis/python/plugins/processing/tools/vector.py", line 618, in __init__
            uri = GEOM_TYPE_MAP[geometryType] + "?uuid=" + unicode(uuid.uuid4())
        KeyError: 1006

I have been able to use this function to extract points (after having created a point layer with the centroïds of the buildings) and then keep only buildings which have the same IDs as the centroids extracted but I had to do it with PostGIS and it is quite long to do.

Is there any way to do it with a simplier method ?

  • do both layers have the same CRS? did you accidentally switch input and clip layers (input is the layer to extract from, clip the mask)? you actually might want to stick to the centroid method in general (or other spatial relations like within or contains or intersects, all of them are available in qgis), though...clipping a layer actually might cut the buildings polygons along the cities polygons – geozelot Apr 20 '17 at 9:09
  • Yes, both layer have the same CRS. When I tried for the first time, before finding out that it doesn't work, I wondered how it would deal with buildings which have a part in and a part out of the cities. Do you think that it is what's causing the error ? – Florian L. Apr 20 '17 at 9:20
  • I don't 'understand' the error message, others might help here. but 'clip' does, AFAIK, actually cut the input features along the mask layers edges (e.g. cutting the outside part). – geozelot Apr 20 '17 at 9:24
  • 1
    vector -> geoprocessing tools -> intersect might be one solution here. this would include all buildings that share any part of its polygon with the city polygon – geozelot Apr 20 '17 at 9:31
  • Sometimes features with NULL geometry could cause the algorithm error. Try: Geoprocessing Tools -> Select by expression -> '$geometry is NULL'. If there are some features you should delete them and try 'Clip' again. – Mykola Kozyr Apr 20 '17 at 9:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.