1

I work at urban planning and I am trying to create an hexbin map from landscape use of a small city.

I have different polygons (vector layers) like buildings, roads, gardens, services, industry, and so on... that doesn't overlap.

I also have created a HEXAGONAL GRID (polygons), and each hexagon has 10.000 m2 (1 ha).

My idea is to create something like this: https://pbs.twimg.com/media/CEiZ9eEVIAApcSO.png

A cool and very interesting alternative to point-based maps, in my opinion...

My first (1) option was to go to: menu -> Vector -> Geometry tools -> polygon centroid and create a centroid point layer, and then "count points in polygons" but I came to the conclusion that much of the information I have, like what is the use that is predominant inside each hexagon, is lost...

So I am now searching for a method that counts area (% of the 10.000 m2) of the different uses... For example for green areas, what is its predominance inside each hexagons?

How can I "pass" that attribute to the hexagonal shape?

Should I clip building-green areas-industry layers, with the grid, and the perform a spatial join (join by location)?

Or is there another way to perform this?

I am using QGIS 2.14 ESSEN.

____________________EDITING____________________________

To specify my question:

I want to know if it is possible to calculate all red-pink-blue-green area inside each hexagon, knowing that every hexagon has 10.000 m2.

My objective is to know for hexagon ID = n:

Building area  = x %
Green area  = x %
Industry area  = x %
Roads area  = x %

And for all other 450 Hexagons.

Do I have to clip with the grid and then perform spatial join?

enter image description here

  • Intersect and find dominant land use, see arcgis workflow gis.stackexchange.com/questions/217729/… – FelixIP Aug 2 '17 at 9:37
  • Can you help I little bit more? I am working with QGIS. Just a simple intersect will do it? – M_M Aug 2 '17 at 9:49
  • Sort interest in descending order by area. Remove duplicate rows of grid id. This will leave 1 (dominant!) Land use per grid. Transfer it's name to grid through join – FelixIP Aug 2 '17 at 19:35
1

By using PyQGIS, next code calculates, as area percentage of hexagonal (or part of it) feature layer, for each feature belongs to polygon_layer; equivalent to layer with buildings, roads, gardens, services, industry, etc.

registry = QgsMapLayerRegistry.instance()

grid = registry.mapLayersByName('hexabin_grid')
polygon_layer = registry.mapLayersByName('polygon_layer_mult')

feats_grid = [ feat for feat in grid[0].getFeatures() ]

feats_pol = [ feat for feat in polygon_layer[0].getFeatures() ]

for i, fg in enumerate(feats_grid):
    for j, fp in enumerate(feats_pol):
        if fg.geometry().intersects(fp.geometry()):
            total = fg.geometry().area()
            intersect = fg.geometry().intersection(fp.geometry()).area()
            print 'i: {}, j: {}, %area: {:.2f} % of i'.format(i, j, (intersect/total)*100)

I tried above code out with multipart layer (equivalent yours with buildings, roads, gardens, services, industry, etc) and hexabin layer (48 features) of next image:

enter image description here

and after running it, it was printed at Python Console of QGIS, values of i (feature grid) and j (feature of another polygon layer) indexes and area percentage of features layer inside each feature grid.

