gdal2tiles 삽질

원래는 tif파일하나가 400MB정도 나가서 도저히 Merge를 할 수가 없어서 이 방법, 저 방법 찾다가 우연찮게 발견한 것이 gdal_vrtmerge라는 툴이었다(http://code.google.com/p/maphew/ 가면 Download에 gdal_extra라는 파일에 끼어있음). 공식 GDAL 유틸리티는 아니지만 삽질을 통해 설치하고 gdalwarp의 -tr 옵션을 주어서 PixelSize까지 맞춰서 수 많은 tif파일들을 Merge시킨 vrt 파일을 만들었다. 그냥 gdal_merge를 통해 하나의 통판으로 만들면 용량이 너무 커서 시간도 오래걸리고 쪽날꺼 같아 gdal_vrtmerge를 사용 하였다(참고: Open Source GIS를 이용한 고해상도 영상의 Tile Map Service 시스템 구축에 관한 연구-정명훈).

 

근데 제길슨

gdal2tiles.py: error: Processing of several input files is not supported.

Please first use a tool like gdal_vrtmerge.py or gdal_merge.py on the files:

위와 같은 에러가 뜨는게 아닌가!!

구글링을 하다가 http://www.mail-archive.com/debian-bugs-closed@lists.debian.org/msg280389.html 이것을 찾았고

답변은.. but current (>= 1.6) has a different syntax. Sorry for the noise...

시발놈…

 

그래서 혹시나 나중에 삽질하는 사람을 위해서 gdal2tiles 옵션을 정리하고자 한다.

gdal2tiles 실행 방법

gdal2tiles.py는 FWTools와 OSGeo4w 쉘(shell)을 통하여 실행할 수 있다. 하지만 FWTools에서는 GDAL의 버전이 잘 안맞는 경우가 있는데 그냥 OSGeo4W shell을 통하여 실행하면 된다. 먼저 gdal1.6 라이브러리를 활성화 시키기 위해 gdal16이라고 치고 커맨드를 실행시키면 OSGeo4W가 gdal16.bat을 실행시키면서 환경변수 등을 설정한다.

그 다음 gdal2tiles 커맨드와 적절한 옵션을 실행시키면 된다. 커맨드를 실행 시킬 때는 gdal2tiles.py 혹은 gdal2tiles 둘 다 같은 효과를 갖는다. 그 이유는 gdal2tiles.bat이 결국 아래와 같이 gdal2tiles.py를 실행시키는 구조이기 때문이다.

@python "%OSGEO4W_ROOT%\apps\gdal-16\bin\gdal2tiles.py" %*


이제 gdal2tiles 커맨드와 함께 아래 옵션 값들을 참조하여 자신에게 맞는 옵션들을 기입하면 된다.

gdal2tiles와 관련된 옵션

옵션명

옵션1

옵션2

Type

설명

OptionChoice

profile

-p

--profile

choice

프로파일

mercator, geodetic, raster

resampling

-r

--resampling

choice

리샘플링 방법 지정

average,
near, bilinear, cubic, cubicspline, lanczos, antialias

SRS

-s

--s_srs

 

원본파일의 Spatial Reference System

 

zoom

-z

--zoom

 

2-5 혹은 10과 같은 식으로 지정

 

resume

-e

--resume

 

복구재개모드. Resume mode. Generate only missing files

 

NODATA

-a

--srcnodata

 

NODATA transparency value to assign to the input data

 

verbose

-v

--verbose

 

Print status messages to stdout

 

KML

-k

--force-kml

 

Generate KML for Google Earth - default for 'geodetic' profile and 'raster' in EPSG:4326. For a dataset with different projection use with caution!")

 

No KML

-n

--no-kml

 

Avoid automatic generation of KML files for EPSG:4326

 

url

-u

--url

 

URL address where the generated tiles are going to be published

 

webviewer

-w

--webviewer

 

Web viewer to generate Google Maps, Yahoo Maps, OpenLayers- default 'all'

 

title

-t

--title

 

Title of the map

 

copyright

-c

--copyright

 

Copyright for the map

 

Google Maps API key

-g

-googlekey

 

Google Maps API key from
http://code.google.com/apis/maps/signup.html

 

Yahoo Application ID

-y

--yahookey

 

Yahoo Application ID from
http://developer.yahoo.com/wsregapp/

 

tileindex

-i

--tileindex

 

Generate tileindex and mapfile for MapServer (WMS)

 

 

 

gdal2tiles 옵션의 기본 값

verbose=False

profile="mercator"

kml=False

url=''

webviewer='all'

copyright=''

resampling='average'

resume=False

googlekey='INSERT_YOUR_KEY_HERE'

yahookey='INSERT_YOUR_YAHOO_APP_ID_HERE'

Posted by 강부자아들
,