6

I have a dataset that contains many points (representing specimens) with GPS locations taken at the same point. When I map these points as a vector layer, only the uppermost point shows - so, at one given location, for example, there could be 50 data points yet it looks exactly the same as a location that may have just 1 data point.

I am wondering if there is a way to increase the marker size relatively to show this abundance of points at the same location using QGIS? I have tried to use the point displacement tool but I am not looking for the result that this gives with a centroid and a ring of points surrounding. I basically want to create a buffer that has a size in accordance with the number of points at that same lat long to show the relative abundance of specimens at that point.

here is a screen shot, the different colors are classified based on time, the points in the southern/coastal area of NH have A LOT of points whereas the northern area has fewer points

  • I tried to solve the issue using a geometry generator, please see my answer and let me know if it works (the solution is explained in detail and it is really easy to apply). – mgri Apr 30 '17 at 16:16
4

Have you thought of styling the data as a heatmap. This way areas of concentration will show up as more intense colors. I am not sure what program you are using but this can be done quite simply using QGIS. A good tutorial explaining the process can be found at http://www.qgistutorials.com/en/docs/creating_heatmaps.html.

2

I propose an approach which only recurs to a geometry generator and a custom function.


Firstly, go to Layer Properties | Style and then choose the Single symbol renderer.

From the Symbol selector dialog, choose a Geometry generator as symbol layer type and Polygon / MultiPolygon as geometry type. Then, click on the Function Editor tab:

enter image description here

Then, click on New file and type buff_numb as the name of the new function:

enter image description here

You will see that a new function has been created and it is listed on the left side of the dialog. Now, click on the name of the function and replace the default @qgsfunction with the following code (don't delete the libraries imported by default):

@qgsfunction(args='auto', group='Custom')
def buff_numb(layer_name, curr_feat, feature, parent):
    layer = QgsMapLayerRegistry.instance().mapLayersByName(layer_name)[0]

    index = QgsSpatialIndex()
    for ft in layer.getFeatures():
        index.insertFeature(ft)

    tmp_geom = curr_feat.geometry()
    idsList = index.intersects(tmp_geom.boundingBox())
    return len(idsList)

Once you have done this, click on the Load button and you will be able to see the function from the Custom Menu of the Expression dialog.

Now, type this expression (see the image below as a reference):

buffer(
 $geometry,
 0.04 * buff_numb(@layer_name, $currentfeature)
)

enter image description here

You have just run a function which is saying, in an imaginary way:

"For the current layer (@layer_name) and the current feature ($currentfeature), display its geometry using a buffer having a radius of 0.04 decimal degrees times the number of occurrences."

The only thing you need to change is the value of the radius: I expressed it in decimal degrees since you wrote about lat/lon, so I assumed you were using a Geographic Reference System (if not, this is not a problem and you can set any value you want). Therefore, leave the other function parameters as provided.

Finally, click on the Apply button for applying the changes.

You will see something like this:

enter image description here

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.