Changes between Version 4 and Version 5 of USGS_PDF_Topo
- Timestamp:
- Jan 28, 2013, 11:34:04 AM (12 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
USGS_PDF_Topo
v4 v5 1 1 = Summary = 2 2 3 1. USGS offers new topo maps as a geospatial PDF [http://www.gdal.org/frmt_pdf.html] for download [http://nationalmap.gov/ustopo/index.html]. Direct download of specific file: [http://ims.er.usgs.gov/gda_services/download?item_id=5365522] 4 2. Some users may prefer to have the Topo map as a geotif rather than PDF 3 * USGS offers new topo maps as a geospatial PDF [http://www.gdal.org/frmt_pdf.html] for download [http://nationalmap.gov/ustopo/index.html]. Direct download of specific file: [http://ims.er.usgs.gov/gda_services/download?item_id=5365522] 4 5 * Some users may prefer to have the Topo map as a geotif rather than PDF 6 7 * Here are some tips to convert PDFs (specifically USGS Topo maps) to geotif 5 8 6 9 = Details = 7 10 8 1.GDAL must be built with Geospatial PDF support, see the above link for details. Confirm with:11 GDAL must be built with Geospatial PDF support, see the above link for details. Confirm with: 9 12 {{{ 10 13 $ gdalinfo --formats … … 17 20 }}} 18 21 19 2. Use gdalinfo to get NEATLINE: 22 == python script == 23 24 This cutline.py python script was recommended on the email [http://lists.osgeo.org/pipermail/gdal-dev/2013-January/035269.html list]. 25 26 {{{ 27 from osgeo import gdal 28 import os 29 import sys 30 31 ds = gdal.Open(sys.argv[1]) 32 neatline_wkt = ds.GetMetadataItem("NEATLINE") 33 ds = None 34 35 f = open('cutline.csv', 'wt') 36 f.write('id,WKT\n') 37 f.write('1,"%s"\n' % neatline_wkt) 38 f.close() 39 40 os.system('gdalwarp %s %s.tif ' % (sys.argv[1], sys.argv[1]) + 41 '-crop_to_cutline -cutline cutline.csv -overwrite') 42 }}} 43 44 Usage: python cutline.py your.pdf 45 46 == Manual method == 47 48 If you for some reasons want to do things more manually, here is how: 49 50 1. Use gdalinfo to get NEATLINE: 20 51 {{{ 21 52 $gdalinfo OR_Newport_North_20110824_TM_geo.pdf … … 29 60 }}} 30 61 31 3. Make an OGR datasource of the NEATLINE to use as a cutline in gdalwarp. This can be two files, a .vrt and .csv62 2. Make an OGR datasource of the NEATLINE to use as a cutline in gdalwarp. This can be two files, a .vrt and .csv 32 63 wkt_cutline_file.vrt: 33 64 {{{ … … 49 80 }}} 50 81 51 4. Use gdal_translate or gdalwarp to convert to geotif and if using gdalwarp, -cutline to the NEATLINE.82 3. Use gdal_translate or gdalwarp to convert to geotif and if using gdalwarp, -cutline to the NEATLINE. 52 83 {{{ 53 84 gdalwarp -cutline wkt_cutline_file.vrt -cl NEATLINE -crop_to_cutline OR_Newport_North_20110824_TM_geo.pdf OR_Newport_North_20110824_TM_geo.tif … … 56 87 57 88 = Notes = 58 * There is probably a more elegant way to grab the NEATLINE for use. (see this thread for some ideas, [http://osgeo-org.1803224.n2.nabble.com/gdal-dev-GeoPDF-translation-td7091018.html GeoPDF thread on nabble]) 89 * There is probably a more elegant way to grab the NEATLINE for use. (see this thread for some ideas, [http://osgeo-org.1803224.n2.nabble.com/gdal-dev-GeoPDF-translation-td7091018.html GeoPDF thread on nabble]). The above python script does this. 59 90 * This could be combined with gdalinfo, wget, or curl to determine which file to download. (This is not the same file listed above but a nearby historical Topo) 60 91 {{{