2

I'm new to mapping concepts and software.

I need to report on the intersecting area of postcode polygons and NBN Rollout areas. So postcode 3000 has 3 units of area in rollout region 1 and 6 units of area in rollout region 2.

Postcode polygons come in an ESRI Shapefile. NBN Rollout regions come in a KML file.

I've loaded both into QGIS, saved them into a new file with CRS = EPSG 4326 then loaded these new files. Now the layers have the same CRS.

I then went to Vector > Data Management Tools > Join attributes by location.

Here are the settings I've selected:

Settings for intersect.

That runs for a few minutes before throwing this error:

Error message

The log messages panel gives the following log entry:

Uncaught error while executing algorithm Traceback (most recent call last): File "C:/PROGRA~1/QGIS2~1.18/apps/qgis/./python/plugins\processing\core\GeoAlgorithm.py", line 203, in execute self.processAlgorithm(progress) File "C:/PROGRA~1/QGIS2~1.18/apps/qgis/./python/plugins\processing\algs\qgis\SpatialJoin.py", line 158, in processAlgorithm outFeat.setGeometry(f.geometry()) TypeError: QgsFeature.setGeometry(QgsGeometry): argument 1 has unexpected type 'NoneType'

The final output I want to see is something like this:

postcode    rollout_region  area
3000        1               27
3000        2               44
3141        4               94
3141        6               46
3006        8               70
3006        9               41
3006        11              38

if the problem can be solved more easily in some other open source software I'm happy to try that.

2 Answers 2

2

QGIS doesn't like you trying to join polygon to polygon this way. It doesn't know what to do with the geometry (QgsFeature.setGeometry(QgsGeometry): argument 1 has unexpected type 'NoneType'). It would better work with a mix point/polygon.

You rather need some Union tool if you want to keep all of the input geometry (below A area, plus A x B overlay area, plus B area). You will then have some data in the attribute table, that you can use afterwards in Excel.

  • Make sure each rollout area has a unique id, each postcode area its unique postcode code.
  • Do the Union, then update an area field.
  • Then export to Excel.
  • With a pivot table, you'll have your info.

Union

Union

Description

This algorithm combines the feature(s) of both layers. Features that lie partially within the other layer’s features will be split. Areas that lie within both layers will be added as new features. If any features are selected in either of the layers, then only those features are used in the operation. If no features are selected then the operation is performed using all features.

Parameters

  • Input layer [vector: any] : One layer containing feature(s) to be unioned.
  • Input layer 2 : [vector: any] : Second layer containing feature(s) to be unioned.

Outputs

  • Union [vector] : Where to save the union layer. Can be saved to file, a temporary file or a memory layer.

Nb : If you only need A x B area, you'd rather need to look out at the Intersect tool

2

Following @gisinside (I chose Intersect option), my suggestion is a Virtual Layer.

(1) An experimental data

  • postcode polygon layer: id and code fields. (code= 3000, 3006, 3141)
  • nbn polygon layer: id and rollout fields. (rollout= 1, 6, 8, 11)

enter image description here

(2) Go to Layer | Add Layer | Add/Edit Virtual Layer

  • Click on Import and embed these two (postcode and nbn) layers.

enter image description here

  • Please modify below Query to fit your layer name and fieldname
  • In this example I chose EPSG:3857 to reproject, but it is known for its inaccuracy in distance/area. Please choose appropriate CRS.

Query:

SELECT postcode.code, nbn.rollout, 
       st_area(st_transform(setsrid(st_intersection(                                       
               postcode.geometry, nbn.geometry
               ), 4326), 3857)) AS area_m2 
FROM postcode CROSS JOIN nbn 
ON st_intersects(postcode.geometry, nbn.geometry) = 1

(3) You will obtain a table something like this:

enter image description here

1
  • 1
    Nice answer ! I didn't even know about this feature, thanks.
    – gisnside
    Commented Jan 24, 2018 at 18:17

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.