开发者

Is there python code to parse a geoPDF file to get the projection and image data? a geoPDF2KML tool?

I wa开发者_Go百科nt to organize lots of geoPDF files so they can easily viewed overlayed onto Google Maps and Google Earth.

My 1st step, I think, is to convert the geoPDF to a jpg type image which then needs matching lat,long information.

Is there python code to parse a geoPDF file to get the projection and image data?

A geoPDF2KML tool?


Steps I used on ubuntu system that has python (python already part of Unbuntu) 1. download and install poppler 2. download and install proj4 3. download and install gdal

poppler$./configure --enable-xpdf-headers --prefix=/usr/local/include/poppler" then the usual "$make" and "$make install"

poppler$make

poppler$sudo make install

sudo apt-get install proj4

gdal$./configure --with-static-proj4=/usr/local/lib --with-threads --with-libtiff=internal --with-geotiff=internal --with-jpeg=internal --with-gif=internal --with-png=internal --with-libz=internal --with-poppler=/usr/local/include/poppler --with-python

gdal$make

gdal$sudo make install 


One option is to use GDAL...

The latest version (i.e. the current svn trunk, not any released version) of gdal should support geoPDF's.

You'll need to compile it with the option --with-poppler=yes and have the poppler pdf library installed. (Compiling gdal can be a bit of a pain, just to warn you ahead of time...)

Gdal's python bindings are painful, but they generally work.

From there, you should be able to easily use GDAL to convert your geopdf's to georeferenced jpegs.

If you're not already familiar with GDAL, though, this may be more trouble than it's worth. The georeferenceing information in a geoPDF can probably be extracted in other ways...

Hope that helps a bit, anyway...


This code below may help guide some one wanting to convert many geoPDFs to KML-Superoverlay which can then be incorporated as web map overlays using Google Maps API or Google Earth API...

import shlex
import subprocess
from subprocess import Popen, PIPE
import os


def step1_translate( input_file ):
    out = input_file + ".vrt"
    translate_command = "gdal_translate -of VRT %s %s" % (input_file,out)
    translate_args = shlex.split( translate_command )
    p1 = subprocess.Popen( translate_args) # translate
    print p1

def step2_warp( input_file):
    gdalwarp_command = "gdalwarp -of VRT -t_srs EPSG:4326 %s %s" % (output_file,output_file2)
    gdalwarp_args = shlex.split( gdalwarp_command )
    p2 = subprocess.Popen( gdalwarp_args   , stdin=p1.stdout ) #gdalwarp

def step3_tile( input_file, output_file, output_file2 ):
    gdal2tiles_command = "/home/boris/gdal/swig/python/scripts/gdal2tiles.py -p geodetic -k %s" % output_file2
    gdal2tiles_args = shlex.split( gdal2tiles_command )
    p3 = subprocess.Popen( gdal2tiles_args , stdin=p2.stdout) #gdal2tiles
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