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.

260 questions
Filter by
Sorted by
Tagged with
98 views

Moving features of different geometries at the same time in QGIS

In QGIS 3.34 I would like to move a point feature and a polygon feature at the same time. The polygon is a round buffer around a point. I am only able to edit the point and polygon one after the other....
• 107
24 views

QGIS Radial Flow map: How can I move a centroid point to the middle of a country?

How can I move a centroid to a centre of a country in the QGIS world map and doing a Radial Flow map as described here: https://www.youtube.com/watch?v=dEHMnioynN8 As I understand You create ...
1 vote
174 views

Creating radial lines from center of polygon to edge in QGIS

I have a set of polygons for which I need 16 radial lines each from the centroid of the polygon to the edge (see image). So far I have only found a python script to create radial points for a circle (...
• 91
10 views

How to find PLSS section corners, given the ring of nodes?

Given a ring of nodes and centroid representing a US Public Land Survey System (PLSS, or Canada DLS) section, find the four corner nodes. Do the same, but without needing the centroid.
• 418
173 views

Splitting polygons though centroid like Pizza Slices in QGIS

I am aware of how to create centroids and how to divide a polygon by line, but not how to create those lines from each centroid. I was wondering if anybody knows a technique/algorithm/plugin that ...
• 81
1 vote
61 views

Drawn centroid with function make_circle

I'm using the following function to draw a circle at the centroid position of a layer of points grouped by the "ID" field and excluding NULL values: make_circle(centroid( concave_hull( ...
• 1,142
102 views

Selection by Location with Have their center in - GeoPandas

I have two polygon GeoDataFrames. I have read them in with the following: import geopandas as gpd poly1_path = r”.\Input\poly1.shp” poly2_path = r”.\Input\poly2.shp” poly1 = gpd.read_file(poly1_path) ...
• 23
74 views

Can I utilize vectorization to improve performance instead of iterating over QGIS Features?

I am using Python to write a standalone application with QGIS. The application uses requests to allow the user to update a shapefile from the internet on demand. After fetching the shapefile, I need ...
97 views

Export all polygons to SVG using QGIS

For a game, I needed to draw the districts of my city in QGIS. I created a layer and drew many polygons on it. I have now a table with four columns, being "fid", "name" and "...
• 143
1 vote
125 views

Multipolygon to Points

I'm currently mapping out around 10 layers worth of polygons all in a polygon feature as shown in the image below. I'm now trying to create a heatmap for each layer to show where lies the highest ...
134 views

Centroid data points for US states

I need to map some data related to states in the USA. I have polygon data for each state but my dataset needs to be mapped by points. How do I find centroid points for each state (not polygons)?
97 views

Creating centroid layer from selection using PyQGIS

I'm trying to create a centroid layer from a selection with Python. I manage to make a selection based on features with expression : code_com = '001' section = '\'0A\'' numero = '0502' layer = iface....
• 21
1 vote
53 views

mviewer/OpenLayers: Create proportional circles from the centroids of each polygon in a layer

I have created a mviewer map. This one is based on OpenLayers 7.1. I created a map from a point layer added as WFS from my GeoServer. This layer shows the population using proportional circles. The ...
• 649
272 views

Convert centroid data to lat/long coordinates

I have a geoJSON file from Alameda County, California, that says it is based on "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:...
712 views

QGIS: centroid of polygon layer

I would like to determine the center of this layer, when I look for the centroid I get the centroid of each separate shape but I want the centroid of the total layer.
• 615
1 vote
24 views

How to create a copy of a geodataframe switching polygons for centroids (points)? [duplicate]

I'd like to take an existing geopandas geodataframe (polygon) and create a copy, retaining all attributes of the first geodataframe but swapping out each feature's polygon geometry for its centroid. ...
• 1,567
126 views

Population weighted centroids imported into QGIS are located off the coastline

I am new to QGIS. Imported the census population weighted centroids shape file retrieved from NHGIS as a vector layer into QGIS and they are nearly always where I would expect them but a sprinkling of ...
• 31
331 views

Extract coordinates out of list() in R (bbox) and get centroid of bbox

I have a data.frame with a column called geo. In this column, there are lists with coordinates that represent a bounding box. I would like to grab the coordinates that are inside each list and ...
113 views

How to make the grid polygons assume the inside centroid attributes of another layer QGIS

I have a square grid and I have multiple centroids on another layer. These centroids have many attributes as values. I want for each grid cell to assume the attributes of the centroids inside them. ...
396 views

GeoPandas - can't write to file because field names are tuples (AttributeError)

I have created a new shapefile by dissolving and computing centroids from an existing shapefile. I have also aggregated values of the existing shapefile to use in the new shapefile. However, when I ...
• 197
793 views

GeoPandas centroids based on field, while keeping aggregated values

I have a shapefile containing 85.000 points representing houses. I want to create a new shapefile containing the centroid of each subset of houses with the same postal code. This centroids file should ...
• 197
664 views

Spatial join based on polygon centroids in GeoPandas

I have two polygon shapefiles. I'd like to spatially join them in Geopandas based on their centroids. Basically doing the same thing as have_their_centers_in in ArcGIS but with GeoPandas. I see the ...
• 37
841 views

QGIS distance in meter instead of decimal degrees

I use a shapefile of the US counties and I want to create buffer zones around the centroid of each county. However, the distance is measured in decimal degrees. As far as I understood, I have to ...
850 views

How to compute weighted mean centroid of lat+lon points taking into account spheroid

I have a bunch of points (lat+lon coordinates). Each one has a weight. I would like to get a weighted mean centroid of the points, taking into account the spheroid (as my points are scattered across ...
• 127
480 views

Creating/generating centroids point features from raster image in console in QGIS [duplicate]

I have a 1-band TIFF/raster file showing a value for each raster cell. I want to get those cell/pixel values of the TIFF extracted to a CSV file. I guess there are two ways of doing this. First, ...
175 views

Creating raster from centroids of another raster using QGIS/GDAL

I have a raster that is input into a model which generates outputs in a CSV format (Lon, Lat, Z value). The Lon and Lat are the centroids of the original raster's pixels. I want to use these centroids ...
• 11
2k views

Finding the centroid of every pixel in a raster Python

I am trying to get the centroid of every pixel in a aviris hyperspectral image (a raster) but my results are not quite as expected. The centroids don't seem to line up with the center of every pixel, ...
638 views

Ordering polygons from north to south in QGIS

In QGIS 3.10 I want to order 22 polygons north to south based on their position using their centroids. I have used the centroids tool to determine where their middle is. But now I'm not sure now how ...
• 53
250 views

Plot points around defined centroid using degrees and distance in QGIS

I have a shapefile plot_center of plot centroid points (like picture below) and then I have a Excel table with trees which corresponds to plot centroid points by common field ID. The excel table ...
• 600
307 views

QGIS rotate CRS around a new centre

I've been given some NetCDF data in a Mercator projection with a centre longitude of 173.9581, centre latitude of -41.0870 and rotation of 40 degrees. I have tried to create a new CRS based on ...
• 231
1 vote
829 views

Computing visual "center" of irregular polygon

UPDATE: centroid is fine, my initial implementation was not weighing the edge length. With that fix all is well. I am using the centroid to render a marker in the "center" of a parcel, but ...
• 2,951
453 views

Rasterize a vector layer where pixels just need to include a vector inside, not necessarily on the center

QGIS(3.22) I'm trying to compare a vector layer to a raster layer by rasterizing the layer to the same pixel size as the raster and then using raster calculator. I just want to know which pixels in ...
241 views

Centre of mass w.r.t. a raster

I have a vector layer of polygons, and a raster layer with real numbers. I would like to get for each polygon, a 'centroid', not purely based on the geometry of the polygon (such as provided by Vector ...
• 155
169 views

Scaling polygons in vector grid around polygon centers in QGIS

I have a aerial image with a vector grid overlaid in QGIS. Is it possible to scale the individual polygons (scale all of them by the same size) around their individual centroids? For example, to cut ...
• 61
1 vote
545 views

Create polygons around centroids, maintaining information

I have a csv file which contains points (latitude, longitude) around all the African continent (see the picture for clarification). Apart from the latitude and longitude, it contains more information. ...
• 618
1 vote
1k views

Getting centroid of area and info in popup in Leaflet

I'm trying to get the centroids of each of the features of a polygon layer, and the popup with its info inside: but I'm not able to show those centroids. Something is wrong in my code, the variables ...
• 488
1 vote
2k views

Convert MultiLineString to one LineString

TLDR: I was not able to change the String type from MultiLineString to LineString and keep the line together but there is a way to still represent that as a symbology. So my problem is solved, but the ...
• 667
195 views

Creating centroid on curved surface in QGIS

I am using QGIS 3.16.13 to build a map in which I have 98 adjacent polygons that represent areas of ocean around the coastline of an island. I want to have a centroid inside of each polygon, even ...
• 53
675 views

Generation of centroids outside polygon

I have a polygons layer and creating a centroid layer of it, some of them are generated outside my polygon, what cause a selection problem after. Does anyone know how to solve this?
• 313
26 views

Getting minimum latitude of centroid geometries in a folder using ArcPy

My goal is to print names of feature classes and corresponding minimum latitude of centroids of geometry for all shapefiles in a folder. In total I have 5 shapefiles and I'm trying to loop through ...
• 511
579 views

Calculating raster weighted centroids for polygon in QGIS

I need to calculate centroids for each feature in a polygon layer, weighted by the values of a raster. So the centroids are shifted towards higher raster values. I found a way, but it is complicated. ...
• 74.9k
1k views

QGIS - how to use geometry generator to place a centroid in each segment of a multiline?

With geometry generator in QGIS I'm trying to place a marker in the midpoint of each segment of a multiline vector (I don't want to use the Highlight line option). My main issue is how to read each ...
26 views

Storing the standard distance of a centroid alongside the centroid coordinates

I'd like to calculate and save a centroid (the central tendency) of a set of points as well as the standard distance (i.e. the root mean squared distance to the centroid). I can store the centroid as ...
• 1,847
527 views

Calculating/obtaining a "centerpoint" inside a multipolygon entity with FME software?

Obviously, this point does not necessarily have to be the real centroid, but it does have to be a, only one, single interior point of each multipolygon. What I have found is the CenterPointReplacer ...
• 1
163 views

Filtering on centroid distance between layers in Rule based layer styling in QGIS

By using Rule based layer styling for a polygon shapefile I want to display only those features whose centroid is separated by 1.000m from the feature centroids of another polygon layer ('layerB'). ...
• 1,075
1 vote
570 views

Extracting centroids from property of polygons

I have been using a function to get the centroid of each polygon (building) in my dataset. var buildings = ee.FeatureCollection('GOOGLE/Research/open-buildings/v1/polygons') Map.addLayer(buildings, {...
• 61
71 views

Drawing routes combining a geographic dataset and a dataset containing routes in R

I want to draw migration routes on a map in R. The basic idea is that I have a dataset containing 3 municipalities inside Mexico through which an individual has passed. I want to draw a line ...
• 103
1 vote
655 views

Preserving IDs when using gCentroid to find centroids of multiple polygons in R

This seems like it should be simple. I have multiple polygons contained in one shapefile, and I am using the gCentroid() function from rgeos to create a bunch of centroid points. The function has an ...
• 191
1 vote