Zoom help
Download data bundle
1.1 Server configuration
Installation of Geoserver
Server status
Log files: how to use them
Service configuration
Datum transformations
1.2 Publishing a shapefile
Structure of GEOSERVER_DATA_DIR
Uploading the files to publish
Creating workspaces, data stores, layers
1.3. Styling with SLD
Basic styling of a point layer
Basic styling of a line layer
Basic styling of a polygon layer
Online documentation on SLD
Advanced vectorial styling: filtering and labeling
CartoCSS: a lighter alternative
1.4 Publishing a PostGIS table
Uploading layers to PostGIS from QGIS
Creating a PostGIS data store
Benefits of PostGIS: indexes, functions, triggers
1.5 Publishing a raster layer
Preparing the raster files
File types: Monochromatic (binary), DEM, RGB
Raster symbolization: Color ramps
Publishing heavy raster data: mosaic, pyramid
2.1 Using WMS standard
Content of a GetCapabilities document
GetMap operation
Output formats and their uses
Consumption from QGIS and web
GetLegendGraphic, GetFeatureInfo
GeoServer-specific: CQL_FILTER
2.2 Using WFS standard
Content of a GetCapabilities document
DescribeFeatureType, GetFeature
Output formats and uses
2.3 Tile caching with GeoWebCache
Choosing the appropriate image formats
Defining a custom pyramid
Pre-generating and deleting tiles
Adding "dimensions" to a cache
2.4 Using cache standards (WMTS, WMS-C)
WMTS: GetCapabilities, GetTile
Concept of pyramid
“De facto” Google standard: TMS (or XYZ)
2.5 Getting the most of GeoServer
An Internet Map Server provides maps through the Internet usually as images (???). One standard specification for such a server is the OGC Web Map Service.
Wikipedia, 2006
Think free as in free speech, not free beer
R.Stallman
Free / Open source software
Being a community-driven project, GeoServer is developed, tested, and supported by a diverse group of individuals and organizations from around the world.
Designed for interoperability, it publishes data from any major spatial data source using open standards.
Jetty (development):
https://docs.geoserver.org/stable/en/user/installation/win_installer.html
Tomcat (production, WAR): https://docs.geoserver.org/stable/en/user/installation/war.html
docker pull oscarfonts/geoserver
docker run -d -p 8080:8080 -v /path/to/local/data_dir:/var/local/geoserver
oscarfonts/geoserverLoad balancing
N1
N2
N3
N4
Log in: http://localhost:8080/geoserver
admin/geoserver ? CHANGE IT!
The log file of an application is a text file where details about the execution of the file are stored. Thus, a log file keeps a history with the details of the operations carried out, with more or less detail. Generally, when an execution error occurs, check this file for details.
GEOSERVER_DATA_DIR/logging.xml
logs/geoserver.log
User Administration Interface
GeoServer serves data using standard protocols established by the Open Geospatial Consortium:
Connect to a WMS service (using QGIS)
https://neo.sci.gsfc.nasa.gov/wms/wms
or see the capabilities in browser:
https://neo.sci.gsfc.nasa.gov/wms/wms?version=1.3.0&service=WMS&request=GetCapabilities
Metadata is important for interoperability!
Metadata is important for interoperability!
If source and target CRSs are refered to a different datum, GeoServer will automatically transform the information. How?
Custom transformations: use the Reprojection Console
Given a CRS pair, GeoServer will automatically pick the most accurate datum transform from the EPSG database, unless a custom operation is declared
Standalone platform Default/typical location
| Windows (except XP) | C:\Program Files (x86)\GeoServer 2.16.x\data_dir |
| Windows XP | C:Program Files\GeoServer 2.16.x\data_dir |
| Mac OS X | /Applications/GeoServer.app/Contents/Resources/Java/data_dir |
| Linux (Tomcat) | /var/lib/tomcat7/webapps/geoserver/data |
Everything is stored in data directory. If:
=> PORTABILITY!
#uploading with SSH
scp local_file user@remote_host:remote_file
#example
scp /myfile.zip geoserver@geoserver.geomati.co:~/training/upload
#check permissions
ls -l
chmod 644 /tmp/myfile.zip
Workspace 1
Data Store A
Data Store B
Layer A1
Layer A2
Layer A3
Layer B1
Layer B2
Publish nyc_streets.shp (or your own shapefiles) to your local geoserver
http://localhost:8080/geoserver
Publish all vector data to your local geoserver
http://localhost:8080/geoserver
<FeatureTypeStyle>
<Rule>
<PointSymbolizer>
<Graphic>
<Mark>
<WellKnownName>circle</WellKnownName>
<Fill>
<CssParameter name="fill">#FF0000</CssParameter>
</Fill>
<Stroke>
<CssParameter name="stroke">#000000</CssParameter>
<CssParameter name="stroke-width">2</CssParameter>
</Stroke>
</Mark>
<Size>6</Size>
</Graphic>
</PointSymbolizer>
</Rule>
</FeatureTypeStyle><FeatureTypeStyle>
<Rule>
<LineSymbolizer>
<Stroke>
<CssParameter name="stroke">#FF0000</CssParameter>
<CssParameter name="stroke-width">3</CssParameter>
<CssParameter name="stroke-dasharray">5 2</CssParameter>
</Stroke>
</LineSymbolizer>
</Rule>
</FeatureTypeStyle><FeatureTypeStyle>
<Rule>
<PolygonSymbolizer>
<Fill>
<CssParameter name="fill">#000080</CssParameter>
</Fill>
<Stroke>
<CssParameter name="stroke">#FFFFFF</CssParameter>
<CssParameter name="stroke-width">2</CssParameter>
</Stroke>
</PolygonSymbolizer>
</Rule>
</FeatureTypeStyle>Style:
Style:
Style nyc_neighbourhoods, nyc_subway stations and nyc_streets:
A spatial database is a database that is optimized for storing and querying data that represents objects defined in a geometric space. Most spatial databases allow the representation of simple geometric objects such as points, lines and polygons. Some spatial databases handle more complex structures such as 3D objects, topological coverages, linear networks, and TINs. While typical databases have developed to manage various numeric and character types of data, such databases require additional functionality to process spatial data types efficiently, and developers have often added geometry or feature data types.
# TYPE DATABASE USER ADDRESS METHOD
local all postgres ident
local all all md5
#only localhost
host all all 127.0.0.1/32 md5
#everything open
host all all 0.0.0.0/32 md5
#open for a specific BD
host bd_abierta all 0.0.0.0/32 md5CREATE DATABASE nyc;
CREATE EXTENSION postgis;cd C:\Program Files\PostgreSQL \9.5\bin
shp2pgsql -I -s 26918 C:\Documents\postgis-workshop\data\roads.shp
roads | psql -U postgres -d <DBNAME>Get all subway stations less than 2kms from lon:-73.85 lat:40.75 in PostGIS
Hint: use ST_Distance or ST_Within
Show the stations on GeoServer
SELECT name
FROM nyc_subway_stations
WHERE ST_DWithin(
geom,
ST_Transform(ST_GeomFromText('POINT(-73.85 40.75)', 4326), 26918), 2000
);PostgreSQL trigger can be specified to fire
PostgreSQL Triggers are database callback functions, which are automatically performed/invoked when a specified database event occurs.
GDAL is a translator library for raster and vector geospatial data formats that is released under an X/MIT style Open Source License by the Open Source Geospatial Foundation.
cd /var/lib/tomcat8/webapps/geoserver/WEB-INF/lib/
sudo wget https://sourceforge.net/projects/geoserver/files/GeoServer/2.14.2/extensions/geoserver-2.14.2-gdal-plugin.zip
sudo unzip geoserver-2.14.2-gdal-plugin.zip
rm *.txt *.TXT *.zip
chown tomcat8:tomcat8 *.jarcd /usr/local/geoserver/
mkdir gdal
cd gdal
wget http://demo.geo-solutions.it/share/github/imageio-ext/releases/1.1.X/1.1.8/gdal/gdal-data.zip
unzip gdal-data.zip
mkdir lib
cd lib
wget https://demo.geo-solutions.it/share/github/imageio-ext/releases/native/gdal/1.9.2/linux/gdal192-Ubuntu12-gcc4.6.3-x86_64.tar.gz
tar -xvf gdal192-Ubuntu12-gcc4.6.3-x86_64.tar.gz1. Upload file rgb.tiff
2. Create data store in http://localhost:8080/geoserver
3. Publish layer
1. Upload file
2. Create data store
3. Style layer (SLD or QGIS)
4. Publish layer
Example layer: sf:sfdem (Spearfish elevation)
Create overviews (pyramids)
Ex: gdaladdo -r average abc.tif 2 4 8 16
If possible, create cache with GeoWebCache!
2.1 Using WMS standard
Content of a GetCapabilities document
GetMap operation
Output formats and their uses
Consumption from QGIS and web
GetLegendGraphic, GetFeatureInfo
GeoServer-specific: CQL_FILTER
2.2 Using WFS standard
Content of a GetCapabilities document
DescribeFeatureType, GetFeature
Output formats and uses
2.3 Tile caching with GeoWebCache
Choosing the appropriate image formats
Defining a custom pyramid
Pre-generating and deleting tiles
Adding "dimensions" to a cache
2.4 Using cache standards (WMTS, WMS-C)
WMTS: GetCapabilities, GetTile
Concept of pyramid
“De facto” Google standard: TMS (or XYZ)
2.5 Getting the most of GeoServer
Designed for interoperability, it publishes data from any major spatial data source using open standards.
REQUEST (GetMap, GetCapabilities ...)
RESPONSE (image/png, application/json, ...)
CLIENT:
QGIS, ArcGIS, web client (OpenLayers, LeafletJS)
SERVER:
GeoServer, MapServer, QGISServer, ...
WMS REQUEST1
CLIENT:
QGIS, ArcGIS, webpage/ mashup (OpenLayers, LeafletJS)
SERVER1
WFS REQUEST2
SERVER2
WMS REQUEST3
SERVER3
Paradigm: every layer of information can be maintained and published by its producer and can be consumed from multiple clients using OGC Standards.
WMS provides a standard interface for requesting a geospatial map image. The benefit of this is that WMS clients can request images from multiple WMS servers, and then combine them into a single view for the user. The standard guarantees that these images can all be overlaid on one another as they actually would be in reality.
WMS requests can perform the following operations:
| Operation | Description |
| Exceptions | If an exception occur |
| GetCapabilities | Retrieves metadata about the service, including supported operations and parameters, and a list of the available layers |
| GetMap | Retrieves a map image for a specified area and content |
| GetFeatureInfo(optional) | Retrieves the underlying data, including geometry and attribute values, for a pixel location on a map |
| DescribeLayer(optional) | Indicates the WFS or WCS to retrieve additional information about the layer. |
| GetLegendGraphic(optional) |
(Layer preview)
https://docs.qgis.org/3.4/en/docs/user_manual/working_with_ogc/ogc_client_support.html
GetCapabilities -> GetMap
Make a QGIS map with 3 WMS layers
Make a Leaflet map with 2 WMS layers:
Make a Leaflet map with 2 WMS layers
Add the legend of the subway stations layer to Leaflet map with 2 WMS layers
Defined in Style Editor. Make a custom legend (a static image) for subway_stations
Get all subway stations less than 2kms from lon:-73.85 lat:40.75 using CQL_FILTER
(localhost, LayerPreview)
WMS requests can perform the following operations:
| GetCapabilities | Generates a metadata document describing a WFS service provided by server as well as valid WFS operations and parameters |
| DescribeFeatureType | Returns a description of feature types supported by a WFS service |
| GetFeature | Returns a selection of features from a data source including geometry and attribute values |
| LockFeature | Prevents a feature from being edited through a persistent feature lock |
| Transaction | Edits existing feature types by creating, updating, and deleting |
WMS requests can perform the following operations:
| Operation | Description |
| Exceptions | If an exception occur |
| GetCapabilities | Retrieves metadata about the service, including supported operations and parameters, and a list of the available layers |
| GetMap | Retrieves a map image for a specified area and content |
| GetFeatureInfo(optional) | Retrieves the underlying data, including geometry and attribute values, for a pixel location on a map |
| DescribeLayer(optional) | Indicates the WFS or WCS to retrieve additional information about the layer. |
| GetLegendGraphic(optional) |
WFS downloads the full data! Good or bad?
WFS layers are preferable over WMS layers if you need direct access to the attributes and geometries of the layers. However, considering the amount of data that needs to be downloaded (which leads to speed problems and also a lack of easily available public WFS servers) it’s not always possible to use a WFS instead of a WMS.
Make a QGIS map with 1 WFS layer
and 1 WMS layer
GetFeature
Get nyc_neighbourhood that intersects with point lon:-73.85 lat:40.55 using WFS_Intersects
The basic Web Feature Service allows querying and retrieval of features. A transactional Web Feature Service (WFS-T) allows creation, deletion, and updating of features.
GeoWebCache is a tiling server. It runs as a proxy between a map client and map server, caching (storing) tiles as they are requested, eliminating redundant request processing and thus saving large amounts of processing time.
We can not store every WMS GetMap request, the combination of BBOX, WIDTH, HEIGHT and layers is huge!
=> we need TILES
Web Administration Interface
Which format to use?
Direct integration allows WMS requests served through GeoServer to be cached as if they were received and processed by GeoWebCache.
With direct integration, tile caching is enabled for all standard WMS requests that contain the tiled=true parameter and conform to all required parameters.
In your local GeoServer, configure tiles for nyc_census_blocks for EPSG:3857 (aka EPSG:900913).
Warning: keep ZOOM LEVEL below 15 ... it's just training!
geoserver_data_dir/gwc
Standalone platform Default/typical location
| Windows (except XP) | C:\Program Files (x86)\GeoServer 2.16.x\data_dir |
| Windows XP | C:Program Files\GeoServer 2.16.x\data_dir |
| Mac OS X | /Applications/GeoServer.app/Contents/Resources/Java/data_dir |
| Linux (Tomcat) | /var/lib/tomcat7/webapps/geoserver/data |
Instead of drawing on-demand
we get a few files from the server
Make a Leaflet map with 2 WMS layers and check it's cached with GeoWebCache header responses (HIT and MISS)
LayerPreview in Tile Caching->Tile Layers
Common mass market solutions implicitly follow this profile by using Google-Mercator CRS, a common topLeftCorner, the same set of TileMatrices and a fix URL template.
WHO SET THE STANDARD?
Make a Leaflet map with 1 local WMS layer and a basemap from