I have a number of 1 km hexagonal grids that cover various counties in the United States in a postgreSQL/postGIS database. Each grid has the CRS EPSG:3857, and the counties layer has EPSG:3857. When viewing the grids with the counties in QGIS, everything looks grand.
But ... in order to share these grids with colleagues, I've had to export them to shapefiles using ogr2ogr. Viewing these in QGIS, each grid looks nudged up about 20 km or so, and QGIS automatically sets the CRS to EPSG:3395 (which is not the project CRS).
When I export the postGIS tables as shapefiles from QGIS, the .prj file looks exactly the same as the ogr2ogr exported shapefiles, but the postGIS exported tables are displayed correctly. I noticed that QGIS creates a .qpj file when exporting shapefiles from QGIS, so I've come to the conclusion that QGIS is ignoring the .prj and looking for a .qpj instead. Why can't it read the .prj without a .qpj? Other shapefiles (such as those from the US Census) don't have a .qpj but QGIS displays these correctly.
I've come up with a workaround by saving a default.qpj and creating a new .qpj from this for every file that export using ogr2ogr, but this seems messy and obviously not reproducible as it only works for EPSG:3857.
Sidenote: I'm using QGIS 2.0.1.
EDIT:
Here's the ogr2ogr command I used:
ogr2ogr -f "ESRI Shapefile" /home/matt/data/hex_grid_1 PG:'dbname=mydb user=matt' hex_grid_1
Contents of the .prj:
PROJCS["WGS_84_Pseudo_Mercator",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Mercator"],PARAMETER["central_meridian",0],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["Meter",1],PARAMETER["standard_parallel_1",0.0]]
Contents of the .qpj:
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,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],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"]],AXIS["X",EAST],AXIS["Y",NORTH],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"]]
EDIT:
The problem was solved by converting the EPSG:3857's to EPSG:2163 in all my scripts. I'm still not sure what the problem is though since the grids displayed correctly in QGIS when originally loaded from a postgreSQL table (with EPSG:3857).
My workaround proved crude as I thought it did, since my colleague was unable to use the file in ArcGIS, which didn't read the .prj or the .qpj properly.