i: 0, j: 0, %area: 100.00 % of i
i: 1, j: 0, %area: 100.00 % of i
i: 2, j: 0, %area: 74.97 % of i
i: 2, j: 1, %area: 25.03 % of i
i: 3, j: 0, %area: 59.38 % of i
i: 3, j: 1, %area: 40.62 % of i
i: 4, j: 0, %area: 94.50 % of i
i: 4, j: 1, %area: 5.50 % of i
i: 5, j: 0, %area: 100.00 % of i
i: 6, j: 0, %area: 100.00 % of i
i: 7, j: 0, %area: 100.00 % of i
i: 8, j: 0, %area: 100.00 % of i
i: 9, j: 0, %area: 86.99 % of i
i: 9, j: 1, %area: 13.01 % of i
i: 10, j: 0, %area: 26.00 % of i
i: 10, j: 1, %area: 74.00 % of i
i: 11, j: 1, %area: 100.00 % of i
i: 12, j: 0, %area: 0.47 % of i
i: 12, j: 1, %area: 99.53 % of i
i: 13, j: 0, %area: 60.14 % of i
i: 13, j: 1, %area: 11.00 % of i
i: 13, j: 2, %area: 28.86 % of i
i: 14, j: 0, %area: 98.69 % of i
i: 14, j: 2, %area: 1.31 % of i
i: 15, j: 0, %area: 100.00 % of i
i: 16, j: 0, %area: 100.00 % of i
i: 17, j: 0, %area: 26.64 % of i
i: 17, j: 1, %area: 73.36 % of i
i: 18, j: 1, %area: 100.00 % of i
i: 19, j: 1, %area: 89.17 % of i
i: 19, j: 2, %area: 10.83 % of i
i: 20, j: 1, %area: 84.97 % of i
i: 20, j: 2, %area: 15.03 % of i
i: 21, j: 0, %area: 12.32 % of i
i: 21, j: 2, %area: 87.68 % of i
i: 22, j: 0, %area: 52.67 % of i
i: 22, j: 2, %area: 47.33 % of i
i: 23, j: 0, %area: 100.00 % of i
i: 24, j: 0, %area: 100.00 % of i
i: 25, j: 0, %area: 98.95 % of i
i: 25, j: 1, %area: 1.05 % of i
i: 26, j: 0, %area: 50.64 % of i
i: 26, j: 1, %area: 49.36 % of i
i: 27, j: 0, %area: 6.84 % of i
i: 27, j: 1, %area: 35.87 % of i
i: 27, j: 2, %area: 57.29 % of i
i: 28, j: 0, %area: 22.94 % of i
i: 28, j: 1, %area: 0.58 % of i
i: 28, j: 2, %area: 76.48 % of i
i: 29, j: 0, %area: 17.15 % of i
i: 29, j: 1, %area: 0.21 % of i
i: 29, j: 2, %area: 82.65 % of i
i: 30, j: 2, %area: 100.00 % of i
i: 31, j: 0, %area: 41.89 % of i
i: 31, j: 2, %area: 58.11 % of i
i: 32, j: 0, %area: 100.00 % of i
i: 33, j: 0, %area: 60.12 % of i
i: 33, j: 1, %area: 39.88 % of i
i: 34, j: 0, %area: 85.66 % of i
i: 34, j: 1, %area: 7.84 % of i
i: 34, j: 2, %area: 6.50 % of i
i: 35, j: 0, %area: 94.47 % of i
i: 35, j: 1, %area: 2.87 % of i
i: 35, j: 2, %area: 2.66 % of i
i: 36, j: 0, %area: 41.35 % of i
i: 36, j: 1, %area: 10.80 % of i
i: 36, j: 2, %area: 47.85 % of i
i: 37, j: 2, %area: 100.00 % of i
i: 38, j: 0, %area: 8.93 % of i
i: 38, j: 2, %area: 91.07 % of i
i: 39, j: 0, %area: 46.51 % of i
i: 39, j: 2, %area: 53.49 % of i
i: 40, j: 0, %area: 100.00 % of i
i: 41, j: 0, %area: 100.00 % of i
i: 42, j: 0, %area: 100.00 % of i
i: 43, j: 0, %area: 100.00 % of i
i: 44, j: 0, %area: 53.63 % of i
i: 44, j: 1, %area: 46.37 % of i
i: 45, j: 0, %area: 50.91 % of i
i: 45, j: 1, %area: 1.14 % of i
i: 45, j: 2, %area: 47.95 % of i
i: 46, j: 0, %area: 31.93 % of i
i: 46, j: 2, %area: 68.07 % of i
i: 47, j: 0, %area: 85.94 % of i
i: 47, j: 2, %area: 14.06 % of i

where j indexes would be equivalents to buildings, roads, gardens, services, industry, and so on.

0

Thank you for help.

I have to say that I am not that confortable with python language... So I had to tought of a diferent aproach:

1) INTERSECTed my Hexagonal grid with my polygons 2) Then I used DISSOLVE tool by Hexagonal_ID, while summing area with Dissolve with Stats Plugin 3) So I ended up with a table with every intersect area, by HEXAGONAL ID for every polygon layer

I guess it was a more exhausting methodoly but it worked.

Fell free to comment on my method, or suggest other aproachs.

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.