GRASS and MapServer: Difference between revisions

From GRASS-Wiki
Jump to navigation Jump to search
No edit summary
mNo edit summary
 
Line 54: 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 How to set up MapServer with GRASS GIS support]
* [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:Documentation]]
[[Category:Web Servers]]
[[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