# 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
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 ...
662 views

### Centroids in QGIS 3.0 not using Python? [duplicate]

How do you calculate centroids in QGIS 3.0? In previous versions, there was an easily accessible tool in the vector geometry toolbar, but it is gone. I've seen ways to do it with Python on Stack ...
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 ...
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 ...
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 ...
2k views

### Getting x,y of polygon in PyQGIS?

Is this the right way to get centroid x and y of a polygon. How do I get centroid x,y, of a polygon layerName = "INTERIOR" layer = QgsMapLayerRegistry.instance().mapLayersByName(layerName)[0] print ...
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 ...
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 ~...
140 views

### Calculating centroids without adding field to table using ArcPy?

I haven't been able to find any bit of code that does this successfully. I need to delete some fields in a table that I'm modifying using a script I'm writing. I don't want the fields to be left on ...
2k views

### Obtaining Centroid from Polygon in SQL Server 2008 R2

I have several spatial layers created in QGIS that are held as spatial data in SQL Server 2008 R2. What I want to do is to find the centroid (OS Easting and Northing) of the polygon from the geometry. ...
237 views

### Looking for information on methods or algorithms used to calculate centroid from polygons across software

Looking for information on methods or algorithms used to calculate point centroids from polygons across software. ArcGIS uses a "gravity model" but can someone point me to the math or a paper on the ...
580 views

### table of polygon centroids

Given a polygon layer, census tracts, how can I generate a table of centroid coordinates in QGIS, or add columns with the centroid coordinates or generate a new layer of polygon centroid points?
63 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´...
506 views

### How to obtain geometric centroid for DataFrame where each row is a unique vertex?

I have looked at several related questions, but have not found a working solution beginning with a DataFrame of vertices for multiple polygons. There are existing solutions that address shapefiles ...
191 views

### Calculate nearest town for 2900 lot centroids

I have 16 town point shapefiles. I have a layer of 2900 centroids for lots. I need to determine the nearest town for each of the centroids. The option I came up with is to Split by Attribute by ...
304 views

### Aggregate by date-time and compute a centroid as an output?

(I would prefer using R if possible) I have a table with coordinates (in latitude, longitude), time information (YYYY-mm-dd HH:MM:SS) and ID information (example provided). I sometimes have multiple ...
608 views

### Correct Projection for calculating centroids of a group of points?

I have a long list of points covering all of North America for which I would like to calculate the centroid (by grouping points based on the "Name" column). My approach is to take the WGS84 co-...
295 views

### Find the vertices of an ROI in XROI using IDL

I need to find the vertices of an ROI shape created in IDL's XROI, so that I can redraw the ROI on multiple images. I know you can find the centroid, area and perimeter with the GEOMETRY command, but ...
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 ...
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 ...
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 ...
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 ...
186 views

### Polygon Centroids working for only some Polygons in PyQGIS?

