日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

MapServer Tutorial——MapServer7.2.1教程学习——第一节用例实践:Example1.5 Adding a raster layer...

發布時間:2024/1/17 编程问答 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 MapServer Tutorial——MapServer7.2.1教程学习——第一节用例实践:Example1.5 Adding a raster layer... 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

MapServer Tutorial——MapServer7.2.1教程學習——第一節用例實踐:Example1.5 Adding a? raster layer

一、前言

  MapServer不僅支持矢量數據(point, lines, polygons, and annotations),同時也支持柵格數據。通過GDAL庫,MapServer可以輸入輸出多種類型的柵格數據。

  在4.x版本前,MapServer輸出柵格數據僅限于單個圖層、灰度圖像或偽彩色圖像。

  當前版本支持RGB圖像和多光譜圖像(多層級multi-layer)。此示例演示如何選擇使用多光譜數據時要顯示的圖層。官網地址:https://www.mapserver.org/tutorial/example1-5.html

  注意?在使用RGB和多光譜圖像時,可能會出現明顯的性能問題。

  因為MapServer5.x后使用AGG或GD2.x來生成輸出的圖像,它還支持RGB(24位或真彩色)輸出。因此,除了8位(灰度圖像或偽彩色圖像)png8之外,現在還可以使用png(真顏色)進行輸出。此示例使用PNG作為ImageType。

  注意?與RGB輸入一樣,與PNG8相比,使用PNG時可能會出現明顯的性能問題。

  MapServer實際上也可以使用gdal生成輸出圖像,但這是另一個主題。如果您想了解更多信息,請查看mapfile引用中的outputformat對象。

二、創建站點Example1.5 Adding a? raster layer

  1.文件準備

    在cmd中輸入:cd /d?E:\SvnWorkspace\LY_WEB_GIS\branches\Documents\ms4w-mapserver-for-wimdows\release-1911-x64-gdal-2-3-3-mapserver-7-2-1\apps

    在cmd中輸入:md Example1.5

    在cmd中輸入:cd?Example1.5

    在cmd中輸入:md data

    在cmd中輸入:md logs

    在cmd中輸入:md fonts

    在cmd中輸入:md symbols

    在cmd中輸入:cd.>web.config

    在cmd中輸入:cd.>example1_5.map

    在cmd中輸入:cd data

    在cmd中輸入:md?raster

    修改web.config的內容如下

<?xml version="1.0" encoding="UTF-8"?> <configuration><system.webServer><handlers><add name="MapServerFastCgi" path="*" verb="*" type="" modules="FastCgiModule"
        scriptProcessor
="E:\SvnWorkspace\LY_WEB_GIS\branches\Documents\ms4w-mapserver-for-wimdows\release-1911-x64-gdal-2-3-3-mapserver-7-2-1\bin\mapserv.exe"
        resourceType
="Unspecified" requireAccess="Script" allowPathInfo="false" preCondition="" /></handlers><caching enabled="true" enableKernelCache="true" /></system.webServer> </configuration>

    將 app\tutorial\fonts 中的所有內容拷貝到 app\Example1.5\fonts 文件夾中(字體文件)

    將?app\tutorial\data 中的?states_ugl.dbf、states_ugl.shp、states_ugl.shx 拷貝到? app\Example1.5\data 文件夾中(數據文件)

    將?app\tutorial\symbols 中的?symbols35.sym 拷貝到?app\Example1.5\symbols 文件夾中(符號文件)

    將?app\tutorial\data\raster 中的?mod09a12003161_ugl_ll_8bit.tif、mod09a12003161_ugl_ll_idxa.tif 拷貝到?app\Example1.5\data\raster 文件夾中(圖層數據文件)

  2.在IIS中創建站點Example1.5

    應用程序池名稱:Example1.5;站點端口:8015

  3.給應用程序池讀寫log文件夾權限

    在cmd中輸入:icacls "E:\SvnWorkspace\LY_WEB_GIS\branches\Documents\ms4w-mapserver-for-wimdows\release-1911-x64-gdal-2-3-3-mapserver-7-2-1\apps\Example1.5\logs" /grant "IIS AppPool\Example1.5":(OI)(CI)RW

  4.修改example1_5.map文件

