Python error message 'EOL while scanning string literal (, line 77) See log for more details'
Have any astronauts or cosmonauts died in space?
Euler and minus sign
Minimum energy path of a potential energy surface
What does "don't have a baby" imply or mean in this sentence?
In the Lost in Space intro why was Dr. Smith actor listed as a special guest star?
Draw triangle with text in vertices/edges
Why don't you get burned by the wood benches in a sauna?
Question: "Are you hungry?" Answer: "I feel like eating."
Coworker asking me to not bring cakes due to self control issue. What should I do?
How can I differentiate duration vs starting time
Can a planet be tidally unlocked?
How can guns be countered by melee combat without raw-ability or exceptional explanations?
Spells that would be effective against a Modern Day army but would NOT destroy a fantasy one
Did the characters in Moving Pictures not know about cameras like Twoflower's?
How can changes in personality/values of a person who turned into a vampire be explained?
Dot product with a constant
Have the UK Conservatives lost the working majority and if so, what does this mean?
What is an explicit bijection in combinatorics?
Why don't programs completely uninstall (remove all their files) when I remove them?
Why Third 'Reich'? Why is 'reich' not translated when 'third' is? What is the English synonym of reich?
Can a Hydra make multiple opportunity attacks at once?
Identical projects by students at two different colleges: still plagiarism?
Is Screenshot Time-tracking Common?
Buying a "Used" Router
Python error message 'EOL while scanning string literal (, line 77) See log for more details'
I am an absolute beginner in Python programming. Despite numerous attempts to rectify I am constantly finding new errors in the script below. Can anyone help please?
Network analysis=group
Shortest paths=name
Road_layer=vector line
Start_points=vector point
End_points=vector point
Shortest_paths=output vector
from PyQt4.QtCore import QVariant
from qgis.core import QGis, QgsFeature, QgsGeometry, QgsField, QgsFields
from qgis.networkanalysis import (QgsLineVectorLayerDirector,
QgsDistanceArcProperter, QgsGraphBuilder, QgsGraphAnalyzer)
from processing.core import GeoAlgorithmExecutionException
from processing.tools.vector import VectorWriter
layerRoads = processing.getObjectFromUri (Road_Layer)
layerStartPoints = processing.getObjectFromUri (Start_points)
layerStopPoints = processing.getObjectFromUri (End-points)
if layerStartPoints.featureCount () != layerStopPoints. featureCount():
GeoAlgorithmExecutionException (
'Number of features in start and end point layers should be equal!')
progress.setInfo ('Gathering start and stop points')
feats=layerStartPoints.getFeatures()
points=[f.geometry() .asPoint() for f in feats]
feats=layerStopPoints .getFeatures()
tmp=[f.geometry() .asPoint() for f in feats]
fields=QgsFields ()
fields.append(QgsField ('id', QVariant.Int, '',10))
fields.append(QgsField('startPoint', QVariant.String, '', 254))
fields.append(QgsField('endPoint', QVariant.String, '', 254))
fields.append(QgsField('length', QVariant.Double,'',20,7))
writer=VectorWriter(Shortest_paths, None, fields.toList(), QGis.WKBLineString, layerRoads.crs())
director=QgsLineVectorLayerDirector(layerRoads, -1, '', '', '', 3)
properter=QgsDistanceArcProperter()
director.addProperter(properter)
builder=QgsGraphBuilder(layerRoads.crs())
progress.setInfo('Generating road graph...')
tiedPoints=director.makeGraph(builder, points)
graph=builder.graph()
del points
count=layerStartPoints.featureCount()
total=100.0/float(count)
ft=QgsFeature()
ft.setFields(fields)
progress.setInfo('Finding shortest paths')
for i in xrange(count):
nStart = tiedPoints[i]
nStop = tiedPoints[count + i]
idxStart = graph.findVertex(nStart)
idxStop = graph.findVertex(nStop)
tree, cost = QgsGraphAnalyzer.dijkstra(graph, idxStart, 0)
if tree[idxStop] == -1:
progress.setInfo('No path found from point ({:.6f},{:.6f})'
'to point ({:.6f},{:.6f})'.format(
nStart.x(), nStart.y(), NStop.x(), nStop.y()))
else:
nodes = []
curPos = idxStop
while curPos != idxStart:
nodes.append (graph.vertex(
graph.arc (tree [curPos]. inVertex())).point())
curPos=graph.arc(tree[curPos]).outVertex()
nodes.append (nStart)
nodes.reverse ()
ft.setGeometry(QgsGeometry .fromPolyline (nodes))
ft ['id'] = i
ft ['startPoint']='({:.6f},{:.6f}).format(nStart.x(),nStart.y())
ft['endPoint'] = """({:.6f},{:.6f})""" .format (nStop.x(),nStop.y())
ft['length']=ft.geometry() .length()
writer.addFeature(ft)
progress.setPercentage (int(i*total))
del graph
del writer
qgis python qgis-processing qgis-networkanalysis
add a comment |
I am an absolute beginner in Python programming. Despite numerous attempts to rectify I am constantly finding new errors in the script below. Can anyone help please?
Network analysis=group
Shortest paths=name
Road_layer=vector line
Start_points=vector point
End_points=vector point
Shortest_paths=output vector
from PyQt4.QtCore import QVariant
from qgis.core import QGis, QgsFeature, QgsGeometry, QgsField, QgsFields
from qgis.networkanalysis import (QgsLineVectorLayerDirector,
QgsDistanceArcProperter, QgsGraphBuilder, QgsGraphAnalyzer)
from processing.core import GeoAlgorithmExecutionException
from processing.tools.vector import VectorWriter
layerRoads = processing.getObjectFromUri (Road_Layer)
layerStartPoints = processing.getObjectFromUri (Start_points)
layerStopPoints = processing.getObjectFromUri (End-points)
if layerStartPoints.featureCount () != layerStopPoints. featureCount():
GeoAlgorithmExecutionException (
'Number of features in start and end point layers should be equal!')
progress.setInfo ('Gathering start and stop points')
feats=layerStartPoints.getFeatures()
points=[f.geometry() .asPoint() for f in feats]
feats=layerStopPoints .getFeatures()
tmp=[f.geometry() .asPoint() for f in feats]
fields=QgsFields ()
fields.append(QgsField ('id', QVariant.Int, '',10))
fields.append(QgsField('startPoint', QVariant.String, '', 254))
fields.append(QgsField('endPoint', QVariant.String, '', 254))
fields.append(QgsField('length', QVariant.Double,'',20,7))
writer=VectorWriter(Shortest_paths, None, fields.toList(), QGis.WKBLineString, layerRoads.crs())
director=QgsLineVectorLayerDirector(layerRoads, -1, '', '', '', 3)
properter=QgsDistanceArcProperter()
director.addProperter(properter)
builder=QgsGraphBuilder(layerRoads.crs())
progress.setInfo('Generating road graph...')
tiedPoints=director.makeGraph(builder, points)
graph=builder.graph()
del points
count=layerStartPoints.featureCount()
total=100.0/float(count)
ft=QgsFeature()
ft.setFields(fields)
progress.setInfo('Finding shortest paths')
for i in xrange(count):
nStart = tiedPoints[i]
nStop = tiedPoints[count + i]
idxStart = graph.findVertex(nStart)
idxStop = graph.findVertex(nStop)
tree, cost = QgsGraphAnalyzer.dijkstra(graph, idxStart, 0)
if tree[idxStop] == -1:
progress.setInfo('No path found from point ({:.6f},{:.6f})'
'to point ({:.6f},{:.6f})'.format(
nStart.x(), nStart.y(), NStop.x(), nStop.y()))
else:
nodes = []
curPos = idxStop
while curPos != idxStart:
nodes.append (graph.vertex(
graph.arc (tree [curPos]. inVertex())).point())
curPos=graph.arc(tree[curPos]).outVertex()
nodes.append (nStart)
nodes.reverse ()
ft.setGeometry(QgsGeometry .fromPolyline (nodes))
ft ['id'] = i
ft ['startPoint']='({:.6f},{:.6f}).format(nStart.x(),nStart.y())
ft['endPoint'] = """({:.6f},{:.6f})""" .format (nStop.x(),nStop.y())
ft['length']=ft.geometry() .length()
writer.addFeature(ft)
progress.setPercentage (int(i*total))
del graph
del writer
qgis python qgis-processing qgis-networkanalysis
add a comment |
I am an absolute beginner in Python programming. Despite numerous attempts to rectify I am constantly finding new errors in the script below. Can anyone help please?
Network analysis=group
Shortest paths=name
Road_layer=vector line
Start_points=vector point
End_points=vector point
Shortest_paths=output vector
from PyQt4.QtCore import QVariant
from qgis.core import QGis, QgsFeature, QgsGeometry, QgsField, QgsFields
from qgis.networkanalysis import (QgsLineVectorLayerDirector,
QgsDistanceArcProperter, QgsGraphBuilder, QgsGraphAnalyzer)
from processing.core import GeoAlgorithmExecutionException
from processing.tools.vector import VectorWriter
layerRoads = processing.getObjectFromUri (Road_Layer)
layerStartPoints = processing.getObjectFromUri (Start_points)
layerStopPoints = processing.getObjectFromUri (End-points)
if layerStartPoints.featureCount () != layerStopPoints. featureCount():
GeoAlgorithmExecutionException (
'Number of features in start and end point layers should be equal!')
progress.setInfo ('Gathering start and stop points')
feats=layerStartPoints.getFeatures()
points=[f.geometry() .asPoint() for f in feats]
feats=layerStopPoints .getFeatures()
tmp=[f.geometry() .asPoint() for f in feats]
fields=QgsFields ()
fields.append(QgsField ('id', QVariant.Int, '',10))
fields.append(QgsField('startPoint', QVariant.String, '', 254))
fields.append(QgsField('endPoint', QVariant.String, '', 254))
fields.append(QgsField('length', QVariant.Double,'',20,7))
writer=VectorWriter(Shortest_paths, None, fields.toList(), QGis.WKBLineString, layerRoads.crs())
director=QgsLineVectorLayerDirector(layerRoads, -1, '', '', '', 3)
properter=QgsDistanceArcProperter()
director.addProperter(properter)
builder=QgsGraphBuilder(layerRoads.crs())
progress.setInfo('Generating road graph...')
tiedPoints=director.makeGraph(builder, points)
graph=builder.graph()
del points
count=layerStartPoints.featureCount()
total=100.0/float(count)
ft=QgsFeature()
ft.setFields(fields)
progress.setInfo('Finding shortest paths')
for i in xrange(count):
nStart = tiedPoints[i]
nStop = tiedPoints[count + i]
idxStart = graph.findVertex(nStart)
idxStop = graph.findVertex(nStop)
tree, cost = QgsGraphAnalyzer.dijkstra(graph, idxStart, 0)
if tree[idxStop] == -1:
progress.setInfo('No path found from point ({:.6f},{:.6f})'
'to point ({:.6f},{:.6f})'.format(
nStart.x(), nStart.y(), NStop.x(), nStop.y()))
else:
nodes = []
curPos = idxStop
while curPos != idxStart:
nodes.append (graph.vertex(
graph.arc (tree [curPos]. inVertex())).point())
curPos=graph.arc(tree[curPos]).outVertex()
nodes.append (nStart)
nodes.reverse ()
ft.setGeometry(QgsGeometry .fromPolyline (nodes))
ft ['id'] = i
ft ['startPoint']='({:.6f},{:.6f}).format(nStart.x(),nStart.y())
ft['endPoint'] = """({:.6f},{:.6f})""" .format (nStop.x(),nStop.y())
ft['length']=ft.geometry() .length()
writer.addFeature(ft)
progress.setPercentage (int(i*total))
del graph
del writer
qgis python qgis-processing qgis-networkanalysis
I am an absolute beginner in Python programming. Despite numerous attempts to rectify I am constantly finding new errors in the script below. Can anyone help please?
Network analysis=group
Shortest paths=name
Road_layer=vector line
Start_points=vector point
End_points=vector point
Shortest_paths=output vector
from PyQt4.QtCore import QVariant
from qgis.core import QGis, QgsFeature, QgsGeometry, QgsField, QgsFields
from qgis.networkanalysis import (QgsLineVectorLayerDirector,
QgsDistanceArcProperter, QgsGraphBuilder, QgsGraphAnalyzer)
from processing.core import GeoAlgorithmExecutionException
from processing.tools.vector import VectorWriter
layerRoads = processing.getObjectFromUri (Road_Layer)
layerStartPoints = processing.getObjectFromUri (Start_points)
layerStopPoints = processing.getObjectFromUri (End-points)
if layerStartPoints.featureCount () != layerStopPoints. featureCount():
GeoAlgorithmExecutionException (
'Number of features in start and end point layers should be equal!')
progress.setInfo ('Gathering start and stop points')
feats=layerStartPoints.getFeatures()
points=[f.geometry() .asPoint() for f in feats]
feats=layerStopPoints .getFeatures()
tmp=[f.geometry() .asPoint() for f in feats]
fields=QgsFields ()
fields.append(QgsField ('id', QVariant.Int, '',10))
fields.append(QgsField('startPoint', QVariant.String, '', 254))
fields.append(QgsField('endPoint', QVariant.String, '', 254))
fields.append(QgsField('length', QVariant.Double,'',20,7))
writer=VectorWriter(Shortest_paths, None, fields.toList(), QGis.WKBLineString, layerRoads.crs())
director=QgsLineVectorLayerDirector(layerRoads, -1, '', '', '', 3)
properter=QgsDistanceArcProperter()
director.addProperter(properter)
builder=QgsGraphBuilder(layerRoads.crs())
progress.setInfo('Generating road graph...')
tiedPoints=director.makeGraph(builder, points)
graph=builder.graph()
del points
count=layerStartPoints.featureCount()
total=100.0/float(count)
ft=QgsFeature()
ft.setFields(fields)
progress.setInfo('Finding shortest paths')
for i in xrange(count):
nStart = tiedPoints[i]
nStop = tiedPoints[count + i]
idxStart = graph.findVertex(nStart)
idxStop = graph.findVertex(nStop)
tree, cost = QgsGraphAnalyzer.dijkstra(graph, idxStart, 0)
if tree[idxStop] == -1:
progress.setInfo('No path found from point ({:.6f},{:.6f})'
'to point ({:.6f},{:.6f})'.format(
nStart.x(), nStart.y(), NStop.x(), nStop.y()))
else:
nodes = []
curPos = idxStop
while curPos != idxStart:
nodes.append (graph.vertex(
graph.arc (tree [curPos]. inVertex())).point())
curPos=graph.arc(tree[curPos]).outVertex()
nodes.append (nStart)
nodes.reverse ()
ft.setGeometry(QgsGeometry .fromPolyline (nodes))
ft ['id'] = i
ft ['startPoint']='({:.6f},{:.6f}).format(nStart.x(),nStart.y())
ft['endPoint'] = """({:.6f},{:.6f})""" .format (nStop.x(),nStop.y())
ft['length']=ft.geometry() .length()
writer.addFeature(ft)
progress.setPercentage (int(i*total))
del graph
del writer
qgis python qgis-processing qgis-networkanalysis
qgis python qgis-processing qgis-networkanalysis
asked 1 min ago
Sean JarrettSean Jarrett
61
61
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
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%2f313181%2fpython-error-message-eol-while-scanning-string-literal-line-77-see-log-for%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
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%2f313181%2fpython-error-message-eol-while-scanning-string-literal-line-77-see-log-for%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