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.

Filter by
Sorted by
Tagged with
53
votes
11answers
107k views

Obtaining up-to-date list of US ZIP Codes with Latitude and Longitude Geocodes? [closed]

NOTE: This began as a question on Stack Overflow, which has subsequently been closed. I also noticed a similar question about Most Up-To-Date Source for US Zip Code Boundaries, but I believe this ...
44
votes
3answers
56k views

How to calculate polygon centroids in R (for non-contiguous shapes)

I've spent a little while figuring out the answer to this question. It's not immediately obvious from a Google search, so thought it may useful to post the answer on here. There is also an additional ...
41
votes
8answers
71k 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 ...
40
votes
1answer
37k views

Finding center of geometry of object?

Given a set of 2D or 3D points: How to find the center of geometry of an object? According to the following figure, the center of geometry differs from the center of mass if it is calculated in the ...
30
votes
3answers
83k views

Finding centroid of cluster of points using R

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. Can you ...
21
votes
4answers
39k 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) ...
19
votes
3answers
11k 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 ...
13
votes
4answers
26k views

Get Center of Geometry in OpenLayers 3

Given a Geometry object in OpenLayers 3. How would one go about getting its center? Older versions of OpenLayers provided a getCentroid method. There was also a getBounds workaround. But these appear ...
13
votes
2answers
3k views

Centroid coordinates for odd-shaped polygons

I have a problem in computing the centroids of certain polygons in QGIS (via the geometry tools): for certain polygons - with a strange and rather long shape - the centroids computed are off the ...
13
votes
1answer
6k views

How to take polygon centroid in Postgis

I have table with column name,Latitude and Longitude.I want to update this with polygon name and its centroid latitude longitude.I know there is a function in postgis st_centroid(geometry). But I want ...
12
votes
3answers
10k views

Using Field Calculator in QGIS to update columns with centroid coordinates

In QGIS I would like to update two columns with the centroid easting and northing of my polygons. I am using the field calculator. I have tried using $x and $y but this only seems to work for points. ...
12
votes
2answers
7k views

Calculating a spherical polygon centroid

I'd like a general way to calculate centroids for polygons on a sphere. So far, the best online reference appears to be: Tools for Graphics and Shapes by Jeff Jenness. The method described there ...
11
votes
3answers
5k 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 ...
11
votes
1answer
4k views

How exactly is the centroid of polygons calculated?

I would like to know how exactly QGIS Geometry tools -> polygon centroid is calculating the point coordinates. For example does it divide the boarder of the polygon into small points, take two pairs ...
11
votes
2answers
6k views

How does ArcGIS Desktop calculate INSIDE point for Feature to Point?

Let me back up and say that from what I understand there are two common ways to calculate the centroid of a polygon in ArcGIS Desktop: Using Calculate Geometry on fields within the attribute table of ...
10
votes
3answers
4k views

PostGIS - Get a point inside a line or polygon

I need to get the center point of a line or polygon to make marker for my app. So that when you click a marker the geometry appears (line or polygon). I used ST_Centroid to make it work. The result ...
10
votes
0answers
39k views

How to add Lat/long columns to a point layer which is not in WGS84? [duplicate]

I need to extract the Lat/long coordinates of the centroids of districts. My QGIS project SCR and the different layers have all been set on "WGS 84 / UTM zone 18N". I've created the centroids using ...
9
votes
4answers
3k views

assign and move centroids to their polygons

I m using QGIS 1.8 Lisboa. After calculating the centroids from a polygon shapefile, if some of them lie outside the polygon outlines, I'd like to move them on the polygon they came from. The ...
9
votes
1answer
217 views

Getting dual graph from QGIS

I have a .shp file, and I need to get the dual graph from this file (that is to say, each polygon centroid should become a vertex, and two vertices are linked if their associated polygons are adjacent)...
9
votes
1answer
6k 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 ...
9
votes
1answer
3k views

What is the difference between data access's “SHAPE@XY” and “SHAPE@TRUECENTROID” tokens?

Data Access Search Cursor. What, if anything, is the difference between the tokens "SHAPE@XY" and "SHAPE@TRUECENTROID"? They returned the same coordnates on a test polygon: >>> cursor = ...
8
votes
1answer
11k 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 ...
8
votes
1answer
588 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 ...
8
votes
1answer
2k views

How to create point labels from midpoints of road polylines in QGIS?

I have a road polyline layer (singlepart ie has several features per road, grouped by an id field), and i want to (after merging the parts) find the mid point of the resulting lines. This is for roads ...
7
votes
2answers
5k views

How do I calculate a weighted centroid with respect to a raster, e.g. population weighted centroid

In ArcGIS 10.0, how do I calculate the weighted centroid of a collection of polygons, where I want the weight to be a raster layer. In particular I am using a raster of population counts and would ...
7
votes
3answers
2k views

How to place multiple symbols on one polygon centroid?

I am using QGIS for visualizing the health conditions of elderly living in an old age home, some of the elderly have multiple medical device with them and I want to show them on the map. Suppose I ...
7
votes
1answer
717 views

Zip + 4 Centroids

