# Questions tagged [centroids]

In geometry, the centroid, geometric center, or barycenter of a plane figure or two-dimensional shape X is the intersection of all straight lines that divide X into two parts of equal moment about the line. Informally, it is the "average" (arithmetic mean) of all points of X. The definition extends to any object X in n-dimensional space: its centroid is the intersection of all hyperplanes that divide X into two parts of equal moment.

163 questions
Filter by
Sorted by
Tagged with
39 views

### Auto-generate Grid Reference for Point and Polygon features within existing Shapefile, QGIS

I have various point and polygon layers (shapefiles) which I use regularly in QGIS (3.6.3), and often need to work out their location as an 8 figure grid reference (British co-ordinates, EPSG-code ...
5k views

### Calculating {minimal} distance between polygons in R

I have calculated the surface area of species distributions (merging polygons from shapefiles), but since this area can be comprised of quite distanced polygons, I would like to calculate some measure ...
66 views

### Creating convex hull by expression by aggregating points

I would like to recieve the centroid of a convex hull of a group of points in a layer, grouped by its name. This needs to be done by expressions, available in QGIS 3.4. E.g. I have this list of points:...
33 views

### Centroid of multiple polygons based on value in attribute table

I have a (polygon) shapefile with multiple zones. Now, I would like to calculate the centroid of groups of these zones. The zones have to be grouped based on a value in the attribute table: AreaNr ...
120 views

### QGIS Point on Surface

As far as I can tell, the option to "Create point on surface for each part" in the QGIS Centroid tool is not returning the correct geometry when activated in QGIS (version 3.8.1-Zanzibar/GDAL v 2.2.3 ...
96 views

### Get midpoint of SDE.ST_GEOMETRY polylines?

I have a polyline SDE.ST_GEOMETRY feature class in an Oracle 12c geodatabase (10.7.1). I want to create a view on the feature class that has X and Y columns that contain the coordinates of the ...
511 views

### Misalignment when generating centroids with QGIS

I was wondering if anyone could shed a light on why this behavior is happening in QGIS? I'm pretty confident that the issue here is not due to centroids within polygon. Edit Added a detailed image
52 views

### Getting polyline midpoint coordinates using ArcGIS REST API

I have an ArcGIS 10.7.1 feature service that integrates polyline GIS assets to a work order management system. In the work order management system, I want to retrieve the midpoint coordinates of the ...
51 views

### PostGIS - How to extract polygons in a rectangle by their centroid?

I'm new to PostGIS and I'm amazed what can be done with it! Currently I'm running a query from a large database where I need to split the extracts into smaller chunks so that I'm not bouncing at the ~...
11 views

### Calculate centroid of points (group point) [duplicate]

I am new to PostGIS and I need to calculate the centroid of a group of points that have a cluster identifier (id_cluster). I need to get the latitude and longitude of the cluster centroid.
30k views

### List of central coordinates (centroid) for all countries?

I need a list of the central points (centroid) for all countries: China: lat/long (coordinates of the most central point in China) France: lat/long (coordinates of the most central point in France) ...
38 views

### Speedup function to calculate distance from centroid of building to river segment in PostgreSQL

I am trying to measure the distance from the centroid of a building to a river segment using the following function. CREATE OR REPLACE FUNCTION river_foo_mapper () RETURNS trigger LANGUAGE plpgsql AS ...
121 views

### R sf extrapolate grid from centroids

I've got a grid/raster in R that is represented as centroids of the grid instead of polygons. I am trying to merge that with points. library(sf) nc <- st_read(system.file("shape/nc.shp", package="...
1k views

### Centroids of each grid cell

I have a grid created by mean the following script: # My grid [using package 'sf'] worldGrid <- st_make_grid(x = worldMap, what = "polygons", cellsize = 10) worldGrid <- st_sf(idcell = 1:length(...
10k views

### Calculating Centroid of all lands of Earth using SQL Server Spatial?

I want to find the center point of all lands of the earth. What I have tried up to now is downloading shapefile of all countries and polar parts of the earth. Then I imported that shapefile into a ...
68 views

### Finding coordinates of centroids?

I have a few thousands of polygons, which I found the centroid for each one of them. Now I want to find the coordinates of each centroid. But for some reason the x and y columns are empty and I don't ...
569 views

### Rasterize in QGIS using point as centroid (not vertex)

I'm attempting to make the full switch from ArcGIS to QGIS, but there are a few snags I'm hitting along the way, one of which is in the GDAL "Rasterize" function. My process goes like this: I have a ...
20 views

### Real Centroids plugin QGis 3.4.4 Inavlid Geometry?

The plugin gives on a specific feature the following error message: "Invalid or empty geometries found". Is the following topology not supported?
35 views

### Spatial Join Polygon to Polygon with Centroids Inside features

I have a parcel feature class with +5M features. I want to spatially join it to a feature class of regions to check if the regional code matches that in the parcel data. I've tried using "have their ...
497 views

### QGIS weighted centroid of polygons with weights from raster layer

I am a total novice with GIS and using QGIS as that is what is available to me. I have a vector layer of polygons (about 3500) and a raster layer of light intensity. What I'm working with looks like ...
67 views

### Making path between polygon using QGIS?

I am trying to draw a line (vector layer) of a certain length that that tries as much as possible to dodge the green polygons. Assuming a starting point, is there some sort of line centroid ...
247 views

### Finding census block with highest pop. value within census tract using QGIS?

In QGIS, I'm trying to plot a centroid of only the census block with the highest population within each census tract. So there should only be one point per tract- that of the block with the greatest ...
2k views

### Calculate centre point of SpatialGrid object

I am using R and have a SpatialGrid object similar to the example from this question: Overlay a spatial polygon with a grid and check in which grid element specific coordinates are located ## read ...
62 views

### Combining st_snaptogrid with st_centroid and group by using PostGIS?

I have a table of devices, each of them has a field 'location' that is a postGis geometry(Point,4326) I need to operate a GROUP BY based of the placement on a grid, I'd use ST_SnapToGrid and then I ...
75 views

### Displaying a legend for a centroid, simple marker with size overwrite?

I am new to QGIS and can't figure out how to display a legend for the dot size of a centroid, simple marker. The size of the dot is dependent on a value from a CSV linked to a layer map of Europe. I ...
115 views

### Geoserver SLD: How to get CENTROID of result of INTERSECTION?

In my GeoServer SLD I need to place a symbol (particularly a piechart) exactly on Centroid of the result of Intersection of 2 geometry: geom field from my PostGIS table AND environment variable ...
27 views

### How is the Point on surface tool calculated in QGIS [duplicate]

I am interested to know how the Point on surface tool works in QGIS 3. I am choosing to use this rather than the Centroids tool which works of the "center of mass" methodology because this creates a ...
39 views

### Computing center and zoom level for a set of points

I need to duplicate google's static map image API api on an internal server with no internet access using OpenStreetMaps. I did find the OSM Wiki Page covering this topic. I initially looked at OSM ...
965 views

### Creating centerline of river in QGIS? [duplicate]

I made two river bank lines and I want to associate them. I want to make a centerline using two rows as a base. I managed to make the centre line with a lot of work creating several lines from one ...
8k views

### How to get the centroid of a set of points in PostGIS?

I use PostgreSQL with the PostGIS extension. I have a set of points in the_geom column from a table myschema.myobjects. I want to create a select statement to get the centroid of this cluster, so ...
41 views

### Centroids: Based on travel distance/time and not straight line distances

I am working on a Sales Person Deployment project and quite often come across requests for calculating centroid of a territory where work is distributed across 1000s of ZIP codes. Increasingly we get ...
115 views

### Calculate weighted centroid of a raster layer using GRASS?

I'm trying to calculate the weighted centroid of some raster layers I have, which are basically patches of positive values in a sea of null values. I know I could convert thoses patches to binary ...
35 views

### NHGIS census files get lat/lon from polygon

I've never worked with shapefiles before and I'm having a lot of trouble with something that I think should be pretty simple. So I have the census tract files from NHGIS for 1980 and the structure ...
34 views

### How to compare centrality of points in different shaped and sized polygons

Suppose I have several polygons of varying shape and size, each containing a single point. I want to compare the centrality of each point, and determine which point is more central to its polygon. I'm ...
55 views

### Calculating centroid for polygon layer with several features?

I need only 1 centroid point for the whole layer (more than one polygon) instead of 1 centroid point per feature that you get with the menu -> Vector -> Geometry tools -> polygon centroid tool. Its ...
60k views

### How to determine the centroid of polygons?

I have a polygon vector and I want to quickly attain the centroid of this polygon for insertion in a text document. I am working with QGIS. I searched through other questions and although some are ...
197 views

### Centroid value extraction of Landsat image collection in Google Earth Engine

I have an NDVI collection wich I have created from the combination of different collections Landsat5 and 7. How can I exctract the NDVI values of the centroids of each pixel, of each image from my ...
71 views

### Using centroid point to generate polygon using ArcPy? [closed]

Is this possible to generate polygons from points (which are centroids of future polygon)? I got shapefile with ~250 points + they have got two attributes: length and width. I don't need complete ...
64 views

### QGIS Rasterize PolygonZM

I have a triangulated DEM PolygonZM shape and would like to Rasterize it in QGIS (3.2). I couldn´t find an option to use the geometry´s z value so i tried to create a field and calculate the centroid´...
102 views

### How do I center a polygon on specific co-ordinates?

I need to place a set of polygons onto a set of points, so that each polygon is centered on its corresponding point - any ideas? In MapInfo I can just manually edit the co-ordinates of the center, but ...
172 views

### Is there a way to create pixel centroids inside polygons with PostGIS ?

I am trying to find a solution to do the function of the QGIS-tool 'Generate points(pixel centroids) inside polygons' in PostGIS. In the picture below you can see the output. Is there a way to do it ...
127 views

### Raster centroid and relationships with geoTIFF

I have a list (s) containing information on the probable locations of many animals in South America. For example, this is the type of stored information and what it looks like when plotted for the ...
74k views

### find the centroid of a cluster of points

While searching the web, solutions for finding centroids of polygons come up rather often. What I'm interested in is finding a centroid of a cluster of points. A weighted mean of sorts. I would ...
1k views

### Shapely polygons crossing the antimeridian

Sample data Consider the following WKT Polygon, crossing the international dateline (antimeridian): POLYGON((176 49,-65 49,-65 11,176 11,176 49)) And the following points: POINT(-140 32) # ...
353 views

### Spatial Join In PostGIS where centroid of a polygon is inside another polygon

I have two overlapping polygon layers as shown in figure below. One with small grid polygons and another with a large irregular polygon. I want to join them such that attributes of the large polygon ...
271 views

### Finding center of circle given three points?

I have been trying to solve this problem for quite some time, but can't find a good solution. Given three sets of geographic coordinates how can I calculate the center point. By "center point" I mean ...
89 views

### PostGIS Centroid coordinates (E, N)

I would like to add two new columns in the table (E, N), fill in the coordinates of a polygon centroid using PostGIS SQL code and have the column upadated as soon as I save the edit of a drawing in ...
111 views

### Drawing routes through centroids

According with this link http://postgis.net/workshops/postgis-intro/advanced_geometry_construction.html I'm creating lines that describe routes. I have a table stopcentroids4 like in figure with the ...