# The annotated map file (sort of) # Created by Pericles S. Nacionales for the MapServer tutorial # 20050408 # # MapServer map file uses the pound sign (#) to denote the start of a line # comment--each line that needs to be commented has to be prepended with a "#". # # Map files begin with MAP keyword to signify the start of the map object. # Well, the entire map file is THE map object. Enclosed between MAP and END # at the very bottom of this map file, are keyword/value pairs and other # objects. MAPIMAGETYPE PNGEXTENT -97.238976 41.619778 -82.122902 49.385620SIZE 400 300SHAPEPATH "./data"IMAGECOLOR 255 255 255FONTSET "./fonts/fonts.list"SYMBOLSET "./symbols/symbols35.sym"# Layer objects are defined beneath the map object. You need at least one# layer defined in your map file before you can display a map... You can# define as many layers as you'd like although a limit is typically hard-coded# in map.h in the MapServer source. The default limit is set at 100. You'd# have to have a very specialized application to need more than 100 layers in# your application.## Start of LAYER DEFINITIONS ---------------------------------------------LAYER # States polygon layer begins hereNAME statesDATA states_uglSTATUS OFFTYPE POLYGON# CLASSITEM defines the non-spatial attribute that you will be using to# separate a layer into classes. This attribute will be in the DBF file# of your shapefile (it will be different for each data format). In this# example the shapefile states_ugl has an associated database# (states_ugl.dbf) that contains an attribute called "CLASS". You will be# using two values in the CLASS attribute to separate the classes (also# called themes) used in this layer--land and water. CLASSITEM is used in# association with the EXPRESSION parameter in the CLASS object. See below.CLASSITEM "CLASS"# The class object is defined within the layer object. You can define as# many classes as you need (well, there are limits as with layers, but it's# senseless to define more than ten on a "normal" layer. There are# situations, however, where you might have to do it.)CLASSNAME 'States'EXPRESSION 'land'# There are styles in a class, just like there are classes in a layer,# just like there are layers in a map. You can define multiple styles in# a class just as you can define multiple classes in a layer and multiple# layers in a map.STYLECOLOR 232 232 232ENDENDEND # States polygon layer ends here# In addition to vector data (shapefiles are vector data), MapServer supports# a host of raster formats. In GIS world, one of the most common raster# formats is GeoTIFF, a TIFF image with geospatial headers. MapServer also# supports JPEG, PNG, GIF, and other common formats. Other raster formats# supported by MapServer include ESRI Arc/Info grid, HDF and HDF-EOS, NetCDF,# Generic raster binaries, OGC Web Map Service (WMS) layers, etc. Pretty much# any raster format you can think of is probably supported, thanks to the# impressive Geospatial Data Abstraction Library (GDAL, pronounced "GOODALL"# or GOODLE?). More information on GDAL is available at http://www.gdal.org.## MapServer 4.x can read and display bitmapped (like GIFs), RGB/A (true# color), and multispectral (images with more than 3 bands, like raw LandSat# images) rasters.LAYER # MODIS raster layer begins hereNAME modisDATA "raster/mod09a12003161_ugl_ll_8bit.tif"STATUS OFFTYPE RASTERPROCESSING "BANDS=1,2,3"OFFSITE 71 74 65END # MODIS raster layer ends hereLAYER # States line layer begins hereNAME states_lineDATA states_uglSTATUS OFFTYPE LINECLASSITEM "CLASS"CLASSNAME 'State Boundary'EXPRESSION 'land'STYLESYMBOL 'line5'COLOR 64 64 64SIZE 1ENDENDEND # States line layer ends here# Labels can be defined in its own layer. This is useful if, say, you want# to label a polygon layer that's covered by another layer. By keeping the# label separate from the polygon and placing it near the bottom of the map# file (so its drawn on, or near the, top), you can still see the label even# though you might not be able to see the polygon. It is also a good# alternate to point symbols.## A label layer is actually defined with ANNOTATION type (This is derived from# points, Node IDs for lines, or polygon IDs).LAYER # States label layer begins hereNAME states_labelDATA states_uglSTATUS OFFTYPE POLYGON #ANNOTATION 此類型的LAYER已經被移除。此處需要表達的是標簽,請查看上一章《MapServer Tutorial——MapServer7.2.1教程學習——第一節用例實踐:Example 1.4 Labeling the Map》
                     #LAYER 官網:https://www.mapserver.org/mapfile/layer.html ,定位到 TYPE 對象處查看。CLASSITEM "CLASS"# Just like CLASSITEM, LABELITEM defines the database attribute that you# will be using to draw labels. In this case, the values of the attribute# "STATE" will be used to label the states polygons.LABELITEM "STATE"CLASSEXPRESSION 'land'STYLECOLOR -1 -1 -1END# There can be labels in a class, just like there are classes in a layer,# just like there are layers in a map. You can define multiple labels in# a class just as you can define multiple classes in a layer and multiple# layers in a map.# MapServer has a very flexible labeling system. With that flexibility# comes complexity, specially when using truetype fonts. Please read# through the LABEL section of the MapServer map file documentation at# http://www.mapserver.org/mapfile for more information.LABELCOLOR 132 31 31#SHADOWCOLOR 218 218 218 # deprecated, use STYLE and GEOMTRANSFORM#SHADOWSIZE 2 2 # deprecated, use STYLE and GEOMTRANSFORMTYPE TRUETYPEFONT arial-boldSIZE 12ANTIALIAS TRUEPOSITION CLPARTIALS FALSEMINDISTANCE 300BUFFER 4END # end of labelEND # end of classEND # States label layer ends here# End of LAYER DEFINITIONS -------------------------------DEBUG 5CONFIG "MS_ERRORFILE" "logs\ms.log" END # All map files must come to an end just as all other things must come to...

