+ Reply to Thread
Results 1 to 2 of 2

Thread: Best way to import a GeoPDF into ArcMap 10?

  1. #1
    Charlie Parr
    Join Date
    May 2012
    Posts
    2
    Points
    1
    Answers Provided
    0


    1

    Default Best way to import a GeoPDF into ArcMap 10?

    I need to import a GeoPDF to ArcMap 10 for georeferencing purposes.
    The GeoPDF was created with ArcMap, but now ArcMap can't open it back up.
    How can I get this file into ArcMap? Are there some third-party file converters I should use?

    I've searched some help articles but I cannot find any clear explanation. Seems that GeoPDF is a relatively new spatial file format.

    Thanks!

  2. #2
    jim schmidt
    Join Date
    Aug 2013
    Posts
    2
    Points
    0
    Answers Provided
    0


    0

    Default Re: Best way to import a GeoPDF into ArcMap 10?

    Here's a Python script (version 3.3) to convert a USGS historic map GeoPDF in a polyconic projection to a GeoTiff in UTM coordinates. It relies on GDAL libraries that I obtained by installing MS4W and executing the python script from the MS4W shell prompt. The script creates two GeoTiffs for each input GeoPDF. If the GeoPDF is in a map projection that ArcGIS recognizes, then the first GeoTiff created should work fine in ArcMap. The script creates a second GeoPDF for each input GeoPDF assuming that the input projection is polyconic, NAD27 and the output projection is UTM10, NAD83. It uses the lat-long extent in the file header to create new control points in UTM NAD83.

    import glob, os
    import subprocess
    import pyproj

    def GetLatLon(line):
    coords = line.split(') (')[1]
    coords = coords[:-1]
    LonStr, LatStr = coords.split(',')
    # Longitude
    LonStr = LonStr.split('d') # Get the degrees, and the rest
    LonD = int(LonStr[0])
    LonStr = LonStr[1].split('\'')# Get the arc-m, and the rest
    LonM = int(LonStr[0])
    LonStr = LonStr[1].split('"') # Get the arc-s, and the rest
    LonS = float(LonStr[0])
    Lon = LonD + LonM/60. + LonS/3600.
    if LonStr[1] in ['W', 'w']:
    Lon = -1*Lon
    # Same for Latitude
    LatStr = LatStr.split('d')
    LatD = int(LatStr[0])
    LatStr = LatStr[1].split('\'')
    LatM = int(LatStr[0])
    LatStr = LatStr[1].split('"')
    LatS = float(LatStr[0])
    Lat = LatD + LatM/60. + LatS/3600.
    if LatStr[1] in ['S', 's']:
    Lat = -1*Lat
    return Lat, Lon

    EPSGin = "EPSG:4267" # Lat-Lon, NAD27 - Assumed coordinate system of lat-lon corner coordinates
    #EPSGout = "EPSG:26910" # UTM10, NAD83 - Output coordinate system for Geotiff files
    EPSGout = "EPSG:26911" # UTM11, NAD83 - Output coordinate system for Geotiff files

    dirname = "C:\\GeoPDFSold\\UTM11_62K\\" # Location of input pdf files Also used for output directory
    print(dirname)
    p1=pyproj.Proj(init= EPSGin) # Define input projection
    p2=pyproj.Proj(init= EPSGout) # Define output projection

    list_of_files1 = glob.glob(dirname +'*.pdf') # create the list of PDF files


    for file_name in list_of_files1:
    os.rename(file_name, file_name.replace(" ", "_")) #replace any blanks in filenames with underscore character

    list_of_files2 = glob.glob(dirname +'*.pdf') # create the list of renamed PDF files

    for file_name in list_of_files2:

    FIPDF = file_name
    FOTIFF1 = FIPDF.replace('pdf', 'tif')
    FOTIFF2 = FOTIFF1.replace('CA_', 'CA1_')
    print(FIPDF)
    print(FOTIFF1)
    print(FOTIFF2)

    # Export geoPDF to Geotiff at 300 dpi in original map projection coordinates (polyconic for USGS historic maps)

    os.system('gdal_translate.exe -of GTiff --config GDAL_PDF_DPI 300 -co COMPRESS=JPEG ' + FIPDF + ' '+ FOTIFF1)

    CornerLats = [0,0,0,0]
    CornerLons = [0,0,0,0]
    Cornerx = [0,0,0,0]
    Cornery = [0,0,0,0]
    gcp = ['','','','']
    xstr = ['','','','']
    ystr = ['','','','']
    GdalInfo = subprocess.check_output('gdalinfo {}'.format(FOTIFF1),shell=True,universal_newlines=True)# Runs Gdalinfo on exported GeoTiff
    GdalInfo = GdalInfo.splitlines() # Creates a line by line list.
    GotUL, GotUR, GotLL, GotLR, GotSize, GotPixel, Proj, NeedReproj = False, False, False, False, False, False, False, True

    for line in GdalInfo:
    print(line)
    if line.startswith("Size"):
    size = line.split()
    R = size[3]
    size2 = size[2].split(',')
    C = size2[0]
    CornerRow = ['0', R, '0', R]
    CornerCol = ['0', '0', C, C]
    GotSize = True

    if line.startswith("Pixel Size"):
    pix1 = line.split('(')
    pix2 = pix1[1].split(',')
    pixsize = float(pix2[0])
    halfpix = pixsize/2 # Adjustment to move coordinates to cell center from edge
    GotPixel = True

    if line.startswith("Upper Left"):
    CornerLats[0], CornerLons[0] = GetLatLon(line)
    Cornerx[0], Cornery[0] = pyproj.transform(p1,p2,CornerLons[0],CornerLats[0]) #Reproject edge coords in LL to Map proj
    Cornerx[0] = Cornerx[0] - halfpix # Adjustment to pixel edge
    Cornery[0] = Cornery[0] + halfpix
    GotUL = True

    if line.startswith("Lower Left"):
    CornerLats[1], CornerLons[1] = GetLatLon(line)
    Cornerx[1], Cornery[1] = pyproj.transform(p1,p2,CornerLons[1],CornerLats[1])
    Cornerx[1] = Cornerx[1] - halfpix
    Cornery[1] = Cornery[1] - halfpix
    GotLL = True

    if line.startswith("Upper Right"):
    CornerLats[2], CornerLons[2] = GetLatLon(line)
    Cornerx[2], Cornery[2] = pyproj.transform(p1,p2,CornerLons[2],CornerLats[2])
    Cornerx[2] = Cornerx[2] + halfpix
    Cornery[2] = Cornery[2] + halfpix
    GotUR = True

    if line.startswith("Lower Right"):
    CornerLats[3], CornerLons[3] = GetLatLon(line)
    Cornerx[3], Cornery[3] = pyproj.transform(p1,p2,CornerLons[3],CornerLats[3])
    Cornerx[3] = Cornerx[3] + halfpix
    Cornery[3] = Cornery[3] - halfpix
    GotLR = True

    if GotUL and GotUR and GotLL and GotLR and GotSize and GotPixel and NeedReproj:
    xstr[0] = str(Cornerx[0])
    xstr[1] = str(Cornerx[1])
    xstr[2] = str(Cornerx[2])
    xstr[3] = str(Cornerx[3])
    ystr[0] = str(Cornery[0])
    ystr[1] = str(Cornery[1])
    ystr[2] = str(Cornery[2])
    ystr[3] = str(Cornery[3])

    gcp[0] = ' -gcp '+ CornerCol[0]+ ' ' + CornerRow[0]+ ' ' + xstr[0]+ ' ' + ystr[0]
    gcp[1] = ' -gcp '+ CornerCol[1]+ ' ' + CornerRow[1]+ ' ' + xstr[1]+ ' ' + ystr[1]
    gcp[2] = ' -gcp '+ CornerCol[2]+ ' ' + CornerRow[2]+ ' ' + xstr[2]+ ' ' + ystr[2]
    gcp[3] = ' -gcp '+ CornerCol[3]+ ' ' + CornerRow[3]+ ' ' + xstr[3]+ ' ' + ystr[3]

    # Reproject to new geotiff file using control points

    gdalstr = 'gdal_translate.exe -of GTIFF -co COMPRESS=JPEG ' + FOTIFF1 + gcp[0] + gcp[1] + gcp[2] + gcp[3]+ ' -a_srs ' + EPSGout + ' '+ FOTIFF2
    print(gdalstr)
    os.system(gdalstr)
    NeedReproj = False
    Proj = True

    if GotUL and GotUR and GotLL and GotLR and GotSize and GotPixel and Proj:
    break

+ Reply to Thread

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts