Create mid point from line layer The Next CEO of Stack OverflowIs QgsMapLayerRegistry removed in QGIS3?Finding middle point (midpoint) of line in QGIS?Copying point features along line features by predetermined distancepoint created on a line not precisely on lineParts of the lines aren't split when using Split Line At PointQGIS plugin that adds a point along a line at a specified distance?Length of line on specific point (from point layer)Adding M values to point feature attribute table in ArcmapConvert Line to central point in QGIS?Plot points along a line at specific distance value?QGIS points or line vertexCreate multiple paths by joining a set of start points in one layer to a single end destination in another layer?
My ex-girlfriend uses my Apple ID to login to her iPad, do I have to give her my Apple ID password to reset it?
If Nick Fury and Coulson already knew about aliens (Kree and Skrull) why did they wait until Thor's appearance to start making weapons?
Is there a reasonable and studied concept of reduction between regular languages?
Do I need to write [sic] when including a quotation with a number less than 10 that isn't written out?
Aggressive Under-Indexing and no data for missing index
What does "shotgun unity" refer to here in this sentence?
IC has pull-down resistors on SMBus lines?
How to Implement Deterministic Encryption Safely in .NET
In the "Harry Potter and the Order of the Phoenix" video game, what potion is used to sabotage Umbridge's speakers?
Is it convenient to ask the journal's editor for two additional days to complete a review?
Why is the US ranked as #45 in Press Freedom ratings, despite its extremely permissive free speech laws?
What flight has the highest ratio of timezone difference to flight time?
Physiological effects of huge anime eyes
Help/tips for a first time writer?
Purpose of level-shifter with same in and out voltages
What connection does MS Office have to Netscape Navigator?
Why don't programming languages automatically manage the synchronous/asynchronous problem?
How to find image of a complex function with given constraints?
From jafe to El-Guest
It is correct to match light sources with the same color temperature?
Is there an equivalent of cd - for cp or mv
Help understanding this unsettling image of Titan, Epimetheus, and Saturn's rings?
Spaces in which all closed sets are regular closed
Why am I getting "Static method cannot be referenced from a non static context: String String.valueOf(Object)"?
Create mid point from line layer
The Next CEO of Stack OverflowIs QgsMapLayerRegistry removed in QGIS3?Finding middle point (midpoint) of line in QGIS?Copying point features along line features by predetermined distancepoint created on a line not precisely on lineParts of the lines aren't split when using Split Line At PointQGIS plugin that adds a point along a line at a specified distance?Length of line on specific point (from point layer)Adding M values to point feature attribute table in ArcmapConvert Line to central point in QGIS?Plot points along a line at specific distance value?QGIS points or line vertexCreate multiple paths by joining a set of start points in one layer to a single end destination in another layer?
In QGIS I am trying to create a new point layer based on the mid point of a line layer (and keep all the feature attributes in the table).
For example, one line feature becomes one point, located on the mid/center point of the line. Points to lines only seems to work on nodes, and Create points along lines only seems to work at fixed distances?
qgis point line distance points-to-line
add a comment |
In QGIS I am trying to create a new point layer based on the mid point of a line layer (and keep all the feature attributes in the table).
For example, one line feature becomes one point, located on the mid/center point of the line. Points to lines only seems to work on nodes, and Create points along lines only seems to work at fixed distances?
qgis point line distance points-to-line
add a comment |
In QGIS I am trying to create a new point layer based on the mid point of a line layer (and keep all the feature attributes in the table).
For example, one line feature becomes one point, located on the mid/center point of the line. Points to lines only seems to work on nodes, and Create points along lines only seems to work at fixed distances?
qgis point line distance points-to-line
In QGIS I am trying to create a new point layer based on the mid point of a line layer (and keep all the feature attributes in the table).
For example, one line feature becomes one point, located on the mid/center point of the line. Points to lines only seems to work on nodes, and Create points along lines only seems to work at fixed distances?
qgis point line distance points-to-line
qgis point line distance points-to-line
edited 2 days ago
Kadir Şahbaz
4,52721331
4,52721331
asked Oct 12 '17 at 14:48
user107128user107128
264
264
add a comment |
add a comment |
4 Answers
4
active
oldest
votes
If python is Ok for you, you can easily do that with that code snippet.
Copy/paste this code in the editor of the python console, select your line layer and run the script!
layer = iface.activeLayer()
temp = QgsVectorLayer("Point?crs=epsg:2154", "result", "memory")
temp.startEditing()
attrs = layer.dataProvider().fields().toList()
temp_prov = temp.dataProvider()
temp_prov.addAttributes(attrs)
temp.updateFields()
for elem in layer.getFeatures():
feat = QgsFeature()
geom = elem.geometry().interpolate(elem.geometry().length()/2)
feat.setGeometry(geom)
feat.setAttributes(elem.attributes())
temp.addFeatures([feat])
temp.updateExtents()
temp.commitChanges()
QgsMapLayerRegistry.instance().addMapLayer(temp)
This code also take care about keeping the attributes of the line Layer.
Here is my result on a set of line :
Thanks for this. Just to note that the last line doesn't work in QGIS 3, the following works instead:QgsProject.instance().addMapLayer(temp)
Credit to Abhijit Gujar.
– TeddyTedTed
Jan 3 at 12:03
@TeddyTedTed You are right, thanks for pointing this!
– YoLecomte
Jan 3 at 22:03
add a comment |
You can use the GDAL/OGR tool: Create points along lines.
Make sure you specify 0.5
as the distance. This calculates the fraction of the total length (not the distance) as the tool incorporates the ST_Line_Interpolate_Point function.
Here is the default settings shown for me using QGIS 2.18.2 for Win7 64-bit:
The attributes are also carried over to the output point layer.
add a comment |
I would suggest you use MMQGIS plugin that will allow you to find the mid point of the layer.
This provide a great resource to learn more about the plugin and the features. You would need to add the plugin via the repository in QGIS Describes use of MMQGIS, a set of Python vector map layer plugins for Quantum GIS
add a comment |
I use a two steps solution:
-First I make count densification with a count equals to one, this adds a mid point to every segment.
-Then I extract specific nodes, indicating node number 1.
I use this solution because I keep not only the mid point, also the angle of the segment comes as an attribute.
I have a model with the two steps inside, I only have to insert the lines layer
New contributor
add a comment |
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "79"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f258308%2fcreate-mid-point-from-line-layer%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
If python is Ok for you, you can easily do that with that code snippet.
Copy/paste this code in the editor of the python console, select your line layer and run the script!
layer = iface.activeLayer()
temp = QgsVectorLayer("Point?crs=epsg:2154", "result", "memory")
temp.startEditing()
attrs = layer.dataProvider().fields().toList()
temp_prov = temp.dataProvider()
temp_prov.addAttributes(attrs)
temp.updateFields()
for elem in layer.getFeatures():
feat = QgsFeature()
geom = elem.geometry().interpolate(elem.geometry().length()/2)
feat.setGeometry(geom)
feat.setAttributes(elem.attributes())
temp.addFeatures([feat])
temp.updateExtents()
temp.commitChanges()
QgsMapLayerRegistry.instance().addMapLayer(temp)
This code also take care about keeping the attributes of the line Layer.
Here is my result on a set of line :
Thanks for this. Just to note that the last line doesn't work in QGIS 3, the following works instead:QgsProject.instance().addMapLayer(temp)
Credit to Abhijit Gujar.
– TeddyTedTed
Jan 3 at 12:03
@TeddyTedTed You are right, thanks for pointing this!
– YoLecomte
Jan 3 at 22:03
add a comment |
If python is Ok for you, you can easily do that with that code snippet.
Copy/paste this code in the editor of the python console, select your line layer and run the script!
layer = iface.activeLayer()
temp = QgsVectorLayer("Point?crs=epsg:2154", "result", "memory")
temp.startEditing()
attrs = layer.dataProvider().fields().toList()
temp_prov = temp.dataProvider()
temp_prov.addAttributes(attrs)
temp.updateFields()
for elem in layer.getFeatures():
feat = QgsFeature()
geom = elem.geometry().interpolate(elem.geometry().length()/2)
feat.setGeometry(geom)
feat.setAttributes(elem.attributes())
temp.addFeatures([feat])
temp.updateExtents()
temp.commitChanges()
QgsMapLayerRegistry.instance().addMapLayer(temp)
This code also take care about keeping the attributes of the line Layer.
Here is my result on a set of line :
Thanks for this. Just to note that the last line doesn't work in QGIS 3, the following works instead:QgsProject.instance().addMapLayer(temp)
Credit to Abhijit Gujar.
– TeddyTedTed
Jan 3 at 12:03
@TeddyTedTed You are right, thanks for pointing this!
– YoLecomte
Jan 3 at 22:03
add a comment |
If python is Ok for you, you can easily do that with that code snippet.
Copy/paste this code in the editor of the python console, select your line layer and run the script!
layer = iface.activeLayer()
temp = QgsVectorLayer("Point?crs=epsg:2154", "result", "memory")
temp.startEditing()
attrs = layer.dataProvider().fields().toList()
temp_prov = temp.dataProvider()
temp_prov.addAttributes(attrs)
temp.updateFields()
for elem in layer.getFeatures():
feat = QgsFeature()
geom = elem.geometry().interpolate(elem.geometry().length()/2)
feat.setGeometry(geom)
feat.setAttributes(elem.attributes())
temp.addFeatures([feat])
temp.updateExtents()
temp.commitChanges()
QgsMapLayerRegistry.instance().addMapLayer(temp)
This code also take care about keeping the attributes of the line Layer.
Here is my result on a set of line :
If python is Ok for you, you can easily do that with that code snippet.
Copy/paste this code in the editor of the python console, select your line layer and run the script!
layer = iface.activeLayer()
temp = QgsVectorLayer("Point?crs=epsg:2154", "result", "memory")
temp.startEditing()
attrs = layer.dataProvider().fields().toList()
temp_prov = temp.dataProvider()
temp_prov.addAttributes(attrs)
temp.updateFields()
for elem in layer.getFeatures():
feat = QgsFeature()
geom = elem.geometry().interpolate(elem.geometry().length()/2)
feat.setGeometry(geom)
feat.setAttributes(elem.attributes())
temp.addFeatures([feat])
temp.updateExtents()
temp.commitChanges()
QgsMapLayerRegistry.instance().addMapLayer(temp)
This code also take care about keeping the attributes of the line Layer.
Here is my result on a set of line :
answered Oct 12 '17 at 15:10
YoLecomteYoLecomte
2,085218
2,085218
Thanks for this. Just to note that the last line doesn't work in QGIS 3, the following works instead:QgsProject.instance().addMapLayer(temp)
Credit to Abhijit Gujar.
– TeddyTedTed
Jan 3 at 12:03
@TeddyTedTed You are right, thanks for pointing this!
– YoLecomte
Jan 3 at 22:03
add a comment |
Thanks for this. Just to note that the last line doesn't work in QGIS 3, the following works instead:QgsProject.instance().addMapLayer(temp)
Credit to Abhijit Gujar.
– TeddyTedTed
Jan 3 at 12:03
@TeddyTedTed You are right, thanks for pointing this!
– YoLecomte
Jan 3 at 22:03
Thanks for this. Just to note that the last line doesn't work in QGIS 3, the following works instead:
QgsProject.instance().addMapLayer(temp)
Credit to Abhijit Gujar.– TeddyTedTed
Jan 3 at 12:03
Thanks for this. Just to note that the last line doesn't work in QGIS 3, the following works instead:
QgsProject.instance().addMapLayer(temp)
Credit to Abhijit Gujar.– TeddyTedTed
Jan 3 at 12:03
@TeddyTedTed You are right, thanks for pointing this!
– YoLecomte
Jan 3 at 22:03
@TeddyTedTed You are right, thanks for pointing this!
– YoLecomte
Jan 3 at 22:03
add a comment |
You can use the GDAL/OGR tool: Create points along lines.
Make sure you specify 0.5
as the distance. This calculates the fraction of the total length (not the distance) as the tool incorporates the ST_Line_Interpolate_Point function.
Here is the default settings shown for me using QGIS 2.18.2 for Win7 64-bit:
The attributes are also carried over to the output point layer.
add a comment |
You can use the GDAL/OGR tool: Create points along lines.
Make sure you specify 0.5
as the distance. This calculates the fraction of the total length (not the distance) as the tool incorporates the ST_Line_Interpolate_Point function.
Here is the default settings shown for me using QGIS 2.18.2 for Win7 64-bit:
The attributes are also carried over to the output point layer.
add a comment |
You can use the GDAL/OGR tool: Create points along lines.
Make sure you specify 0.5
as the distance. This calculates the fraction of the total length (not the distance) as the tool incorporates the ST_Line_Interpolate_Point function.
Here is the default settings shown for me using QGIS 2.18.2 for Win7 64-bit:
The attributes are also carried over to the output point layer.
You can use the GDAL/OGR tool: Create points along lines.
Make sure you specify 0.5
as the distance. This calculates the fraction of the total length (not the distance) as the tool incorporates the ST_Line_Interpolate_Point function.
Here is the default settings shown for me using QGIS 2.18.2 for Win7 64-bit:
The attributes are also carried over to the output point layer.
answered Oct 12 '17 at 15:12
JosephJoseph
58.5k7100205
58.5k7100205
add a comment |
add a comment |
I would suggest you use MMQGIS plugin that will allow you to find the mid point of the layer.
This provide a great resource to learn more about the plugin and the features. You would need to add the plugin via the repository in QGIS Describes use of MMQGIS, a set of Python vector map layer plugins for Quantum GIS
add a comment |
I would suggest you use MMQGIS plugin that will allow you to find the mid point of the layer.
This provide a great resource to learn more about the plugin and the features. You would need to add the plugin via the repository in QGIS Describes use of MMQGIS, a set of Python vector map layer plugins for Quantum GIS
add a comment |
I would suggest you use MMQGIS plugin that will allow you to find the mid point of the layer.
This provide a great resource to learn more about the plugin and the features. You would need to add the plugin via the repository in QGIS Describes use of MMQGIS, a set of Python vector map layer plugins for Quantum GIS
I would suggest you use MMQGIS plugin that will allow you to find the mid point of the layer.
This provide a great resource to learn more about the plugin and the features. You would need to add the plugin via the repository in QGIS Describes use of MMQGIS, a set of Python vector map layer plugins for Quantum GIS
answered Oct 12 '17 at 15:02
whyzarwhyzar
10.7k92866
10.7k92866
add a comment |
add a comment |
I use a two steps solution:
-First I make count densification with a count equals to one, this adds a mid point to every segment.
-Then I extract specific nodes, indicating node number 1.
I use this solution because I keep not only the mid point, also the angle of the segment comes as an attribute.
I have a model with the two steps inside, I only have to insert the lines layer
New contributor
add a comment |
I use a two steps solution:
-First I make count densification with a count equals to one, this adds a mid point to every segment.
-Then I extract specific nodes, indicating node number 1.
I use this solution because I keep not only the mid point, also the angle of the segment comes as an attribute.
I have a model with the two steps inside, I only have to insert the lines layer
New contributor
add a comment |
I use a two steps solution:
-First I make count densification with a count equals to one, this adds a mid point to every segment.
-Then I extract specific nodes, indicating node number 1.
I use this solution because I keep not only the mid point, also the angle of the segment comes as an attribute.
I have a model with the two steps inside, I only have to insert the lines layer
New contributor
I use a two steps solution:
-First I make count densification with a count equals to one, this adds a mid point to every segment.
-Then I extract specific nodes, indicating node number 1.
I use this solution because I keep not only the mid point, also the angle of the segment comes as an attribute.
I have a model with the two steps inside, I only have to insert the lines layer
New contributor
New contributor
answered 2 days ago
Juan Francisco Garrido RiteJuan Francisco Garrido Rite
1
1
New contributor
New contributor
add a comment |
add a comment |
Thanks for contributing an answer to Geographic Information Systems Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f258308%2fcreate-mid-point-from-line-layer%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown