5

I'm trying to create a points in the middle of polylines. The data is now in the form of shapefile. Is there an easy way to do this?

1
  • 2
    What software do you have available? If you have ArcGIS, you can use the Feature Vertices to Points tool to get the midpoint of a line as stated in this question. You can do this in 10.1 with a trial licence (Advanced). Nov 15, 2012 at 8:27

3 Answers 3

5

This is a simple way to find the center of lines in QGis: Vector > Analysis > Mean Coordinates

enter image description here

This worked very nice and fast.

Points are created in another shapefile, and the attribute table already comes with the coordinates along with the Unique ID field you selected earlier.

enter image description here

I tried before to convert the lines into polygons, then extracting the polygon centroids, but the new solution is one step shorter.

1
  • This does not help. I tried this on an exploded line layer that was converted from a polygon layer, but it creates centroids outside the lines instead of in the center of the exploded lines.
    – JAT86
    Jul 24, 2021 at 0:32
3

if you have qgis;

  1. use SPIT - Shapefile to PostGIS Import Tool to adding your shapefile as postgis table
  2. run this query:

.

SELECT id, ST_AsText(ST_Centroid(the_geom)) as Cetroids FROM myPolyLines;

or

SELECT id,CENTER(the_geom) as Cetroids FROM myPolyLines;

ST_Centroid — Returns the geometric center of a geometry.

Computes the geometric center of a geometry, or equivalently, the center of mass of the geometry as a POINT. more info

it will return you centroid of your line then you can update or set it as new column or anything.

centroid

2

use feature vertices to point in arcmap : Arctoolbox => data management tools => Features => Feature Vertices to point => select mid point type .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.