3

In QGIS I've loaded the shapefile "province" in which attribute table contains 242 fields (the municipalities of this province) and also two other files downloaded from OpenStreetMap about hotels (points and polygons) in the province.

I need to count the number of hotels for each common and I think the best way to do so is by using the "Group Stats" plugin. The problem is that only 26 commons in the province have at least on hotel in them, the others (242-26=216) don't have one or more of them.

Consequently the plugin generates a table containing only the commons with at least one hotel, but I need the full list of them (242 elements) and the number "0" in the commons without hotels.

How can I do to get this?

2

I would use the Count Points in Polygons tool in the Processing Toolbox -> QGIS Geoalgorithms -> Vector Analysis Tools.

The result is your layer "province" but with an additional field which lists the number of hotels.

Note that this tool counts points, so you'd have to convert your hotel polygonal layer into a point layer using Polygon Centroids or some other conversion tool.

In this example I have world countries with some point data enter image description here

After running the tool, I have a field that counted to instances points intersected a unique country polygon, and as you can see, it retained the zeros.

enter image description here

At this point, you can copy the attribute table to Excel or any other spreadsheet/text editor software.

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.