Tag Info

New answers tagged

1

Great methods already posted! There are also tools from the Processing Toolbox which you could call from your script (this is assuming you are running scripts inside QGIS): Count points in polygon Counts points in polygon (weighted) Count unique points in polygon Taking the first tool, you could call it using: import processing Result = ...


1

the most simple way is to use "Join attribute by location". You can do it from the menu (data managment > Join by location), or with Python ("qgis:joinbylocation") with the option "take summary of intersecting features", computing the sum of a field with "1" at each point.


3

I rewrote my answer from a parallel question counting points in current atlas feature: How to count points within the current Print composer atlas feature in QGIS 2.8? Build a new function in the expression editor: from qgis.core import * from qgis.gui import * from qgis.utils import iface @qgsfunction(args="auto", group='Custom') def ...


1

I assume your polygon is a qgsfeature : http://qgis.org/api/classQgsFeature.html I didn't test it but I guess it would work : len(polygon.geometry().asPolygon()) polygon.geometry() gives a qgsgeometry class. qgsgeometry.asPolygon() gives a list of the point of your polygon. Edit : You want the points inside the polygon? You have points in an other ...


1

I have never worked with QGIS's python API, so my answer is a wild guess. But it looks like QGIS is using GEOS geometry objects similar to django. So this could work in QGIS too: len(geom.coords)


2

In the QGIS source code, you will find the Python code for the Points in Polygon tool ... https://github.com/qgis/QGIS/blob/master/python/plugins/fTools/tools/doPointsInPolygon.py Not sure why you are coding this from scratch. You might want to have a look at Processing which allows to combine these existing tools into automated workflows.


1

The problem is that your geometries have to match in terms of reference (the Spatial Reference System, which is identified by a number, the SRID). So if you want to look up a point in degrees (longitude, latitude), but the data is in a UTM zone, you need to use a transformation to get from something referenced to SRID of 4326 to SRID of 26914. In your ...


0

My issue relates to differing coordinate systems. My source data (the shapefiles) is using SRID 26914. Most GPS coordinates are using SRID 4326. I used this service to convert my GPS points into SRID points and with this query: select * from zones where within(GeomFromText('POINT(611646.08 3365787.37)'),zones.Geometry); I got the results I expected. I ...


0

I know this is a bit late but It might helpful in case SomeOne didn't try Android-Map-Utils library. I have posted this Question's specific methods only for Android. Here you go: http://stackoverflow.com/a/31988461/2054348



Top 50 recent answers are included