Projection & raster questions

Stephen Davies sdc at SDC.COM.AU
Wed Nov 30 19:32:13 PST 2005


I have an application which is heavily based on the DHTML rubber band 
sample in the MapServer tutorial. That is, it used two divs to present 
a main map and a reference map with mapserv?mode=map commands.

(MapServer version 4.6.0 OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG OUTPUT=WBMP 
OUTPUT=SVG SUPPORTS=PROJ SUPPORTS=FREETYPE SUPPORTS=WMS_SERVER 
SUPPORTS=GEOS INPUT=TIFF INPUT=EPPL7 INPUT=JPEG INPUT=POSTGIS 
INPUT=SHAPEFILE)

The data involved is stored in a PostGIS database as lat/long 
coordinates and is (currently) projected into the map with proj=eqc 
lon_0=xxx where xxx is calculated dynamically as the centre of the 
initial map extent.

With the attached map1.map mapfile this works very well and users can 
zoom, pan and query from the main map and pan from the reference map 
with the correct results (though the area of interest square on the 
reference map is sometimes marginally out - particularly for very small 
map extents aganst relatively large reference maps).

The extent for the initial main map is given via the URL in the form:

&mapext=139.357482910156+-34.3308868408203+139.380233764648+-34.3129386901855

That is, long/lat (calculated dynamically from other input) and the 
UNITS are meters.

The values plpl, exex and cidcid are edited to realvalues before 
invoking mapserv. plpl is the calculated central meridian, cidcid is 
the current user ID and exex is the extent of the reference map IN 
METRES!

This latter extent is calculated from lat/long values using proj:

proj +proj=eqc +lon_0=$central (where $central is the same value as plpl 
above)

As I say, the above all works exactly as I want - provided the above 
projection and extent rules are followed.

However, I now want to add the raster layer and am having difficulty 
getting the new layer to align with the rest.

The raster file is an ECW.

Driver: ECW/ERMapper Compressed Wavelets
Size is 82560, 70380
Coordinate System is:
GEOGCS["GEOCENTRIC DATUM of AUSTRALIA",
    DATUM["GDA94",
        SPHEROID["GRS80",6378137,298.257222101]],
    PRIMEM["Greenwich",0],
    UNIT["degree",0.0174532925199433]]
