Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a single 2.5 GB JP2 image of a city that I need to split into tiles, which I'll then process to create flight simulation scenery.

Google as I might, I can't find the solution.

The JP2 apparently has GIS XML data embedded, which doesn't affect me either way, since I don't need it. All I'm trying to do is break the image down into x-number of preferably 2048 x 2048 tiles.

A utility to do this in either OSX or Win7 would be great.

Ideas?

Thanks!

share|improve this question
    
Are you interested in a QGIS or ArcGIS approach? –  Aaron Dec 31 '12 at 23:20
5  
try gdal2tiles.py –  mdsumner Jan 1 '13 at 3:33

1 Answer 1

up vote 13 down vote accepted

You can write a simple shell script and use gdal_translate utility to chop the tiles. On Mac, get the GDAL build from here. On Windows,the best way to get GDAL is via the OSGeo4W installer. In the following script, you need to replace following things

  • XDIM and YDIM with your source jp2 X and Y dimensions
  • gdal_translate with the actual path on your system
  • input.jp2 with path to your input file.

Save the script in a text file called script.sh. Open a Terminal and run 'bash script.sh'. That will create the tiles in a directory called tiles/ . The script is copied from here with a little modification for your purpose.

#!/bin/bash
mkdir tiles

XDIM=24000
YDIM=24000
BLOCKSIZE=2048
XPOS=0
YPOS=0
BLOCKNO=0
while [ $YPOS -le $YDIM ]
do
while [ $XPOS -le $XDIM ]
  do
    echo "$XPOS $YPOS : ${BLOCKNO}.tif"
    gdal_translate -of GTiff -srcwin $XPOS $YPOS $BLOCKSIZE $BLOCKSIZE input.jp2 \
      tiles/${BLOCKNO}.tif
    BLOCKNO=`echo "$BLOCKNO + 1" | bc`
    XPOS=`echo "$XPOS + $BLOCKSIZE" | bc`
  done
YPOS=`echo "$YPOS + $BLOCKSIZE" | bc`
XPOS=0
done
share|improve this answer
    
Spatial, many thanks. –  Stent Mutton Jan 2 '13 at 4:11
2  
Ah, no problem. Finder wouldn't know about JP2 format so it won't help. You need the GDAL library to read JP2s. If you installed GDAL from the link in my answer, you can use the command 'gdalinfo' to get that information. On my system, GDAL is at /Library/Frameworks/GDAL.framework/Versions/1.9/Programs/gdalinfo . run gdalinfo <path/to/your/jp2> and it will report the dimensions. Similarly add the full path to gdal_translate in the script for it to work. –  spatialthoughts Jan 2 '13 at 6:09

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.