Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I've used the v2 labeling engine to place some nice looking road labels. Now I'd like to export those labels as a point shapefile for use in another program. Is there any way to accomplish this?

share|improve this question
    
what is the other program –  Nathan W May 3 '12 at 12:47
    
The other program is OCAD. –  Ríbean May 3 '12 at 15:06
1  
I ask because QGIS doesn't seem to treat the labels as any kind of selectable objects. Or at least I don't know how to select them. OCAD doesn't have the ability to smart-label objects the way that QGIS does & if this can be done, it would save a lot of time. –  Ríbean May 3 '12 at 15:09
    
Last month (Dec. 2013), Dr. Marco Hugentobler added direct DXF export to the current development version of QGIS, i.e. the master branch. However, labels are not included in the new feature (yet?). You may wish to contact Marco via the QGIS Dev mailing list to see if he is planning on it, or if you are interested in funding its development. –  dakcarto Jan 9 at 22:01
add comment

1 Answer 1

I do smomthing like this:

canvas = qgis.utils.iface.mapCanvas()
fullext = canvas.mapRenderer().fullExtent()
f = 64
sx = fullext.xMinimum()
sy = fullext.yMinimum()
w = fullext.width()/f
h = fullext.height()/f
fileGrid = open("grid.txt","w")
for i in xrange(f): 
    for j in xrange(f): 
        rec = QgsRectangle(sx+i*w,sy+j*h,sx+(i+1)*w,sy+(j+1)*h)
        s = "%d,%d,%f,%f,%f,%f\n" % (i,j,rec.xMinimum(),rec.yMinimum(),rec.xMaximum(),rec.yMaximum())
        fileGrid.write(s)
        print "rec: "+rec.toString()
        canvas.setExtent(rec)
        canvas.refresh()
        filename = "test_%d_%d.txt" % (i,j)
        fileObj = open(filename,"w")
        labels = canvas.mapRenderer().labelingEngine().labelsWithinRect(fullext)
        for l in labels:
           # print l.labelText,l.cornerPoints[0].x(),l.cornerPoints[0].y(),l.rotation
            s = "%s,%f,%f,%f\n" % (l.labelText.encode("utf-8"),l.cornerPoints[0].x(),l.cornerPoints[0].y(),l.rotation)
            fileObj.write(s)
        fileObj.close()
        print "save: "+filename;


fileGrid.close()
print "END"

it write labels to txt file with x and y cordinate and angle. I dont have idea have to save labels for all map in specific scale.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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