是否有python代码来解析geoPDF文件以获取投影和图像数据?一个geoPDF2KML工具?

是否有python代码来解析geoPDF文件以获取投影和图像数据?一个geoPDF2KML工具?,python,pdf,gis,geospatial,Python,Pdf,Gis,Geospatial,我想组织很多geoPDF文件,以便它们可以轻松地叠加到谷歌地图和谷歌地球上查看 我认为,我的第一步是将geoPDF转换为jpg类型的图像,然后需要匹配的lat、long信息 是否有python代码来解析geoPDF文件以获取投影和图像数据 geoPDF2KML工具?一个选项是使用GDAL gdal的最新版本(即当前svn中继,而非任何发布版本)应支持geoPDF 您需要使用选项--with poppler=yes编译它,并安装poppler pdf库。(编译gdal可能有点痛苦,只是为了提前警告

我想组织很多geoPDF文件,以便它们可以轻松地叠加到谷歌地图和谷歌地球上查看

我认为,我的第一步是将geoPDF转换为jpg类型的图像,然后需要匹配的lat、long信息

是否有python代码来解析geoPDF文件以获取投影和图像数据


geoPDF2KML工具?

一个选项是使用GDAL

gdal的最新版本(即当前svn中继,而非任何发布版本)应支持geoPDF

您需要使用选项
--with poppler=yes
编译它,并安装poppler pdf库。(编译gdal可能有点痛苦,只是为了提前警告你…)

Gdal的python绑定是痛苦的,但它们通常是有效的

从那里,您应该能够轻松地使用GDAL将geopdf转换为地理参考JPEG

但是,如果您还不熟悉GDAL,那么这可能会带来更多的麻烦。geoPDF中的地理参考信息可能可以通过其他方式提取


无论如何,希望这能有所帮助……

我在ubuntu系统上使用的步骤,该系统已经有python(python已经是Unbuntu的一部分) 1.下载并安装poppler 2.下载并安装proj4 3.下载并安装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 

下面的代码可能有助于指导某些人将许多GeoPDF转换为KML Superoverlay,然后使用Google Maps API或Google Earth API将其合并为web地图覆盖

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

谢谢…祝我好运…我会努力的。。。cheers@indiehacker-祝你好运!这可能是一种痛苦,但希望一切顺利!我以前从未尝试过在GDAL中使用geoPDF,所以希望它也能顺利工作。。。我知道它是“应该”的,就在最近,但我还没有尝试它。。。不管怎样,祝你好运!我无法让GDAL读取geoPFD.pdf文件。我想在使用python安装了所需的依赖项之后,我成功地编译了gdal的最新SVN版本。运行gdal$gdalinfo test_geo.pdf后,我看到返回的“错误4:'test_geo.pdf'未被识别为受支持的文件格式。”配置poppler时,我确保有“-启用xpdf头”正如地理空间PDF文档所说的那样……有什么建议吗???@indiehacker-当您运行
gdal config--formats
时,
PDF
是否显示为一种格式?如果没有,那么gdal没有检测到您的poppler安装。。。您可能需要使用
--with poppler=/path/to/poppler/install/
手动指定路径,我刚刚尝试构建了最新的svn版本,它似乎可以与我放置的两个geoPDF一起工作,无论它值多少钱……我都可以使用上面的帮助!执行“$locate include/poppler”导致找到“usr/local/include/poppler”,因此-->第1步是重新安装poppler:“poopler$./configure--enable xpdf headers--prefix=/usr/local/include/poppler”,然后是通常的“$make”和“$make install”。第2步是重新安装gdal,路径为poppler:“gdal$./configure--with poppler=/usr/local/include/poppler.Thanksse如果您需要有关此问题的指导,请参阅下面的代码