Origin = (112.500000,-8.903313)
Pixel Size = (0.00050000,-0.00050000)
Corner Coordinates:
Upper Left  ( 112.5000000,  -8.9033134) (112d30'0.00"E,  8d54'11.93"S)
Lower Left  ( 112.5000000, -44.0933134) (112d30'0.00"E, 44d 5'35.93"S)
Upper Right ( 153.7800000,  -8.9033134) (153d46'48.00"E,  8d54'11.93"S)
Lower Right ( 153.7800000, -44.0933134) (153d46'48.00"E, 44d 5'35.93"S)
Center      ( 133.1400000, -26.4983134) (133d 8'24.00"E, 26d29'53.93"S)
Band 1 Block=82560x1 Type=Byte, ColorInterp=Red
  Overviews: arbitrary
Band 2 Block=82560x1 Type=Byte, ColorInterp=Green
  Overviews: arbitrary
Band 3 Block=82560x1 Type=Byte, ColorInterp=Blue
  Overviews: arbitrary

To test the ECW raster facility, I created a test map file (attached as 
map2.map).

The only ways that I could get the image displayed were to specify the 
projection as epsq:4263 and the extent as lat/long or the projection as 
eqc and the extent in meters relative to 0,0 at top left despite the 
image georef stuff all being in lat/long (why is this??).

Neither of these combinations will work in the existing application (as 
the rubber band and reference map interfaces require metres and a 
proper geographic extent) so I went back to square one with that app 
and tried again to specify the map extent in metres.
I used proj to convert the lat/long extent into metres and tried to 
generate a map. At first it looked as if the map was blank but then I 
randomly panned around and discovered that the data was actually there 
but off the map. Apparently, the extent values out of the proj command 
differ quite significantly from the same values generated within 
mapserv????

For example, proj gave me values of -1282.08, -3821696.8 & 
1250.54,-3819699 while mapserv gave -1336.4, -3802151 & 1351.1, 
-3799464 for approximately the same piece of space.

So, I now have two problems:
1. how to calculate the correct extent values for the base app and
2. how to get the raster layer to align with the rest (that is with the 
same extent as the rest rather than the 0,0-based one).

TIA,
Stephen avies

-- 
========================================================================
This email is for the person(s) identified above, and is confidential to
the sender and the person(s).  No one else is authorised to use or
disseminate this email or its contents.

Stephen Davies Consulting                            Voice: 08-8177 1595
Adelaide, South Australia.                             Fax: 08-8177 0133
Computing & Network solutions.                       Mobile:0403 0405 83
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: signature
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20051201/51ae24f0/attachment.sig>
-------------- next part --------------
MAP
  NAME benparts1
   

  PROJECTION
	"proj=eqc"
	"lon_0=plpl"
  END

  SIZE 600 600
  FONTSET "/usr/local/apache2/htdocs/benparts/fonts.list"
  SYMBOLSET "/usr/local/apache2/htdocs/benparts/symbols"
  UNITS METERS
  IMAGETYPE  png
  IMAGECOLOR 255 255 255

    WEB
	template /usr/local/apache2/htdocs/benparts/templates/test1.html
	imagepath "/usr/local/apache2/htdocs/tmp/"
	imageurl  "/tmp/"
    END

    LEGEND
	KEYSIZE 18 12
	LABEL
	  TYPE BITMAP
	  SIZE MEDIUM
	  COLOR 0 0 94
	END
	STATUS ON
    END

    LAYER
      CONNECTIONTYPE postgis
      NAME "cadt"
      DATA "geom from cad"
      CONNECTION "user=scldad dbname=benparts"
      STATUS DEFAULT
      TYPE POINT
      PROJECTION
        "init=epsg:4263"
      END
      FILTER "gtype='T' and client_id=cidcid"
      CLASSITEM "type"
      CLASS
	EXPRESSION "201"
	STYLE
	  COLOR 0 255 0
	END
	STYLE
	  SYMBOL "tree"
	  COLOR 0 255 0
	  SIZE 9
	END
      END

      CLASS
	EXPRESSION "754"
        LABEL
          MINDISTANCE 150
          POSITION CR
          SIZE TINY
          COLOR 0 0 0
	  FORCE TRUE
        END
	TEXT 'WM'
	STYLE
	  SYMBOL "dot"
	  COLOR 0 0 0
	  SIZE 5
	END
      END

      CLASS
	EXPRESSION "757"
        LABEL
          MINDISTANCE 150
          POSITION CR
          SIZE TINY
          COLOR 0 0 0
	  FORCE TRUE
        END
	TEXT 'Bore'
	STYLE
	  SYMBOL "dot"
	  COLOR 0 0 0
	  SIZE 5
	END
      END

      CLASS
	EXPRESSION "712"
	STYLE
	  SYMBOL "stobie"
	  SIZE 4
	  COLOR 255 0 168
	END
      END

      CLASS
	EXPRESSION /./
        STYLE
	  SYMBOL "dot"
	  COLOR 0 0 0
	  SIZE 5
        END
      END
    END

    LAYER
      CONNECTIONTYPE postgis
      NAME "cadl"
      DATA "geom from cad"
      CONNECTION "user=scldad dbname=benparts"
      STATUS DEFAULT
      TYPE LINE
      PROJECTION
        "init=epsg:4263"
      END
      FILTER "gtype in ('L','P') and client_id=cidcid"
      CLASSITEM "type"
      CLASS
	EXPRESSION "908"
	STYLE
	  SYMBOL "fence"
	  SIZE 10
	  COLOR 0 255 0
	END
	STYLE
	  SYMBOL "dot"
	  COLOR 0 255 0
	  SIZE 1
	END
      END

      CLASS
	EXPRESSION "712"
	STYLE
	  SYMBOL "power"
	  SIZE 8
	  COLOR 255 0 168
	END
	STYLE
	  SYMBOL "dot"
	  COLOR 255 0 168
	  SIZE 1
	END
      END

      CLASS
	EXPRESSION "602"
        STYLE
	  SYMBOL "dot"
	  COLOR 137 205 190
	  SIZE 1
        END
      END
      CLASS
	EXPRESSION /./
        STYLE
          COLOR        0 0 0 
        END
      END
    END

    LAYER
      CONNECTIONTYPE postgis
      NAME "probe"
      DATA "geom from probe"
      CONNECTION "user=scldad dbname=benparts"
      STATUS DEFAULT
      TYPE POINT
#      FILTER "id in (0)"
      PROJECTION
        "init=epsg:4263"
      END
      MAXSCALE 5000000
      LABELITEM "location"
      CLASS
        NAME       "Probe"
        STYLE
          COLOR        0 214 0
          SYMBOL 'circle'
	  SIZE 7
        END
        LABEL
          MINDISTANCE 150
          POSITION CR
          SIZE SMALL
          COLOR 0 0 0
        END
      END
    END

  #
  # Start of reference map
  #
  REFERENCE
    IMAGE /usr/local/apache2/htdocs/benparts/refmaps/ixix
    EXTENT exex
    SIZE 120 120
    STATUS ON
    MINBOXSIZE 5
    MAXBOXSIZE 100
    COLOR 0 255 0
    OUTLINECOLOR 0 0 0
    MARKERSIZE 8
    MARKER 'star'
  END
  #
  # Start of scalebar
  #
  SCALEBAR
    IMAGECOLOR 0 0 0
    LABEL
      COLOR 255 255 255
      SIZE TINY
    END
    STYLE 1
    SIZE 200 2
    COLOR 255 255 255
    UNITS KILOMETERS
    INTERVALS 2
    TRANSPARENT TRUE
    STATUS ON
  END
END
-------------- next part --------------
MAP
  NAME test
   

  PROJECTION
   "init=epsg:4263"
  END
#  PROJECTION
#	"proj=eqc"
#        "lon_0=112.5e"
#  END

    EXTENT 112.5 -44.0933134 153.78 -8.9033134
#    EXTENT 135.5 -40.0933134 143.78 -28.9033134
#     EXTENT 139.357482910156 -34.3308868408203 139.380233764648 -34.3129386901855
#    EXTENT 0 -5000000 4200000 0

  SIZE 600 600
  SHAPEPATH "/benparts/rasters"
  UNITS METERS
  IMAGETYPE  png
  IMAGECOLOR 255 255 255
    OUTPUTFORMAT
	NAME ecw
	DRIVER "GDAL/ECW"
	MIMETYPE "image/ecw"
	IMAGEMODE PC256
	EXTENSION "ecw"
    END

    WEB
	template /usr/local/apache2/htdocs/benparts/templates/test1.html
	imagepath "/usr/local/apache2/htdocs/tmp/"
	imageurl  "/tmp/"
    END

    LAYER
      TYPE RASTER
      NAME "bkgrnd"
      STATUS DEFAULT
      DATA "/tmp/ls7_mosaic.ecw"
      PROJECTION
        "init=epsg:4283"
      END
      OFFSITE 255 255 255
    END
END


More information about the MapServer-users mailing list