?

?  5.瀏覽查看

    在瀏覽器中輸入:http://localhost:8015/mapserv?map=../apps/Example1.5/example1_5.map&layer=states&layer=modis&layer=states_line&layer=states_label&mode=map

    

三、MapFile文件解析

  1.文件結構

MAPLAYER #1-------------LAYER #2----|----LAYER #3--------LAYER #4(states) (modis) (states_line) (states_label)| | | (land) CLASS-|-CLASS (water) |-CLASS |-CLASS| | | |STYLE-| |-STYLE |-STYLE STYLE-|-LABEL

?    當前案例分為四個圖層:

      • tsates用來展示幾何區域
      • modis展示tiff圖像文件,柵格數據
      • states_line展示的是CLASSITEM=CLASS,EXPRESSION=land 的線條數據,其中線條符號為 line5?
# 12 Symbol NAME 'line5' Type VECTOR TRANSPARENT 0 Points 1 0 0 1 0 1 1 0 END END

#line的數據類型為 VECTOR 矢量數據,詳情請看:https://www.mapserver.org/mapfile/symbology/construction.html中 Symbols of TYPE vector and ellipse
#同時,請查看:https://www.mapserver.org/mapfile/symbol.html
#此處可以理解為構建了一個矢量區域,有個坐標系,點(1,0)、(0,1)、(0,1)、(1,0)畫了一個矩形,然而此矩形看起來沒有寬度,長為 2 的開方(三角形勾股定理)
#同時,將這個矢量矩形(看起來就是短的線)中心基于 dbf 數據中 CLASS = land 的 POLYGON 中的點數據來展示,這樣看起來就給 land 外面畫了一個線。

  2.對象參數解釋

    IMAGETYPE

      MapServer生成輸出數據的格式。在cmd中輸入:mapserv -v 查看。值PNG是值輸出24位PNG或真色PNG。

    SYMBOLSET

      SYMBOL集合的文件位置。可以使絕對路徑,也可以是和mapfile(example1_5.map)的相對路徑。字符集位置。可以先了解一下SYMBOL,資料如下:

      SYMBOL的講解:https://www.mapserver.org/mapfile/symbol.html

      創建字符集文件:https://www.mapserver.org/mapfile/symbology/construction.html

    DATA raster/mod09a12003161_ugl_ll_8bit.tif

      在NAME為modis的圖層中,添加的是一個GeoTIFF圖層數據。MapServer支持矢量數據和柵格數據。這個圖層為柵格類型。這個圖層是通過GDAL的庫來完成支持的。MapSeerver上不同的柵格支持和生成請查看:https://www.mapserver.org/input/raster.html#raster

      modis數據了解請進:https://modis.gsfc.nasa.gov/

    TYPE RASTER

      在NAME為modis的圖層中,當前LAYER的數據類型。此處使用的是RASTER。同時在LAYER中,MapServer還支持POLYGON,LINE,POINT,LABEL中支持ANNOTATION等。

    PROCESSING "BANDS=1,2,3"

      這個位置我覺得很難理解。查了相關資料。大概意思是,MapServer調用GDAL庫來處理tiff圖像,并輸出顯示。

      PROCESSING表示進程。根據進程值來決定調用那個庫。請查看:https://www.mapserver.org/mapfile/layer.html?中PROCESSING 段落。

      BANDS表示波段,GDAL源碼中通過RasterIO來讀取波段數據。

      TIFF文件時位圖,在windows中的存儲格式為BGR,然后MapServer根據參數調用時,對參數做了調整順序的相關處理。1,2,3表示Red,Green和blue三種波段選擇。

      具體的我也不大清楚,總之嘗試后,發現1,2,3在瀏覽器中顯示的是和直接看到tiff相差不遠,只是灰色的底色變成白色的。

      同時也請查看:https://www.mapserver.org/input/raster.html?中?BANDS=red_or_grey[,green,blue[,alpha]] 處的解釋。

    OFFSITE

      設置當前LAYER層的背景顏值組成。(Sets the color index to treat as transparent for raster layers.)

      告訴MapServer按照像素值渲染背景(或忽略)。

      想了半天沒弄懂,最后亂改這個值也沒發現什么。知道讀到or ignore之后。忽略,這個tif文件正好背景顏色值RGB是:71 74 65 ,是否設置OFFSITE值和背景顏色值一樣時,做忽略處理。

      但是在設置為其他顏色值時,卻還是顯示當前tif文件的背景顏色。這就十分尷尬了,是否是因為當前tif文件有背景顏色,然后將OFFSITE設置的顏色給覆蓋了。

      顏色組成分多種形式,當前案例是:Indexed Color Image(偽彩色圖像)。還有:RGB、RGBA等。

