1

我尝试使用 WMS 在 web 上以 geotiff 格式显示栅格地图。我想对光栅文件进行分类。我怎样才能做到这一点?我在 Windows 上使用地图服务器。以下是我的 .map 文件。我得到的是

MAP
NAME PM10
IMAGECOLOR 255 255 255
SIZE 600 800
IMAGETYPE PNG24 ## use AGG to for anti-aliassing
OUTPUTFORMAT
NAME 'AGG'
DRIVER AGG/PNG
MIMETYPE "image/png"
IMAGEMODE RGB
EXTENSION "png"
END # outputformat
PROJECTION
"init=epsg:3035" #latlon on etrs 1989 laea
 END
 EXTENT 3487500 2297500 4402500 3202500 # meters extents of region2
 WEB
 IMAGEPATH "c:/tmp/ms_tmp/"
 IMAGEURL "/ms_tmp/"
 METADATA
  "ows_enable_request"   "*"
  "map" "C:/ms4w/apps/airpollution/config.map"
  "ows_schemas_location" "http://schemas.opengeospatial.net"
  "ows_title" "Sample WMS"
  "ows_enable_request"   "*"
  "ows_onlineresource" "http://localhost:7070/cgi-bin/mapserv.exe?       map=C:/ms4w/apps/airpollution/config.map&"
  "ows_srs" "EPSG:3035 " #latlon      
  "wms_feature_info_mime_type" "text/plain"
  "wms_feature_info_mime_type" "text/html"
  "wms_server_version" "1.1.1"
  "wms_formatlist" "image/png,image/gif,image/jpeg, image/geotiff"
  "wms_format" "image/geotiff"
 END #metadata
 END #web
 LAYER
 NAME "pm10"
DATA "pm10.tif"
 TYPE RASTER
 STATUS ON
    METADATA
  "ows_title" "pollution"
 END #metadata
 PROJECTION
  "init=epsg:3035"
END #projection
CLASSITEM "[pixel]"
 # class using simple string comparison, equivelent to ([pixel] = 0)
 CLASS
 EXPRESSION "0"
 STYLE
  COLOR 20 20 20
 END
 END
# class using an EXPRESSION using only [pixel].
CLASS
EXPRESSION ([pixel] >= 0AND [pixel] < 7)
STYLE
  COLOR 255 0 0
END
CLASS
EXPRESSION ([pixel] >= 7AND [pixel] < 20)
STYLE
  COLOR 0 255 0
END
END
CLASS
EXPRESSION ([pixel] >= 7AND [pixel] < 50)
STYLE
  COLOR 0 0 255
END
END


END #layer pm10
END #map

我得到的回应是这张图片WMS的响应

它似乎只读取第 3 行

IMAGECOLOR 255 255 255
4

1 回答 1

3

我不太了解地图服务器,但我知道您可以使用 SLD(样式化图层描述符)从 WMS 设置栅格样式,这只是一个 xml 文件,您可以根据 OGC 标准传入 WMS 请求。

换句话说:您可以在 XML 模式中指定分类。以下是一个简单的 SLD 示例,它将除白色像素之外的所有内容设置为黑色,白色像素的样式为不透明。

    <?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.0" xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd">
    <NamedLayer>
        <Name>undefined</Name>
        <UserStyle>
            <Name>rasterr</Name>
            <Title>Rasterr</Title>
            <Abstract>A simple raaster style</Abstract>
            <FeatureTypeStyle>
                <FeatureTypeName>Feature</FeatureTypeName>
                <Rule>
                    <RasterSymbolizer>
                        <Opacity>1.0</Opacity>
                        <ColorMap>
                            <ColorMapEntry color="#ffffff" quantity="0" opacity="0.0" />
                            <ColorMapEntry color="#000000" quantity="1" />
                            <ColorMapEntry color="#000000" quantity="2" />
                            <ColorMapEntry color="#000000" quantity="3" />
                            <ColorMapEntry color="#000000" quantity="4" />
                            <ColorMapEntry color="#000000" quantity="5" />
                            <ColorMapEntry color="#000000" quantity="6" />
                            <ColorMapEntry color="#000000" quantity="7" />
                            <ColorMapEntry color="#000000" quantity="8" />
                            <ColorMapEntry color="#000000" quantity="9" />
                            <ColorMapEntry color="#000000" quantity="10" />
                        </ColorMap>
                    </RasterSymbolizer>
                </Rule>
            </FeatureTypeStyle>
        </UserStyle>
    </NamedLayer>
</StyledLayerDescriptor>

像这样传递 SLD:

http://demo.mapserver.org/cgi-bin/wms?SERVICE=wms&VERSION=1.1.1&REQUEST=GetMap&LAYERS=country_bounds&SLD=http://demo.mapserver.org/ogc-demos/map/sld/sld_line_simple.xml

在这里阅读更多:

http://mapserver.org/ogc/sld.html - 这是用于地图服务器的,使用 RasterSymbolizer 和 ColorMap 进行分类。在该页面上还描述了颜色图的工作原理。

http://www.opengeospatial.org/standards/sld 维基百科

于 2013-01-05T19:19:51.743 回答