Given the following NEATLINE from the results of gdalinfo on my Geospatial PDF:
NEATLINE=POLYGON ((-1340591.5297333347 -260482.28440259479,-1340591.0579001249 1878014.4171204455,3081498.0723039531 1878014.3548907496,3081497.6538160094 -260482.78408519758,-1340591.5297333347 -260482.28440259479))
I used the following code to convert the result to EPSG:4326 coordinates
from osgeo import ogr
from osgeo import osr
x = [-1340591.5297333347,-1340591.0579001249,3081498.0723039531,3081497.6538160094,-1340591.5297333347]
y = [-260482.28440259479,1878014.4171204455,1878014.3548907496,-260482.78408519758,-260482.28440259479]
i = 0
while i < 5:
pointX = x[i]
pointY = y[i]
# Spatial Reference System
inputEPSG = 3857
outputEPSG = 4326
# create a geometry from coordinates
point = ogr.Geometry(ogr.wkbPoint)
point.AddPoint(pointX, pointY)
# create coordinate transformation
inSpatialRef = osr.SpatialReference()
inSpatialRef.ImportFromEPSG(inputEPSG)
outSpatialRef = osr.SpatialReference()
outSpatialRef.ImportFromEPSG(outputEPSG)
coordTransform = osr.CoordinateTransformation(inSpatialRef, outSpatialRef)
# transform point
point.Transform(coordTransform)
# print point in EPSG 4326
print point.GetY(), point.GetX()
i += 1
This results in:
-2.33930197857 -12.0427386092
16.6318711337 -12.0427343707
16.6318705981 27.6815681634
-2.33930646355 27.681564404
-2.33930197857 -12.0427386092
It looks close to being right, but the 27 degrees longitude on lines 3 and 4 should be more around 54 degrees East.
The additional information from the gdalinfo is as follows:
PROJCS["Lambert_Conformal_Conic",
GEOGCS["GCS_WGS_1984",
DATUM["WGS_1984",
SPHEROID["WGS_84",6378137.0,298.257223563],
TOWGS84[0,0,0,0,0,0,0]],
PRIMEM["Greenwich",0.0],
UNIT["Degree",0.0174532925199433]],
PROJECTION["Lambert_Conformal_Conic_2SP"],
PARAMETER["False_Easting",0.0],
PARAMETER["False_Northing",0.0],
PARAMETER["Central_Meridian",25.0],
PARAMETER["Standard_Parallel_1",7.66666666],
PARAMETER["Standard_Parallel_2",38.3333333],
PARAMETER["Latitude_Of_Origin",0.0],
UNIT["Meter",1.0]]
GeoTransform =
-2133343.372843582, 754.0130468353923, 3.981217275795919
2035401.595692971, 3.953040951345574, -753.9627451388365
I assume I'm using the correct inputEPSG in my code, if not, does anyone know what I should use in its place?
I guess it is also entirely possible that the NEATLINE is incorrect.
Best Answer
To proof the projection string, you can load the WKT of the neatline directly into QGIS, on a tiles background:
The green line uses the CRS from your PDF, and the red one uses SRID 102024. Project CRS is the first one, that's why it looks like a rectangle.
By the way, I had put your PDF WKT definition into a .prj file, and ran gdalsrsinfo on it to get the proj.4 string.