[mapserver-users] ECW Problems

Jeff McKenna jmckenna at gatewaygeomatics.com
Fri Jul 18 07:50:01 PDT 2008


On 18-Jul-08, at 9:21 AM, Derek Bain wrote:

> Hi
> I cannot get ecw files to work in Mapserver. I have updated my map  
> file (see below).
>
> Is there any configuration that I have to do to enable this or is  
> ecw by default. I am using ms4w beta 5..2.
>
> My client is WorldWind and I am using the "Import to WMS Url Layer"  
> option. It would appear that MapServer fails when processing the map  
> file. Are there any options to set to enable a debug console window  
> when processing the map file.
>
> I have checked that my ecw file is georeferenced and it is.
>
> Thanks
> Derek
>
>
>    LAYER
>        NAME TestECWLayer
>        TYPE RASTER
>        STATUS ON
>        DUMP TRUE
>        DATA "C:/Progra~1/ms4w/Apps/All_Data/data/testfile.ecw"
>        PROJECTION
>            "init=epsg:4326"
>        END
>
>
>        METADATA
>            "wms_title"                "TestECWLayer"
>            "wms_abstract"            "TestECWLayer abstract goes  
> here ...."
>            "wms_srs"                 "EPSG:4326"
>            "wms_name"                "TestECWLayer"
>            "wms_format"            "image/png image/jpeg"
>            "wms_extent"            "-88.9803405 30.2175328   
> -88.9755868 30.2216604"
>            "wms_onlineresource"    "http://localhost:8082/cgi-bin/mapserv.exe?map=C:/Progra 
> ~1/ms4w/apps/All_Data/ECW_Test.map"
>        END
>
>        CLASS
>            NAME "TestECWLayer"
>            COLOR 255 0 0
>        END
>            END

Hello,

I have made some notes for you below to assist you with your ECW issue:

1) MS4W (and its underlying GDAL library) comes ready to use ECW data
    by default.  To verify this, execute /ms4w/setenv.bat at the
    commandline, and then execute "gdalinfo --formats" to
    see if ECW is supported, such as:

	>gdalinfo --formats
	
	Supported Formats:
	  VRT (rw+): Virtual Raster
	  GTiff (rw+): GeoTIFF
	  ...
	  ECW (rw): ERMapper Compressed Wavelets
	  ...
	  ADRG (rw+): ARC Digitized Raster Graphics



2) Now that you have established that your local build has ECW support,
    now use the gdalinfo command on your data to get some basic info
    on your ecw file, such as:

    	>gdalinfo image1.ecw
    	
	Driver: ECW/ERMapper Compressed Wavelets
	Files: image1.ecw
	       image1.ecw.aux.xml
	Size is 7966, 8274
	Coordinate System is:
	PROJCS["LCC         E008",
	    GEOGCS["NAD83",
		DATUM["North_American_Datum_1983",
		    SPHEROID["GRS 1980",6378137,298.2572221010002,
			AUTHORITY["EPSG","7019"]],
		    AUTHORITY["EPSG","6269"]],
		PRIMEM["Greenwich",0],
		UNIT["degree",0.0174532925199433],
		AUTHORITY["EPSG","4269"]],
	    PROJECTION["Lambert_Conformal_Conic_2SP"],
	    PARAMETER["standard_parallel_1",49],
	    PARAMETER["standard_parallel_2",77],
	    PARAMETER["latitude_of_origin",49],
	    PARAMETER["central_meridian",-95],
	    PARAMETER["false_easting",0],
	    PARAMETER["false_northing",0],
	    UNIT["metre",1,
		AUTHORITY["EPSG","9001"]]]
	Origin = (2878735.262000000100000,995462.974999999980000)
	Pixel Size = (30.000000000000000,-30.000000000000000)
	Metadata:
	  AREA_OR_POINT=Area
	Corner Coordinates:
	Upper Left  ( 2878735.262,  995462.975) ( 52d35'49.00"W, 48d59'18.47"N)
	Lower Left  ( 2878735.262,  747242.975) ( 54d36'32.41"W, 47d13'6.98"N)
	Upper Right ( 3117715.262,  995462.975) ( 50d 6'40.01"W, 47d37'48.85"N)
	Lower Right ( 3117715.262,  747242.975) ( 52d 9'36.52"W, 45d55'23.39"N)
	Center      ( 2998225.262,  871352.975) ( 52d22'14.82"W, 47d27'4.74"N)
	Band 1 Block=7966x1 Type=Byte, ColorInterp=Red
	  Overviews: arbitrary
	Band 2 Block=7966x1 Type=Byte, ColorInterp=Green
	  Overviews: arbitrary
	Band 3 Block=7966x1 Type=Byte, ColorInterp=Blue
	  Overviews: arbitrary
	
3) Next step is to create a small test mapfile with only one layer,  
for that
    ecw file.  For the EXTENT parameter you can use the lower left and  
upper right
    coordinates listed in your gdalinfo response, such as:

    #
    # Start of map file
    #
    #
    NAME ecw-test
    STATUS ON
    SIZE 600 400
    EXTENT 2878735.262 747242.975 3117715.262 995462.975
    UNITS METERS
    SHAPEPATH "../data"

    #
    # Start of layer definitions
    #

    LAYER
      NAME "ecw-image"
      TYPE RASTER
      STATUS DEFAULT
      DATA "image1.ecw"
    END # Layer

    END # Map File

4) You can test your tiny mapfile with MapServer's "shp2img" utility  
that is part of
    MS4W.  (make sure you execute /ms4w/setenv.bat beforehand).   
shp2img will
    create a map image file or return a MapServer error at the  
commandline.
    You can use this MapServer error to track down the problem in your  
mapfile.
    Here is an example shp2img command to show you how to see  
debugging information
    with shp2img:

    >shp2img -m ecw.map -o test.png -map_debug 3

       msDrawRasterLayerLow(ecw-image): entering.
       msDrawMap(): Layer 0 (ecw-image), 0.220s
       msDrawMap(): Drawing Label Cache, 0.000s
       msDrawMap() total time: 0.220s
       msSaveImage() total time: 0.010s


    In the above test case a "test.png" image file was created in the  
same
    directory as my "ecw.map" file.




---
Jeff McKenna
FOSS4G Consulting and Training Services
http://www.gatewaygeomatics.com/


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20080718/37ff0d0f/attachment.htm>


More information about the MapServer-users mailing list