# Spatial analysis of classified grid using QGIS

I'm calculation the positional accuracy of linear features using the buffer method and dividing the region using a rectangular grid. Here follows the vectos to be compared.

The grid cells were classified according to difference of vector lengths inside the cell, so the red cells have much more of one vector than another, blue cells are the opposite and yellow cells have similar lengths of both vectors.

I'm testing different cell sizes for the grid. The smaller the cell size is, the better will be the "resolution" for the spatial analysis, so will be possible making inferences of more detailed objects, but when I use a too small cell size, the matrix looks like the vectors themselves, making useless using a matrix instead of vectors.

Here is the grid with cell size 0,001 degree.

Here is the grid with cell size 0,0025 degree.

Here is the grid with cell size 0,005 degree.

Here is the grid with cell size 0,0075 degree.

So there seems to have a optimum size of cell, which is the smallest that don't "look like" the vectors that I want to determine. In this case is 0,005 degree (which was the same size when I tested with some other datasets).

My question is: There is a way to measure that the grid "look like" the vectors? Because currently I'm just using my personal perception instead of science.

Just need a scientific way to show that the 0,001 and 0,0025 degree cell grids looks like the vectors and the 0,005 and 0,0075 degree cell grids doesn't. I can't write in an article paper that the grid "looks" like the vectors because it's too subjective, I need numbers show that.

• I think your best option is using points. gis.stackexchange.com/questions/218808/… Commented Mar 8, 2020 at 21:02
• Actually using points would be another way of assessing data, but my goal is to assess using this method.
Commented Mar 8, 2020 at 23:53
• I think you should think about what are the important metrics for your particular problem that you could derive from the original vector (length? connectivity?) then it is just a matter of comparing those metrics taken from the vector and from the grid. Commented Mar 17, 2020 at 17:09

I would recommend selecting a number of sample squares (of same size) at non-intersecting locations on the features.

Then grow the size of the squares from a set minimum to maximum. Then plot the curves for change in ratio of lengths of the features versus the size of the square.

Then calculate a mean (fit) line. From there use either one of the following options:

1. a threshold of change in ratio (example 0.25 shown) or,
2. change in slope, or
3. inflection point in the curve if there is any

to determine the optimum size of the grid (square).

I am pretty sure that the plot won't exactly look like this example, but based on the plot shape you can make your own rules.

Then you can try and see if that approach matches with your requirement of not "looking like" the original features. If it does not try another approach/threshold/rule on the curve. This might take a few trial and error iterations as you are trying to get to a very subjective quantity by mathematical approaches.