GRASS and MapServer: Difference between revisions

From GRASS-Wiki
Jump to navigation Jump to search
mNo edit summary
 
(11 intermediate revisions by 7 users not shown)
Line 5: Line 5:
==Raster Maps==
==Raster Maps==


A shor example of a layer definition to access a GRASS raster:
A short example of a layer definition to access a GRASS raster:


<pre>
<pre>
Line 20: Line 20:
Notes:
Notes:


* The rasters are limited to values form 0 to 255, the values over this are interpreted as 255. Rescale (<code>r.rescale</code>) your maps when necessary.
* The rasters are limited to values from 0 to 255, the values over this are interpreted as 255. Rescale (<code>r.rescale</code>) your maps when necessary.
* You really need to have a CLASS in your layer, otherwise no data will be shown. An empty class is quite fine to show the whole map.
* You really need to have a CLASS in your layer, otherwise no data will be shown. An empty class is quite fine to show the whole map.
See the [[Color tables]] wiki page for more on exporting raster color tables as SLD XML rules using the {{AddonCmd|r.colors.out_sld}} addon script.


==Vector Maps==
==Vector Maps==
Line 46: Line 49:
* You need to have GDAL with OGR and GRASS support for this to work. Note, that in this [http://grass.itc.it/start.html example] the maps are first exported to shapefiles. This is no longer necessary, as the maps can be accessed directly with OGR.
* You need to have GDAL with OGR and GRASS support for this to work. Note, that in this [http://grass.itc.it/start.html example] the maps are first exported to shapefiles. This is no longer necessary, as the maps can be accessed directly with OGR.
* Usually GRASS layers have no names and the layer number is used in DATA. However, it is possible that they do have names. This can happen for example when importing files with v.in.dxf, as the module keeps the dxf-file layer names and stores them into the GRASS vector. The layer names, if such there are, can be found in <tt>/path/to/grassdb/mapset/location/vector/vectorname/dbln</tt>, or with <code>ogrinfo -ro /path/to/grassdb/mapset/location/vector/vectorname/dbln</code>. Why this is so important is because if there are layer names defined, these layers cannot be accessed through the layer number with OGR. They ''have'' to be accessed through the layer name.
* Usually GRASS layers have no names and the layer number is used in DATA. However, it is possible that they do have names. This can happen for example when importing files with v.in.dxf, as the module keeps the dxf-file layer names and stores them into the GRASS vector. The layer names, if such there are, can be found in <tt>/path/to/grassdb/mapset/location/vector/vectorname/dbln</tt>, or with <code>ogrinfo -ro /path/to/grassdb/mapset/location/vector/vectorname/dbln</code>. Why this is so important is because if there are layer names defined, these layers cannot be accessed through the layer number with OGR. They ''have'' to be accessed through the layer name.
* we have trouble using data associated with vectors: http://mapserver.gis.umn.edu/bugs/show_bug.cgi?id=1839 ; if someone succeed in this please let us know (--[[User:Cavallini|Cavallini]] 08:03, 6 November 2006 (CET) cavallini@faunalia.it)


==Examples and useful links==
==Examples and useful links==
Line 52: Line 54:
* [http://grass.itc.it/start.html Example] of GRASS with MapServer.
* [http://grass.itc.it/start.html Example] of GRASS with MapServer.
* [http://mapserver.gis.umn.edu UMN Mapserver homepage]
* [http://mapserver.gis.umn.edu UMN Mapserver homepage]
* [http://idea.isnew.info/how-to-set-up-mapserver-with-grass-gis-support.html How to set up MapServer with GRASS GIS support]
[[Category:Documentation]]
[[Category:Web Servers]]

Latest revision as of 20:42, 15 August 2016

GRASS maps from mapfiles

MapServer needs a mapfile containing the information, how to create the maps. Examples of these can be found, so here you'll find GRASS specific information.

Raster Maps

A short example of a layer definition to access a GRASS raster:

LAYER
  NAME "Example"
  TYPE RASTER
  STATUS ON
  DATA "/path/to/grassdb/location/mapset/cellhd/example"
  CLASS NAME "Example" # You need to have a class definition in the layer
  END
END

Notes:

  • The rasters are limited to values from 0 to 255, the values over this are interpreted as 255. Rescale (r.rescale) your maps when necessary.
  • You really need to have a CLASS in your layer, otherwise no data will be shown. An empty class is quite fine to show the whole map.


See the Color tables wiki page for more on exporting raster color tables as SLD XML rules using the r.colors.out_sld addon script.

Vector Maps

A short example of a layer definition to access a GRASS vector:

LAYER
  NAME "Example"
  TYPE LINE
  STATUS ON
  CONNECTIONTYPE OGR
  CONNECTION "/path/to/grassdb/mapset/location/vector/example/head"
  DATA "1" # Layer number
  CLASS # You need to have a class definition; otherwise nothing is shown on the map
    NAME "Example"
    COLOR 155 155 0
  END
END

Notes:

  • You need to have GDAL with OGR and GRASS support for this to work. Note, that in this example the maps are first exported to shapefiles. This is no longer necessary, as the maps can be accessed directly with OGR.
  • Usually GRASS layers have no names and the layer number is used in DATA. However, it is possible that they do have names. This can happen for example when importing files with v.in.dxf, as the module keeps the dxf-file layer names and stores them into the GRASS vector. The layer names, if such there are, can be found in /path/to/grassdb/mapset/location/vector/vectorname/dbln, or with ogrinfo -ro /path/to/grassdb/mapset/location/vector/vectorname/dbln. Why this is so important is because if there are layer names defined, these layers cannot be accessed through the layer number with OGR. They have to be accessed through the layer name.

Examples and useful links