[gdal-dev] Neatline for USGS PDF maps
even.rouault at mines-paris.org
Sat Jan 19 07:28:53 PST 2013
Le samedi 19 janvier 2013 03:38:16, Eli Adam a écrit :
> Checking over some USGS topo PDFs, the neatline reported appears too
> large. Has anyone else check this or noticed anything similar?
> Specific details below.
Looking more closely at those files, I see that there are various registration
blocks. The algorithm up to now was to select the registration block whose
neatline covered the most area in terms of pixels. In the case of
OR_Newport_North_20110824_TM_geo.pdf, those blocks are :
"UTM Grid and Projection"
"Adjoining Quadrangles Diagram"
The number and names of blocks may change, but in all USGS topo PDFs samples
I've tried, the "Map Layers" is always present and seems to the one that lead
to the best results, so I've just pushed a change to select it when it is
You can use the following Python script to automate fetching the neatline and
launching gdalwarp to use it :
from osgeo import gdal
ds = gdal.Open(sys.argv)
neatline_wkt = ds.GetMetadataItem("NEATLINE")
ds = None
f = open('cutline.csv', 'wt')
f.write('1,"%s"\n' % neatline_wkt)
os.system('gdalwarp %s %s.tif ' % (sys.argv, sys.argv) +
'-crop_to_cutline -cutline cutline.csv -overwrite')
More information about the gdal-dev