1

I have a map with OSM and Google Base layers and EPSG:4326 overlays. Now I am also trying to add overlays with other EPSG's to my map. Overlays which had an EPSG:2333 displayed just fine with no problems. Then I tried to add a layer with EPSG:4008 and nothing showed up. I posted on the openLayers forum and was told to look into the proj4js project (many thanks for that btw!). I have tried using it and it seems promising, but it is just not working for me :(

In my body tag I have the scripts

<script src="./OpenLayers-2.10/OpenLayers.js"></script>
<script src="./proj4js/lib/proj4js-combined.js"></script> //I did also try proj4js.js, but the docs said use this one?

Then I have these before my map and layer declaration, also in the body tag

Ext.onReady(function() {

            Proj4js.defs["EPSG:4008"] = "+proj=longlat +ellps=clrk66 +no_defs";
            Proj4js.defs["SR-ORG:6627"] = "+proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs";
            Proj4js.defs["EPSG:4326"] = "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs";

...
...


//Map properties
            var options = {
                    controls: [new OpenLayers.Control.Navigation()], //Needed to use GeoExt controls such as the zoomslider
                    maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34, 20037508.34, 20037508.34),
                    units: 'm',
                    allOverlays: false //Do not display all layers on load
            }

            var map = new OpenLayers.Map(options);

var borders = new OpenLayers.Layer.WMS(
                    "Borders", "http://localhost:8080/geoserver/wms", {id: 'borders', layers: 'cite:sedac', transparent: true, projection: new OpenLayers.Projection("EPSG:4008")}, {isBaseLayer: false, displayInLayerSwitcher: true, visibility: true}
               );

and have also tried this layer config...after reading this post http://getsatisfaction.com/opengeo/topics/reprojecting_in_openlayers

var borders = new OpenLayers.Layer.WMS(
                    "Borders", "http://localhost:8080/geoserver/wms", {id: 'borders', layers: 'cite:sedac', transparent: true, srsName: 'EPSG:4326'}, {isBaseLayer: false, displayInLayerSwitcher: true, visibility: true}
               );

Still nothing shows up :(. Am I doing something wrong? I'm not seeing the error...

Is it even possible to use layers with various projections??? I can't change my map's projection to be 'EPSG:4008' because it will break my other layers, the advice on the docs was to specify the layer's projection, but as my code shows I have tried this with no luck.

I appreciate your time in looking into this matter for me,

elshae

EDIT I have also tried converting the shapefiles with ogr2ogr:

ogr2ogr -s_srs ./SEDAC/tibet.prj -t_srs EPSG:4326 ./SEDAC/new_tibet.shp ./SEDAC/tibet.shp

And get the following error:

ERROR 6: No translation for Lambert_Conformal_Conic to PROJ.4 format is known.
Failed to create coordinate transformation between the
following coordinate systems.  This may be because they
are not transformable, or because projection services
(PROJ.4 DLL/.so) could not be loaded.
Source:
PROJCS["Lambert_Conformal_Conic",
    GEOGCS["Unknown datum based upon the Clarke 1866 ellipsoid",
        DATUM["D_Clarke_1866",
            SPHEROID["Clarke_1866",6378206.4,294.9786982139109]],
        PRIMEM["Greenwich",0],
        UNIT["Degree",0.017453292519943295]],
    PROJECTION["Lambert_Conformal_Conic"],
    PARAMETER["standard_parallel_1",25],
    PARAMETER["standard_parallel_2",47],
    PARAMETER["latitude_of_origin",10],
    PARAMETER["central_meridian",110],
    PARAMETER["false_easting",0],
    PARAMETER["false_northing",0],
    UNIT["METERS",1]]
Target:
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.01745329251994328,
        AUTHORITY["EPSG","9122"]],
    AUTHORITY["EPSG","4326"]]
Tomas
  • 57,621
  • 49
  • 238
  • 373
elshae
  • 539
  • 3
  • 11
  • 30
  • I am still unable to get this one working :-/. If anyone can offer advice, I'll really really appreciate it! – elshae Dec 21 '10 at 14:42

2 Answers2

0

I'm not quite sure what you are trying to do, but OpenLayers can only fully reproject vector data. It cannot apply a new projection to a tile layer (eg. WMS) - in theory corners could be easily reprojected, but the shape of the tiles can be distorted, and OpenLayers does not have the capability to do this. So you should set your WMS server to use the projection you wish to use in the final application, and then reproject any vector overlays in OpenLayers.

winwaed
  • 7,645
  • 6
  • 36
  • 81
  • Does that mean I am limited to using only vector layers if the shapefile had EPSG:4008? I am not so sure how to do that..This was a shapefile I obtained and using shp2pgsql entered in my PostGIS database. From there I want to have Geoserver use the data and create the layer. In Geoserver, my layer preview looks correct, but on my map, the layer does not display at all :(. Is there anything else I can do? – elshae Dec 17 '10 at 15:08
  • Is your EPSG:4008 layer being provided by WMS? If so, I would reproject it on the server - tell your WMS server to reproject to a projection that matches the other layers. – winwaed Dec 17 '10 at 16:10
  • Yes my layer is being provided by WMS. Unfortunately, I have no idea how to reproject data on Geoserver :(. If I select any other EPSG other than 4008 for this layer it either doesn't show at all, or displays in an unexpected place on my map... If you could drop me a hint on how to do this, that would be awesome :) – elshae Dec 17 '10 at 17:36
  • Sorry - I've never used GeoServer. My WMS servers are all UMN MapServer. With MapServer, you can set the coordinate system (and hence projection) in the map script file. I haven't used it due to web server restrictions, but I keep hearing that GeoServer is easier to use...!? – winwaed Dec 17 '10 at 17:49
  • It definitely is easy to use! And it also has wonderful documentation. It might be slower compared to other map servers because it was created in Java, but don't take my word for this. Geoserver allows me to do the same exact thing you are describing, but then when I load the layer on my map, it is nowhere to be found :( – elshae Dec 17 '10 at 19:13
0

Good News everyone!

I got it :)

I changed my shapefile to lon lat by using:

ogr2ogr -t_srs WGS84 outfile.shp infile.shp

Although I do wonder if this had any effect in altering my shapefile data in unexpected ways...I see that my preview in Geoserver of the original shapefile seems shifted at an angle that my new WGS84 shapefile does not...

However I'll point out that the angle of the new WGS84 shapefile seems to be more correctly positioned as it overlays my base layer pretty well (some little areas not perfectly, but this might be due to the shapefile itself as it is almost perfect :p)

I want to extend a very warm thank you to Arnd and Wally for their continuous kind and patient help on the OpenLayers forum and for teaching me how to use many great tools that I had never known about. (Proj4js, ogr2ogr, etc)

Happy Mapping,

elshae

elshae
  • 539
  • 3
  • 11
  • 30