2010-10-07 75 views
2

我想組織大量的geoPDF文件,以便輕鬆查看覆蓋到Google地圖和Google地球上的文件。是否有python代碼來解析geoPDF文件來獲取投影和圖像數據?一個geoPDF2KML工具?

我的第一步,我認爲是將geoPDF轉換爲一個jpg類型的圖像,然後需要匹配經緯度信息。

是否有python代碼來解析geoPDF文件以獲取投影和圖像數據?

geoPDF2KML工具?

+0

查閱下面的代碼IF YOU WANT指導,這個問題 – 2011-03-03 05:01:28

回答

2

一種選擇是使用GDAL ...

@中的最新版本(即當前SVN主幹,沒有任何發佈的版本)應該支持geoPDF的。

您需要使用選項--with-poppler=yes進行編譯,並安裝poppler pdf庫。 (編譯gdal可能有點痛苦,只是提前提醒你...)

Gdal的python綁定是痛苦的,但他們通常工作。

從那裏,你應該能夠很容易地使用GDAL來將你的geopdf轉換成地理參考的jpegs。

如果你還不熟悉GDAL,這可能比它的價值更麻煩。在geoPDF的georeferenceing信息或許可以用其他方式來提取...

希望幫助一點,反正...

+0

感謝...祝我好運。我會盡量comppile @中...乾杯 – 2010-10-08 01:17:46

+0

@indiehacker - 好運氣!這可能是一個痛苦,但希望它順利!我從來沒有嘗試過使用GDAL之前的geoPDF,所以希望它也可以順利運行......我知道這是「應該」,直到最近,但我還沒有嘗試過......祝你好運,無論! – 2010-10-08 14:16:45

+0

我無法獲取GDAL來讀取geoPFD.pdf文件。我想在使用./configure --with-poppler = yes --with-python安裝所需的依賴關係後,我成功編譯了最新的gdal SVN版本。運行gdal $ gdalinfo test_geo.pdf後,我看到返回的「ERROR 4:'test_geo.pdf'未被識別爲支持的文件格式。」當我配置poppler時,我一定要擁有「--enable-xpdf-headers」,因爲Geospatial PDF文檔說要做...任何建議? – 2010-10-14 17:16:48

3

步我的Ubuntu系統上使用具有蟒蛇(蟒蛇已經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 
2

下面這段代碼可以幫助指導有人想很多geoPDFs轉換爲KML的Superoverlay然後可以結合作爲使用Google Maps AP的網絡地圖疊加我還是谷歌地球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 
相關問題