I have a building Layer(Full of Polygons).I want to get centroids of polygons and save them as point layer.I am using python console within Qgis 3.0. I have tried below code.I got my Centroid Layer(...
327 views

### should ST_Centroid and ST_Transform be applied in a particular order?

I am a complete newbie using GIS, and particularly using postgresql-postgis. I have a table with administrative boundaries where limits are multipolygons defined in utm (EPSG:23030). I want to ...
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(...
111 views

### Directions based on polygon centroid and average/median point of adjacent polygon's touching border

I have a layer containing multiple polygons, and I am trying to find a way to identify the directions of the adjacent polygons of a certain polygon. The directions would be based on the main polygon ...
144 views

### Creating new polygons from multiple points with centroid coordinates of polygons using ArcGIS Desktop?

How to Create from an Excel file or shapefile with multiple points with the coordinates of the centroids polygons, now I would like to create an amount x of polygons with the information of the points,...
512 views

### Generate Tessellation & Centroids using ArcGIS Pro?

I first generated a square tessellation (using Generate Tesselation) using the following: arcpy.GenerateTessellation_management(Output_Feature_Class="/File Location Removed", Extent="371935.1483 ...
345 views

### Transforming polygons centroids in order to make hexbin map in QGIS? [closed]

I want to make a hexbin map of a particular kind. Hexbins can be used to embrace several points in the same area, like in this example : With this method, a large city can be covered by one hexagon, ...
470 views

### How to implement a shoelace formula into Python 2.7.8 [closed]

Here's the image of the equation I'm using, it is a shoelace formula. I need help to point out what each variable represents and how to apply this in python script, math is not my strong-suit! From ...
50 views

### Error adding feature to centroids in QGIS [closed]

I want to map forest stands. I have the compartments as centroids and I am trying to add a feature by snapping to them and creating polygons. Each time I click, however, it displays a box titled "...
68 views

### Postgis routes diagram point-to-point

I have a set of centroids to which are related a set of points characterized by linename. The table with the points contains these fields: id ¦ linename ¦ lat ¦ lon¦ I would like to make a diagram ...
515 views

### How can I find the center of the circle or ellipse I just created

I need to draw circles and ellipses with a certain length/width/ radius. I used the rectangles ovals digitizing plugin to create them, but only measured roughly the circles' radiuses. It would be ...
1k views

### How to get a set of all buildings of an OpenStreetMap section in form of single points / Multiple polygons as one point

The objective is to get a set of all buildings of an OpenStreetMap section in form of single points in a shapefile. I downloaded the section from OSM. Imported the section into QGIS (and later ...
1k views

### Locating the centroid (center of mass) of spherical polygons

I'm trying to work out how best to locate the centroid of an arbitrary shape draped over a unit sphere, with the input being ordered (clockwise or anti-cw) vertices for the shape boundary. The density ...
2k views

### How to move a point shapefile to the centroid of a polygon?

I have this point shapefiles on top of a bounded polygon. I would like to move each point to the centroid of each bounded polygon. Is there an automatic way in ArcGis 10.1 of solving this? Like in the ...
322 views

### Calculate centroids using PyQGIS

I am trying to calculate the centroids of polygons using PyQGIS. When I calculate the centroids with the interface (Vector --> Geometry Tools --> Polygon Centroids) everything works out. However, I ...
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 ...
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 ...
177 views

### Generating polygons from centroids with rotation and dimensions [closed]

I found this from @crmackey at Creating rectangles on centroid points in ArcPy? It is exactly what I was looking for and works great, however I need to add rotation to the polygons. How could I add ...
1k views

### Compute centroids and buffers for multiple polygons in Google Earth Engine

I have a dataset with many polygons that come from a fusion table ('xxxxx'): var polygons = ee.FeatureCollection('xxxxx'); I want to compute the centroid and a buffer of Z meters for each of these ...
463 views

### Calculating centroids in decimal degrees using ArcPy without reprojecting vector data?

I have vector data not in geographical coordinate system (i.e. not in WGS 1984). How to calculate object's centroids using arcpy without reprojecting the data itself? I have tried to do this but it ...
317 views

### Calculating Centroids with Zonal Geometry in ArcGIS

I have a shapefile containing polygons. Each polygon is defined by its postal code. I want to calculate the centroid of each polygon using Zonal Geometry. Sadly, for some polygons there are no ...
1k views

### Plot points by longitude and latitude on a map created by centroids

I'm searching for a way to plot some points for which I have the longitude and latitude (using Google Maps API) on a map created with centroids. I succeeded to do it by using functions such as ...
143 views

### Polygon Torque Map- problem changing polygons to points

I'm trying to alter my data on cartodb map to get maritime emissions over about 20 years- by country. Hence trying get a torque map for polygons, and by changing polygons to points based on a ...
62 views

### Identify polygons greater than n-th percentile and perform further analyses using arcpy

My goal is to identify tracts that are above the 99 percentile of a variable (xvar), to dissolve contiguous tracts by summing a variable (yvar), and to get the coordinates of the centroids (...
2k views

### How to obtain Census Tract Centroids when Bureau's web site unavailable?

Does anyone have the Census Bureau file of census tract centroid, for either 2000 or 2010 tracts? With the Bureau's web site shut down, the only available file is the EPA's, and it omits about 500 ...