Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In ArcMap, when you export data to PDF it preserves the layering within the PDF so that you can turn on/off individual map layers (within the PDF itself). When I export from QGIS to PDF, I don't appear to have the option for this.

Does QGIS support preserving layers when exporting to PDF? Is there a special setting needed to enable this capability? Or has anyone wrote a plugin for this feature?

share|improve this question
    
I have the same question and need. Look forward to presenting pdf maps with layer control. – user4784 Nov 10 '11 at 9:48

This was on the list of possible Google Summer of Code projects 2010 (http://www.qgis.org/wiki/Google_Summer_of_Code_2010#SVG.2FPDF_export_improvements) but I don't think anybody got to work on it.

share|improve this answer
    
Thanks for the feedback. Bummer, that would have been a great enhancement to have. Maybe next by summer... – RyanDalton Mar 11 '11 at 16:50
1  
Years later, GDAL is now able to create GeoPDFs from vector and raster data, but QGIS is still behind. – AndreJ Nov 7 '14 at 15:15
up vote 0 down vote accepted

Until this is supported "out of the box", I wrote the following workaround in Python help automate the batch processing of a folder of outputs generated with the Atlas "data driven pages" part of QGIS Composer. The method I finally settled on was:

  1. Export the Layout to a GeoTiff via Composer
  2. Execute the gdal_translate command from the command line to convert the GeoTiff into GeoPDF.
import os, subprocess

inFolder = r"D:\folder_path\TIFF"
outFolder = r"D:\folder_path\geopdf_conversion"

#Create the outFolder if it does not exist
if not os.path.exists(outFolder):
    os.mkdir(outFolder)


#Define the output projection
epsg = 3857

print "Converting images from {0} to:\n{1}\n".format(inFolder, outFolder)

#List all GeoTiff files in a folder
for f in os.listdir(inFolder):
    fName, fExt = os.path.splitext(f)
    tifExt = ["tif", "tiff", "jpg", "jpeg"]
    if any(e in fExt.strip(".") for e in tifExt):

        gtif = os.path.join(inFolder,f)
        gpdf = os.path.join(outFolder,"{0}.{1}".format(fName ,"pdf") )
        print "Converting {0}".format(f)

        gdal_cmd = 'gdal_translate -a_srs EPSG:{0} -of PDF "{1}" "{2}"'.format(epsg, gtif, gpdf)
        ##print gdal_cmd

        subprocess.call(gdal_cmd)
        print "\n"

print "Converted Image files from {0} to GeoPDFs in {1}".format(inFolder, outFolder)
share|improve this answer

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.