四、RGB vs Indexed Color Image 真彩色和偽彩色的對比

  1.關于偽彩色,可以查看:https://en.wikipedia.org/wiki/Indexed_color

  2.修改mapfile的相關配置,將

DATA "raster/mod09a12003161_ugl_ll_8bit.tif" STATUS DEFAULT TYPE RASTER PROCESSING "BANDS=1,2,3" OFFSITE 71 74 65

?  修改為

DATA "raster/mod09a12003161_ugl_ll_idxa.tif" STATUS DEFAULT TYPE RASTER OFFSITE 70 74 66

  看看效果

  顯示的效果已經改變。去掉GDAL的程序處理后,也不顯示背景色了。

五、后記

  感覺模擬樣例做一個很簡單,但是弄清楚相關的mapfile對象卻很頭痛,涉及的知識點太多,不理解的位置太多。比如:OFFSITE就不動。繼續深入學習,相信隨著了解的越來越多,就會知道其作用。

轉載于:https://www.cnblogs.com/eshinex/p/10291336.html

總結

以上是生活随笔為你收集整理的MapServer Tutorial——MapServer7.2.1教程学习——第一节用例实践:Example1.5 Adding a raster layer...的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 中文字幕永久在线观看 | 青青草日本 | 国产精品电影在线观看 | 成人av网站在线 | 久久福利在线 | 亚洲国产精彩视频 | 狠狠爱成人 | 中国在线观看视频高清免费 | 污污视频网站免费观看 | 一本色道久久综合亚洲精品图片 | 国产视频xxx | www.第四色 | 中文字幕www | 国产情侣一区 | 三级av毛片 | 在线观看亚洲区 | 五月网| 成人a毛片久久免费播放 | 中文字幕中文在线 | 欧美一区二区日韩 | 久久久久人妻一区精品 | 成人精品视频一区二区三区尤物 | 久久久视频6r | 91原创国产| 亚洲深夜| 久久久国产精品黄毛片 | 一区二区三区偷拍 | 日韩在线小视频 | 欧美视频一二三区 | 精品国产一区三区 | 日韩精品视频网站 | 亚洲成人不卡 | 亚洲区成人 | 91性| 制服丝袜手机在线 | 日韩精品一区二区三区中文字幕 | 三a大片| 中文字字幕在线中文乱码电影 | 国产不卡在线播放 | 青娱乐在线免费视频 | 日韩诱惑| 国产青青草在线 | 国产高潮又爽又无遮挡又免费 | 91禁外国网站| 欧美一级少妇 | 国产l精品国产亚洲区久久 午夜青青草 | 日韩人妻无码精品久久免费 | 亚洲综合色站 | 青青青手机视频在线观看 | 国产精品久久精品三级 | 丁香婷婷综合网 | 日日天天干 | 99久久久国产精品免费蜜臀 | 亚洲黄色一区 | 亚洲系列在线 | 一区二区美女 | 超碰加勒比 | 亚洲久久久久 | 在线黄视频| 中文字幕在线观看欧美 | 久精品视频 | 亚洲三级在线观看 | 修女也疯狂3免费观看完整版 | 国产69精品久久久久久久 | 久久无码视频一区 | 日本黄色www| 免费精品视频一区二区三区 | 中文在线视频 | 成人污污视频在线观看 | 国产真实偷伦视频 | 极品久久| 青青在线观看视频 | 久久精品国产一区二区三区 | 成人高潮片免费网站 | 亚洲最大成人网色 | 亚洲无吗在线观看 | 中国女人内精69xxxxxx | 国产99久久九九精品无码 | 四川少妇xxx奶大xxx | av国产在线观看 | 被两个男人吃奶三p爽文 | 91小仙女jk白丝袜呻吟 | 最新中文字幕在线观看视频 | 成人免费视频国产在线观看 | 亚洲黄在线 | 美女少妇直播 | 99精品视频在线看 | 精品一卡二卡三卡 | 国产精品腿扒开做爽爽爽挤奶网站 | 91精品婷婷国产综合久久蝌蚪 | 九九精品免费视频 | 99久久影院 | 色偷偷噜噜噜亚洲男人的天堂 | 久久九九热 | 国产91av在线播放 | 日韩一级片免费在线观看 | 激情视频免费观看 | 可以免费看的黄色 | 日本a在线观看 |