GRASS and MapServer: Difference between revisions

From GRASS-Wiki
Jump to navigation Jump to search
Line 46: Line 46:
* 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==

Revision as of 12:43, 18 May 2007

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 shor 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 form 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.

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