I've been having a problem with GDAL/OGR lately mixing up projections EPSG:3857 and EPSG:54004. I'm cropping some 3857-projected raster files (reprojected using gdalwarp
from UTM) by 3857-projected vector files (reprojected using ogr2ogr
from KML files - EGPS:4326). I checked gdalinfo
and ogrinfo
for both and they seem to be the right projection. The result is a clipped raster that only contains part of what I want due to the offset between 3857 (which it seems the raster stays in) and 54004 (which it seems to think the vector is in). So generally only a part of (some of the bottom) of the desired raster will show due to the 54004 vector being offset north of where the 3857 raster is.
I did see a similar problem in this post, but this made me think it was a QGIS issue as opposed to underlying GDAL/OGR which I've exclusively used for my data processing. While the workaround suggested there via QGIS is effective, I will be doing this with many files, so it seems impractical for my requirements. When I check GDAL version I'm on: "GDAL 1.11.3, released 2015/09/16". I installed this using homebrew (brew install gdal) on a mac, and this seems to be the latest version available via this method from kyngchaos.
So: Is it possible I'm doing something wrong with my projecting/processing (see info below) or is it perhaps my version of GDAL which may be the problem as seen here? If it is the gdal version, please advise the best way to upgrade this on a mac (since home-brew insists I'm using the latest version with 'brew upgrade gdal'?
Here is my clipping command:
gdalwarp -crop_to_cutline -cutline vector.shp raster.vrt output.tif
Also below are example 'gdalinfo' and 'ogrinfo -so' outputs, respectively.
RASTER:
Driver: VRT/Virtual Raster
Files: raster.vrt
Size is 63319, 54925
Coordinate System is:
PROJCS["WGS 84 / Pseudo-Mercator",
GEOGCS["WGS 84",
DATUM["WGS_1984",
SPHEROID["WGS 84",6378137,298.257223563,
AUTHORITY["EPSG","7030"]],
AUTHORITY["EPSG","6326"]],
PRIMEM["Greenwich",0],
UNIT["degree",0.0174532925199433],
AUTHORITY["EPSG","4326"]],
PROJECTION["Mercator_1SP"],
PARAMETER["central_meridian",0],
PARAMETER["scale_factor",1],
PARAMETER["false_easting",0],
PARAMETER["false_northing",0],
UNIT["metre",1,
AUTHORITY["EPSG","9001"]],
EXTENSION["PROJ4","+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs"],
AUTHORITY["EPSG","3857"]]
Origin = (-11716505.067412510514259,4866089.724105604924262)
Pixel Size = (1.323481832251734,-1.323481832251734)
Corner Coordinates:
Upper Left (-11716505.067, 4866089.724) (105d15' 4.16"W, 40d 0' 3.65"N)
Lower Left (-11716505.067, 4793397.484) (105d15' 4.16"W, 39d29'56.26"N)
Upper Right (-11632703.521, 4866089.724) (104d29'54.07"W, 40d 0' 3.65"N)
Lower Right (-11632703.521, 4793397.484) (104d29'54.07"W, 39d29'56.26"N)
Center (-11674604.294, 4829743.604) (104d52'29.12"W, 39d45' 1.60"N)
Band 1 Block=128x128 Type=Byte, ColorInterp=Red
NoData Value=0
Band 2 Block=128x128 Type=Byte, ColorInterp=Green
NoData Value=0
Band 3 Block=128x128 Type=Byte, ColorInterp=Blue
NoData Value=0
VECTOR:
INFO: Open of `vector.shp'
using driver `ESRI Shapefile' successful.
Layer name: vector
Geometry: Polygon
Feature Count: 1
Extent: (-11705558.991470, 4803872.365048) - (-11639276.914951, 4859716.734835)
Layer SRS WKT:
PROJCS["WGS_84_Pseudo_Mercator",
GEOGCS["GCS_WGS_1984",
DATUM["WGS_1984",
SPHEROID["WGS_84",6378137,298.257223563]],
PRIMEM["Greenwich",0],
UNIT["Degree",0.017453292519943295]],
PROJECTION["Mercator_1SP"],
PARAMETER["central_meridian",0],
PARAMETER["false_easting",0],
PARAMETER["false_northing",0],
UNIT["Meter",1],
PARAMETER["latitude_of_origin",0.0]]
Name: String (80.0)
Descriptio: String (80.0)
Output from 'gdalsrsinfo -e vector.shp':
Warning 1: EPSG detection is experimental and requires new data files (see bug #4345)
EPSG:-1
PROJ.4 : '+proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs '
OGC WKT :
PROJCS["WGS_84_Pseudo_Mercator",
GEOGCS["GCS_WGS_1984",
DATUM["WGS_1984",
SPHEROID["WGS_84",6378137,298.257223563]],
PRIMEM["Greenwich",0],
UNIT["Degree",0.017453292519943295]],
PROJECTION["Mercator_1SP"],
PARAMETER["central_meridian",0],
PARAMETER["false_easting",0],
PARAMETER["false_northing",0],
UNIT["Meter",1],
PARAMETER["latitude_of_origin",0.0]]