「Plugins mapserver export」の版間の差分

提供: OSGeo.JP Wiki
移動: 案内検索
(タグ・画像調整前に一旦配下を統合)
(MapServer Export Plugin)
 
(同じ利用者による、間の1版が非表示)
行1: 行1:
<H2>
+
=== MapServer Export Plugin ===
MapServer Export Plugin
+
<span id='sec:mapserver_export'></span>
</H2>
+
  
<P>
+
You can use QGIS to "compose" your map by adding and arranging layers,  
You can use QGIS to ``compose'' your map by adding and arranging layers,  
+
 
symbolizing them, customizing the colors and then creating a map file  
 
symbolizing them, customizing the colors and then creating a map file  
 
for MapServer.
 
for MapServer.
  
<P>
+
==== Creating the Project File ====
<BR><HR>
+
<!--Table of Child-Links-->
+
<STRONG>Subsections</STRONG>
+
  
<UL CLASS="ChildLinks">
 
<LI>[[Creating the Project File]]
 
<LI>[[Creating the Map File]]
 
<LI>[[Testing the Map File]]
 
</UL>
 
<!--End of Table of Child-Links-->
 
<BR><HR>
 
 
<H3>
 
Creating the Project File
 
</H3>
 
 
<P>
 
 
The MapServer Export Plugin operates on a saved QGIS project file and  
 
The MapServer Export Plugin operates on a saved QGIS project file and  
<SPAN  CLASS="textbf">not</SPAN> on the current contents of the map canvas and legend. This  
+
'''not''' on the current contents of the map canvas and legend. This  
 
has been a source of confusion for a number of users. As described below,  
 
has been a source of confusion for a number of users. As described below,  
 
before you start using the MapServer Export Plugin, you need to arrange  
 
before you start using the MapServer Export Plugin, you need to arrange  
行33: 行15:
 
status in a QGIS project file.
 
status in a QGIS project file.
  
<P>
+
<table align='center'>
 +
<caption>'''図 56:''' Arrange raster and vector layers for QGIS project file {{Template:Nix}}</caption>
 +
<tr><td>
 +
<span id='fig:mapserver_export_qgs'></span>
 +
  [[File:mapserver_export_qgis.png|454px]]</td></tr></table>
  
<DIV ALIGN="CENTER"><A NAME="fig:mapserver_export_qgs"></A><A NAME="7"></A>
 
<TABLE>
 
<CAPTION ALIGN="BOTTOM"><STRONG>Figure:</STRONG>
 
Arrange raster and vector layers for QGIS project file </CAPTION>
 
<TR><TD>
 
<DIV ALIGN="CENTER">
 
</DIV>
 
<P></P>
 
<DIV ALIGN="CENTER">  [clip=true, width=12cm]mapserver_export_qgis
 
 
</DIV></TD></TR>
 
</TABLE>
 
</DIV>
 
 
<P>
 
 
In this example, we demonstrate the four steps required to create a simple  
 
In this example, we demonstrate the four steps required to create a simple  
 
project file which can be used to create the MapServer map file.  
 
