0

I want to see how accurate/representative a centroid's datapoint value is compared to averaged multiple datapoints values for the same polygon. There are MANY polygons in the same shapefile.

I have a way to call an API based on lat lons. But I am limited in the number of API calls i can make. So I need to explore a few test cases - see the fewest number of points I need to get reasonable data representation.

I have used the QGIS centroid function (the big red dot) and the vector/random points functions (the 8 small white dots). I have put the values next to each: enter image description here

Eg: the centroid value (red) = 52 and the avg of the 8 random points anywhere in the polygon using my calculator comes to 50.13

to make things a little harder, a very few of the data points are null. see below: enter image description here The above example shows there are not always 8 'good' values. In the above example 6 of the 8 are fine, so the equation would need to 'allow' for this somehow.

So this is for just showing 2 example shape files - But there are a LOT to process

QUESTION: I have many shapes, each with their own ID. I have managed to connect each of the 8 smaller dataPoints to the shape ID successfully but how can i automatically evaluate the average of the 8 random points for EACH polygon against the value for the centroid, in a shapefile of multiple polygons?

Note: I'd like their average but maybe a max, min and spread would also be useful.

I'm using QGIS 2.6.1

0

I am not clear on the relevance to the API call limit - I presume you are getting the points or the polygons from a 3rd-party source. However, it sounds like you have all the polygon data and are generating the random points.

The simplest way to do this is not one polygon at a time. If you can load all the points in a single shapefile then just simply do a spatial join (Vector->Data Management Tools->Join Attributes By Location...). In this dialog you can select a number of statistics for the values is the 'join vector' (your points) that you want to add to the 'target vector' (your polygons). This will them sumarize the values of the points that lie within each polygon and do it in one go rather than a separate process for each polygon (e.g. see below).

enter image description here

There is a similar function in the MMQGIS menu too

  • Thanks for your speedy and clear reply. Yes, you are right about the 3rd party API source. This looks like it, but i keep getting Python Error: TypeError: QgsFeature.setGeometry(QgsGeometry): argument 1 has unexpected type NoneType. I've checked data attributes table and there are values in every cell + I've tried all sorts of clean-ups and work arounds, no luck yet. – sixD Mar 29 '16 at 22:44
  • 1
    It sounds like you have some duff data (looks like you have a point or polygon will Null Geometry). If that's the case you need to eliminate it. see here gis.stackexchange.com/questions/74243/… – MappaGnosis Mar 30 '16 at 5:59

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.