For obvious reasons ![]()
- Needs the
PDFIO.jlpackage (to install] add PDFIO) - Put the followin in a .jl file
using PDFIO, GMT
function squeeze_aip(file::String="AD 2 EDDF 1-5.pdf")
# 'file' is the the (full) name of the PDF to squeeze. If not provided, defaults to "AD 2 EDDF 1-5.pdf"
doc = pdDocOpen(file)
page = pdDocGetPage(doc, 1)
io = IOBuffer();
t = pdPageExtractText(io, page);
tt = split(String(take!(io)), '\n')
nc = length(tt) - 9 # Number of actual coordinates
lonlat = zeros(nc, 2) # Pre-allocate the lon,lat matrix
for k = 1:nc
s = split(tt[k+6]) # ["B10", "N", "50", "02", "55.23", "E", "008", "34", "17.78"]
lonlat[k,2] = (parse(Int, s[3]) + parse(Float64, s[4])/60 + parse(Float64, s[5])/3600) * (s[2] == "N" ? 1 : -1)
lonlat[k,1] = (parse(Int, s[7]) + parse(Float64, s[8])/60 + parse(Float64, s[9])/3600) * (s[6] == "E" ? 1 : -1)
end
return mat2ds(lonlat, proj="geog")
end
- run it (
include("squeeze_aip.jl); squeeze_aip())
julia> squeeze_aip()
BoundingBox: [8.52953888888889, 8.591800000000001, 50.03703055555555, 50.05206944444444]
PROJ: +proj=longlat +datum=WGS84 +units=m +no_defs
69×2 GMTdataset{Float64, 2}
Row │ Lon Lat
│ Float64 Float64
─────┼──────────────────
1 │ 8.57161 50.0487
2 │ 8.57218 50.048
3 │ 8.57169 50.0474
4 │ 8.57232 50.0471
...