project file which can be used to create the MapServer map file.  
We use raster and vector files from the QGIS sample dataset [[#label_sampledata]].
+
We use raster and vector files from the QGIS sample dataset [[label_sampledata]].
  
<P>
+
<ol>
 +
<li>Add the raster layer {{Template:FileName|landcover.tif}} clicking on the
 +
{{Template:ToolBtnTwo|mActionAddRasterLayer|Add Raster Layer}} icon.
 +
<li>Add the vector Shapefiles {{Template:FileName|lakes.shp, majrivers.shp}} and
 +
{{Template:FileName|airports.shp}} from the QGIS sample dataset clicking on the
 +
{{Template:ToolBtnTwo|mActionAddNonDbLayer|Add Vector Layer}} icon.
 +
<li>Change the colors and symbolize the data as you like (For example see
 +
Figure [[#fig:mapserver_export_qgis|57]])
 +
<li>Save a new project named {{Template:FileName|mapserverproject.qgs}} using
 +
{{Template:MainMenuOpt|File}} > {{Template:DropMenuOptTwo|mActionFileSave|Save Project}}.
 +
</ol>  
  
<OL>
+
==== Creating the Map File ====
<LI>Add the raster layer landcover.tif clicking on the
+
mActionAddRasterLayerAdd Raster Layer icon.
+
</LI>
+
<LI>Add the vector Shapefiles lakes.shp, majrivers.shp and
+
airports.shp from the QGIS sample dataset clicking on the
+
mActionAddNonDbLayerAdd Vector Layer icon.
+
</LI>
+
<LI>Change the colors and symbolize the data as you like (For example see
+
Figure&nbsp;[[#fig:mapserver_export_qgis]])
+
</LI>
+
<LI>Save a new project named mapserverproject.qgs using
+
File &gt; mActionFileSaveSave Project.
+
</LI>
+
</OL>
+
  
<P>
+
The tool {{Template:FileName|msexport}} to export a QGIS project file to a MapServer map  
 
+
 
+
<H3>
+
Creating the Map File
+
</H3>
+
 
+
<P>
+
The tool msexport to export a QGIS project file to a MapServer map  
+
 
file is installed in your QGIS binary directory and can be used independently of QGIS.  
 
file is installed in your QGIS binary directory and can be used independently of QGIS.  
To use it from within QGIS, you need to enable the MapServer Export Plugin first using the Plugin Manager (see Section [[#sec:load_core_plugin]]).
+
To use it from within QGIS, you need to enable the MapServer Export Plugin first using the Plugin Manager (see Section [[sec:load_core_plugin]]).
 
+
<P>
+
 
+
<DIV ALIGN="CENTER"><A NAME="fig:mapserver_export_dialog"></A><A NAME="32"></A>
+
<TABLE>
+
<CAPTION ALIGN="BOTTOM"><STRONG>Figure:</STRONG>
+
Export to MapServer Dialog </CAPTION>
+
<TR><TD>
+
<DIV ALIGN="CENTER">
+
</DIV>
+
<P></P>
+
<DIV ALIGN="CENTER">  [clip=true, width=9cm]mapserver_export_dialog
+
  
</DIV></TD></TR>
+
<table align='center'>
</TABLE>
+
<caption>'''図 57:''' Export to MapServer Dialog {{Template:Nix}}</caption>
</DIV>
+
<tr><td>
 +
<span id='fig:mapserver_export_dialog'></span>
 +
  [[File:mapserver_export_dialog.png|340px]]</td></tr></table>
  
<P>
+
<dl>
<DL>
+
<dt>Map file<dd>Enter the name for the map file to be created. You can use the button at the right to browse for the directory where you want the map file created.  
<DT><STRONG>Map file</STRONG></DT>
+
<dt>Qgis project file<dd>Enter the full path to the QGIS project file (.qgs) you want to export. You can use the button at the right to browse for the QGIS project file.
<DD>
+
<dt>Map Name<dd>A name for the map. This name is prefixed to all images generated by the mapserver.
<BR>
+
<dt>Map Width<dd>Width of the output image in pixels.
Enter the name for the map file to be created. You can use the button at the  
+
<dt>Map Height<dd>Height of the output image in pixels.
right to browse for the directory where you want the map file created.  
+
<dt>Map Units<dd>Units of measure used for output
</DD>
+
<dt>Image type<dd>Format for the output image generated by MapServer
<DT><STRONG>Qgis project file</STRONG></DT>
+
<dt>Web Template<dd>Full path to the MapServer template file to be used with the map file
<DD>
+
<dt>Web Header<dd>Full path to the MapServer header file to be used with the map file
<BR>
+
<dt>Web Footer<dd>Full path to the MapServer footer file to be used with the map file
Enter the full path to the QGIS project file (.qgs) you want to export. You can  
+
</dl>
use the button at the right to browse for the QGIS project file.
+
</DD>
+
<DT><STRONG>Map Name</STRONG></DT>
+
<DD>
+
<BR>
+
A name for the map. This name is prefixed to all images generated by the mapserver.
+
</DD>
+
<DT><STRONG>Map Width</STRONG></DT>
+
<DD>
+
<BR>
+
Width of the output image in pixels.
+
</DD>
+
<DT><STRONG>Map Height</STRONG></DT>
+
<DD>
+
<BR>
+
Height of the output image in pixels.
+
</DD>
+
<DT><STRONG>Map Units</STRONG></DT>
+
<DD>
+
<BR>
+
Units of measure used for output
+
</DD>
+
<DT><STRONG>Image type</STRONG></DT>
+
<DD>
+
<BR>
+
Format for the output image generated by MapServer
+
</DD>
+
<DT><STRONG>Web Template</STRONG></DT>
+
<DD>
+
<BR>
+
Full path to the MapServer template file to be used with the map file
+
</DD>
+
<DT><STRONG>Web Header</STRONG></DT>
+
<DD>
+
<BR>
+
Full path to the MapServer header file to be used with the map file
+
</DD>
+
<DT><STRONG>Web Footer</STRONG></DT>
+
<DD>
+
<BR>
+
Full path to the MapServer footer file to be used with the map file
+
</DD>
+
</DL>
+
  
<P>
+
Only the {{Template:FileName|Map file}} and {{Template:FileName|QGIS project file}} inputs are  
Only the Map file and QGIS project file inputs are  
+
 
required to create a map file, however by omitting the other parameters,  
 
required to create a map file, however by omitting the other parameters,  
 
you may end up creating a non-functional map file, depending on your intended use.  
 
you may end up creating a non-functional map file, depending on your intended use.  
行163: 行68:
 
it may require some tweaking to get the results you want.  
 
it may require some tweaking to get the results you want.  
 
For this example, we will create a map file using the project file  
 
For this example, we will create a map file using the project file  
mapserverproject.qgs we just created  
+
{{Template:FileName|mapserverproject.qgs}} we just created  
(see Figure&nbsp;[[#fig:mapserver_export_dialog|59]]):
+
(see Figure [[#fig:mapserver_export_dialog|57]]):
  
<P>
+
<ol>
 
+
  <li> Start the MapServer dialog (see  
<OL>
+
Figure [[#fig:mapserver_export_dialog|57]]) by clicking the {{Template:ToolBtnTwo|mapserver_export|MapServer Export}} icon in the toolbar menu.
<LI>Start the MapServer dialog (see  
+
  <li>Enter the name (e.g., {{Template:FileName|qgisproject.map}}) for your new map file.
Figure [[#fig:mapserver_export_dialog|59]]) by clicking the mapserver_exportMapServer Export icon in the toolbar menu.
+
  <li>Browse and find the QGIS project file (e.g., {{Template:FileName|mapserverproject.qgs}})  
</LI>
+
<LI>Enter the name (e.g., qgisproject.map) for your new map file.
+
</LI>
+
<LI>Browse and find the QGIS project file (e.g., mapserverproject.qgs)  
+
 
   you previously saved.
 
   you previously saved.
</LI>
+
  <li>Enter a name (e.g., {{Template:FileName|MyMap}}) for the map.
<LI>Enter a name (e.g., MyMap) for the map.
+
  <li>Enter the width and height (e.g., {{Template:FileName|600}} for the width and {{Template:FileName|400}} for the height) for your output image.
</LI>
+
  <li>For this example, the layers are in meters, so we change the units to meters.
<LI>Enter the width and height (e.g., 600 for the width and 400 for the height) for your output image.
+
  <li>Choose ``png'' for the image type.
</LI>
+
  <li>Click {{Template:Button|OK}} to generate the new map file {{Template:FileName|qgisproject.map}}.  
<LI>For this example, the layers are in meters, so we change the units to meters.
+
</LI>
+
<LI>Choose ``png'' for the image type.
+
</LI>
+
<LI>Click OK to generate the new map file qgisproject.map.  
+
 
   QGIS displays the success of your efforts.
 
   QGIS displays the success of your efforts.
</LI>
+
</ol>
</OL>
+
  
<P>
 
 
You can view the map file in any text editor or visualizer. If you
 
You can view the map file in any text editor or visualizer. If you
 
take a look, you'll notice that the export tool adds the metadata needed
 
take a look, you'll notice that the export tool adds the metadata needed
 
to enable our map file for WMS.  
 
to enable our map file for WMS.  
  
<P>
+
==== Testing the Map File ====
  
 
+
We can now test our work using the {{Template:FileName|shp2img}} tool to create an image
<H3>
+
from the map file. The {{Template:FileName|shp2img}} utility is part of MapServer and FWTools.  
Testing the Map File
+
</H3>
+
 
+
<P>
+
We can now test our work using the shp2img tool to create an image
+
from the map file. The shp2img utility is part of MapServer and FWTools.  
+
 
To create an image from our map:
 
To create an image from our map:
  
<P>
+
<ul>
 
+
<li>Open a terminal window
<UL>
+
<li>If you didn't save your map file in your home directory, change to
<LI>Open a terminal window
+
</LI>
+
<LI>If you didn't save your map file in your home directory, change to
+
 
   the folder where you saved it.
 
   the folder where you saved it.
</LI>
+
<li>Run {{Template:FileName|shp2img -m qgisproject.map -o mapserver_test.png}} and  
<LI>Run shp2img -m qgisproject.map -o mapserver_test.png and  
+
 
   display the image  
 
   display the image  
</LI>
+
</ul>
</UL>
+
 
+
<P>
+
 
This creates a PNG with all the layers included in the QGIS project file.  
 
This creates a PNG with all the layers included in the QGIS project file.  
 
In addition, the extent of the PNG will be the same as when we saved the  
 
In addition, the extent of the PNG will be the same as when we saved the  
project. As you can see in Figure&nbsp;<A HREF="#fig:mapserver_export_test">60</A>, all  
+
project. As you can see in Figure [[#fig:mapserver_export_test|58]], all  
 
information except the airport symbols are included.
 
information except the airport symbols are included.
  
<P>
+
<table align='center'>
 
+
<caption>'''図 58:''' Test PNG created by shp2img with all MapServer Export layers {{Template:Nix}}</caption>
<DIV ALIGN="CENTER"><A NAME="fig:mapserver_export_test"></A><A NAME="74"></A>
+
<tr><td>
<TABLE>
+
<span id='fig:mapserver_export_test'></span>
<CAPTION ALIGN="BOTTOM"><STRONG>Figure:</STRONG>
+
  [[File:mapserver_export_test.png|454px]]</td></tr></table>
Test PNG created by shp2img with all MapServer Export layers </CAPTION>
+
<TR><TD>
+
<DIV ALIGN="CENTER">
+
</DIV>
+
<P></P>
+
<DIV ALIGN="CENTER">  [clip=true, width=12cm]mapserver_export_test
+
 
+
</DIV></TD></TR>
+
</TABLE>
+
</DIV>
+
  
<P>
 
 
If you plan to use the map file to serve WMS requests, you probably don't
 
If you plan to use the map file to serve WMS requests, you probably don't
 
have to tweak anything. If you plan to use it with a mapping template or a
 
have to tweak anything. If you plan to use it with a mapping template or a
行248: 行119:
 
it is to go from QGIS to serving maps on the web, take a look at
 
it is to go from QGIS to serving maps on the web, take a look at
 
Christopher Schmidt's 5 minute flash video. He used an older version of QGIS (version 0.8), but the demo applies equally well to newer versions.
 
Christopher Schmidt's 5 minute flash video. He used an older version of QGIS (version 0.8), but the demo applies equally well to newer versions.
 +
<ref>{{Template:URL|http://openlayers.org/presentations/mappingyourdata/}}</ref>
 +
 +
----
 +
<references/>

2009年10月5日 (月) 23:06時点における最新版

MapServer Export Plugin

You can use QGIS to "compose" your map by adding and arranging layers, symbolizing them, customizing the colors and then creating a map file for MapServer.

Creating the Project File

The MapServer Export Plugin operates on a saved QGIS project file and not on the current contents of the map canvas and legend. This has been a source of confusion for a number of users. As described below, before you start using the MapServer Export Plugin, you need to arrange the raster and vector layers you want to use in MapServer and save this status in a QGIS project file.

図 56: Arrange raster and vector layers for QGIS project file Nix.png

Mapserver export qgis.png

In this example, we demonstrate the four steps required to create a simple project file which can be used to create the MapServer map file. We use raster and vector files from the QGIS sample dataset label_sampledata.

  1. Add the raster layer landcover.tif clicking on the MActionAddRasterLayer.png Add Raster Layer icon.
  2. Add the vector Shapefiles lakes.shp, majrivers.shp and airports.shp from the QGIS sample dataset clicking on the MActionAddNonDbLayer.png Add Vector Layer icon.
  3. Change the colors and symbolize the data as you like (For example see Figure 57)
  4. Save a new project named mapserverproject.qgs using File > MActionFileSave.png Save Project.

Creating the Map File

The tool msexport to export a QGIS project file to a MapServer map file is installed in your QGIS binary directory and can be used independently of QGIS. To use it from within QGIS, you need to enable the MapServer Export Plugin first using the Plugin Manager (see Section sec:load_core_plugin).

図 57: Export to MapServer Dialog Nix.png

Mapserver export dialog.png
Map file
Enter the name for the map file to be created. You can use the button at the right to browse for the directory where you want the map file created.
Qgis project file
Enter the full path to the QGIS project file (.qgs) you want to export. You can use the button at the right to browse for the QGIS project file.
Map Name
A name for the map. This name is prefixed to all images generated by the mapserver.
Map Width
Width of the output image in pixels.
Map Height
Height of the output image in pixels.
Map Units
Units of measure used for output
Image type
Format for the output image generated by MapServer
Web Template
Full path to the MapServer template file to be used with the map file
Web Header
Full path to the MapServer header file to be used with the map file
Web Footer
Full path to the MapServer footer file to be used with the map file

Only the Map file and QGIS project file inputs are required to create a map file, however by omitting the other parameters, you may end up creating a non-functional map file, depending on your intended use. Although QGIS is good at creating a map file from your project file, it may require some tweaking to get the results you want. For this example, we will create a map file using the project file mapserverproject.qgs we just created (see Figure 57):

  1. Start the MapServer dialog (see Figure 57) by clicking the Mapserver export.png MapServer Export icon in the toolbar menu.
  2. Enter the name (e.g., qgisproject.map) for your new map file.
  3. Browse and find the QGIS project file (e.g., mapserverproject.qgs) you previously saved.
  4. Enter a name (e.g., MyMap) for the map.
  5. Enter the width and height (e.g., 600 for the width and 400 for the height) for your output image.
  6. For this example, the layers are in meters, so we change the units to meters.
  7. Choose ``png for the image type.
  8. Click OK to generate the new map file qgisproject.map. QGIS displays the success of your efforts.

You can view the map file in any text editor or visualizer. If you take a look, you'll notice that the export tool adds the metadata needed to enable our map file for WMS.

Testing the Map File

We can now test our work using the shp2img tool to create an image from the map file. The shp2img utility is part of MapServer and FWTools. To create an image from our map:

  • Open a terminal window
  • If you didn't save your map file in your home directory, change to the folder where you saved it.
  • Run shp2img -m qgisproject.map -o mapserver_test.png and display the image

This creates a PNG with all the layers included in the QGIS project file. In addition, the extent of the PNG will be the same as when we saved the project. As you can see in Figure 58, all information except the airport symbols are included.

図 58: Test PNG created by shp2img with all MapServer Export layers Nix.png

Mapserver export test.png

If you plan to use the map file to serve WMS requests, you probably don't have to tweak anything. If you plan to use it with a mapping template or a custom interface, you may have a bit of manual work to do. To see how easy it is to go from QGIS to serving maps on the web, take a look at Christopher Schmidt's 5 minute flash video. He used an older version of QGIS (version 0.8), but the demo applies equally well to newer versions. <ref>http://openlayers.org/presentations/mappingyourdata/ </ref>


<references/>