I have a data set with ZIP +4 codes, and ideally, I'd like to map them (their centroids) as points. I'm not interested in their boundaries (since they're not really geographies anyway). Does anyone ...
7
votes
1answer
4k views

Polygon Centroid Options and Appropriateness (FeatureToPoint, Labels, etc)?

I've found a couple of other Stack Exchange questions related to this, but they were not satisfying. For example: How does ArcGIS Desktop calculate INSIDE point for Feature to Point? does not tell ...
7
votes
1answer
437 views

Connecting centroids of lines sharing same intersection in QGIS?

I have this street network of the center of Turin (IT), composed by lines representing streets, and black points representing intersections. I have computed the centroids of each line and displayed ...
6
votes
1answer
205 views

How to ensure centroid is calculated within polygon?

I am working with a Search Cursor approach to calculate centroids within polygon features. You can see from the screenshot that the script calculates centroids within polygon features, however, some ...
6
votes
2answers
1k views

Identifying cluster centroids using ArcGIS Desktop?

I have a data set of points which are grouped into clusters like so: I'd like to use ArcGIS or Python to create a point layer of the centroids of each cluster but I can't seem to find the right tools....
6
votes
3answers
12k views

How can I calculate the center point inside a polygon in ArcGIS 9.3?

I'm using the JavaScript API 1.6 on ArcGIS 9.3. I have a polygon geometry in an ArcGIS map, and I'm trying to find a way to get the point that lies in the exact center of the geometry. What is the ...
6
votes
2answers
1k views

Сalculate polygon centroids with 'point on surface' function

I want to calculate centroid coordinates X_center and Y_center for every polygon in layer so that in case polygon has not simple shape (e.g. with holes or like in the picture below) centroid will be ...
6
votes
1answer
2k views

How to force QGIS Centroid Fill inside the Polygon?

I would like to use a centroid fill to enable me to place a letter inside a polygon. The advantage of using a centroid fill is that it also shows up in a legend, whereas labelling the layer would mean ...
6
votes
1answer
744 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 ...
6
votes
1answer
430 views

How to assign polygon attributes to grid cells using centroids in QGIS?

I am relatively new using QGIS. Unfortunately I can´t figure out the following yet. I have two polygon shapefiles, one is a grid I have created using QGIS 2.12.3-Lyon (Creat graticule) and the ...
5
votes
2answers
1k views

Computing radius of gyration in PostGIS

The radius of gyration is a measure of the standard deviation of distances between points (and their center of mass), i.e., how frequently and how far points are moving. A formal definition is: I ...
5
votes
1answer
116 views

Distance to Multiple Neighboring Sectors

I have two shapefiles - one of neighborhood polygons and another of centroids within those neighborhoods: For each centroid I would like to calculate: Distance to the next closest neighborhood (and ...
5
votes
2answers
734 views

QGIS giving multiple centroids per polygon?

I have a shapefile for the boundaries of European NUTS regions, and I would like to compute the centroid for each of those regions. When I do this in QGIS (2.6.1 on OSX, using polygon centroids from ...
5
votes
0answers
6k views

Finding the “center of gravity” of multiple points where points have unequal weights [closed]

I'm trying to reduce a set of lat/lons (each with it's own weight) into one lat/lon that is the center of mass of all of the points. however when I map the results the average point falls no where ...
4
votes
2answers
2k views

Getting centroids for multiple lines?

Is there a possibility to get the centroid of each line? When using VECTOR ==> ANALYSIS TOOLS ==> MEAN COORDINATS I always get a centroid of the whole lines. What I need is the centroid of each line ...
4
votes
2answers
96 views

Creating Virtual layer that is the centroid of another polygon layer

There's a polygon layer building and I want to create a point layer centroid containing centroids of building layer. I have 2 more requests: to keep all attributes in the building layer in the newly-...
4
votes
1answer
360 views

Creating centroid inside of polygon [closed]

I want to get the centroids of my multipolygons using Python and GeoPandas. But when viewing the polygons and the centroids points on QGIS, the centroids are not inside the polygons. Here is the code ...
4
votes
1answer
2k views

How to use the field calculator's centroid() Geometry function in qgis 2.0?

There is an option in the field calculator for centroids under geometry which when you double click gives you "centroid( ". What information is required here in order to use this function?
4
votes
1answer
4k views

How do I get the centroid of line with OGR

Can somebody explain how to get the centroid of a feature with ogr? I have no idea what the centroid() function itself does. >>> linelyr = lineshp.GetLayer() >>> f = linelyr....
4
votes
2answers
512 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
4
votes
1answer
43 views

Create centroids from point layer based on unique field names

I have a point layer in QGIS, which I want to filter by attribute values of a specific attribute column. For each unique attribute value, a centroid should be calculated from the respective features. ...
4
votes
3answers
2k views

How to get mean coordinates of features from a point layer?

I have a vector layer containing several points and I would like to generate the mean coordinates of these points, using QGIS only if possible. I'm looking for something similar to centroids, but for ...
4
votes
1answer
2k views

Shortest distance from polygon centroids to a line in QGIS

To get the distance of each polygon centroid from a line, I have tried the Distance to nearest hub algorithm from the Processing Toolbox. The distances I got from the algorithm did not seem correct, ...
4
votes
0answers
2k 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) # ...