You can do this. First, create the column in your table.
ALTER TABLE point
ADD COLUMN cid integer;
Then update your table based on your query. When you do your DBScan query. Make sure you select an id field that can be matched back to the points.
SET cid = subquery.cid
FROM (SELECT id, st_clusterdbscan(geom, eps := 0.01, minPoints := 5) over() as cid
If you prefer to address this issue in "the raster logic", then there are a few filters that you could consider. The best choice will depend on the spatial distribution of your pixels of each class inside your "background" values, but here are two potential solutions :
if your patches that you want to remove are relatively large, then you should use "sieve" ...
ST_ClusterWithin is an aggregator function, meaning it will not generate a new geometry, but simply output the geometries that were input to it, albeit in a particular grouping (the clusters, in this case).
If you want a visual representation of your clusters, you can do so by feeding your resulting Geometry Collections into ST_ConvexHull. This will give ...
Interesting, haven't seen the Fréchet distance before (it seems to be the equivalent of Hausdorff distance, but for lines rather than polygons)
It looks as if there may be an implementation in the MDAnalysis library.
However, this library appears to be for analysing movements of molecules ... it's python built on numpy, but is not designed for geospatial.
In terms of a local autocorrelation (nonstationarity) statistics, there really is not one. Join-counts is adequate for hypothesis testing of global clustering in binary process, albeit very scale dependent, but not for multinomial data. I am not even sure what the underlying hypothesis test would be here, especially with ordinal data. One has to ask, how ...
I have been able to work around the limitation by "pre-computing" the values for eps and inferring reasonable values of the other subqueries which where previously referring to the recursive CTE.
Note that the new solution may create clusters larger than wanted (5000 in the query below) if you run-out of "pre-computed" values. This helps ensure that the ...
Given you already have your RED 6km span points which I am referring to red_points, you can do something like this to obtain your 3X3 200m grey_points.
(please, adjust the sign (+/-) as you wish to achieve your result. Also, here 200 is in meters as long as the units of your reference system is meter.)
red_points = "your_red_points_fc_here"
You get an entry for each voter because you are grouping on the voter column as well, which results in groups that are all single rows. And you cannot include voter_name in the query unless you either aggregate on the column or build groups that include the column, which means that you have to add one more query level to achieve your objective.
Here are a ...
20000 is most probably in degrees - which is why all of your geometries are in cluster 0 (if it was failing to cluster they would be in NULL). You need to convert your data to be in metres by reprojecting into a local projection (SRID). For example EPSG:5243 would work, so something like:
ALTER TABLE table ADD COLUMN geom_m GEOMETRY;
UPDATE table SET geom_m ...
Just a technicality
(should be a comment but I lack reputation):
In any case this needs a coordinate reference system that gives you euclidean distances in your attribute space, for example UTM:
# specify original CRS:
proj4string(house) <- CRS("+proj=longlat +datum=WGS84")
# transform to new CRS (need to specify correct UTM zone):
It's unclear to me what you are trying to do here, but if you need to do an unnest, you are better off using ST_ClusterDBScan if you have PostGIS 2.3+.
I'm also not clear why you have two calls to ST_ClusterWithin each with different distance.
WITH c AS (SELECT ST_ClusterDBScan(centroid,100,10) AS cluster_num, ...
I've done something similar to this hundreds of times. You didn't provide enough information to provide more than a stick-figure solution, but one way to do it would look like this:
UPDATE mytable t
SET colval = vt.colval
FROM mytable t
JOIN othertab j ON j.geomcol && t.geomcol AND
My interpretation of your question is that you are not simply trying to set a zoom level on an interactive map, and your point groups near each other do not share a common attribute. If my understanding of your question is incorrect, please modify your question to provide more details, as you will get a different answer.
Based on my two assumptions, and ...
No time for more improving or testing, but: for a single, more generic recursive term, and possibly better performance, try
params AS ( -- convenience variables for testing parameters
SELECT 10 AS max_size, -- max. cluster size
1 AS min_points, -- 'min_points' parameter
ST_GeometricMedian should compensate for outliers in MultiPoint geometries, e.g. sth. like:
SELECT ST_GeometricMedian(ST_Collect(geom)) AS geom
General info on the concept, and difference to weighting (i.e. ST_Centroid).
As an alternative, using
ST_ClusterDBSCAN(geom, <eps>, 1) OVER(PARTITION BY ...
Let's work through a Haussdorf clustering of lines.
We'll use the sf package for spatial data and distance calculations:
starting with your final x, lets group everything by cyclone number, make line features, and keep the number of points in the group:
cyclones = x %>% group_by(CycloneNo) %>% mutate(n=n()) %>% summarize(n=mean(n),...
Vast question, a matrix distance is really not the way to go for a lot of points. If you want to do it yourself, look into quadtree and nearest neighbourg. The classicals algorithms used for clustering would be DBScan or Kmeans, but for your exemple you can simply use Postgis and the function ST_ClusterWithin (and you can test ST_ClusterDBSCAN and ...
Actually, the cluster renderer does support categorized styles.
Next to the word Renderer there's a dropdown menu, where you can choose Categorized.
Under the Renderer type selection menu, click the button Rendering Settings... to access the normal layer style panel settings for a Categorized style.
Categorize by the field that has values. Un-check the ...
The eps distance is the maximum distance between points in the cluster, not the maximum width of the entire cluster.
So if you have points A, B, and C, as long as each point is within the eps distance of one other point, then it gets included in the cluster. If the eps distance was 1 km, A could be within 1 km of B, and C can be within 1 km of B, but A can ...
Maybe you can try an iterative approach:
You first use ST_ClusterDBSCAN with a big eps and a small minpoints, and then you isolate the points that are in a cluster too big for you, for exemple using the radius of the bounding circle (general idea, not tested):
sqrt(ST_Area(ST_MinimumBoundingCircle(ST_Collect(points)))/pi) > your_threshold group by ...
Seems like the correct name of the function is
In general, when you get an error: " 'module' object has no attribute X", it means that there is no function named X in the library/module/class, which means you probably have written something wrong in the name of the function, which should be quick to ...
Not a full-fledged answer, but:
Build an adjacency matrix of your polygons, to know which is adjacent to which. This may be done either through the R provide scripts, or Python, as far as I know there is no current implementation built in QGIS;
Search via breadth-first search for the neighbours, and keep on checking whether you got to the population ...
You are convolving what your experimental unit actually is. For information contained in "buffers" you are going to have within unit and between unit variation. You cannot collapse the within unit variability and quantify autocorrelation nor can you evaluate independence between units without addressing the underlying distribution(s).
For evaluating the ...
Make an adjacency list:
touching_list = st_touches(milan_primary_highways)
this isn't NxN so won't grow - its a list of length N where each element is only the adjacent elements. This might help it scale up to larger problems.
Now use igraph to create a graph objects and get the connectivity:
g = graph.adjlist(touching_list)
c = ...
I finally found a way, I scripted my own clustering function in R which works relatively great. The idea is to start from the neighbor list and iteratively make groups. The algorithm looks a little bit like that:
Make one group
select first polygon
find it's neighbors
find the neigbors neighbors
repeat until target size reach
You can use ClusterPoint plugin. After installing the plugin, a tool named doCluster is added to Processing Toolbox.
Cluster Points adds a new field Cluster_IDto the attribute table as output. (In the image, points are styled categorically by Cluster_ID)
It seems as though the table must be formatted with the unique ID field in order (or at least grouped). In the Weights.py script which is throwing the error there is a function that reads the table and checks the value against a list. Every time the tool processes a new unique ID it removes it from the list. If the IDs are not grouped it will fail when ...