GeoServer Cookbook
()
About this ebook
GeoServer is one of the founding blocks of the OS-Geo software stack. It helps connect existing information not only to virtual globes, such as Google Earth, but also to web-based maps such as OpenLayers, Google Maps, and Bing Maps.
You will start off by learning about the various concepts of vector data used in GeoServer to build maps. You will then learn how to build beautiful maps by using advanced styling methods such as CSS. Finally, you will learn how to monitor and tune the GeoServer environment. With this comprehensive guide, you will gain an in-depth knowledge of GeoServer features that will allow you to integrate it into your enterprise systems for data processing and publication quickly and efficiently.
Stefano Iacovella
Stefano Iacovella is a long-time GIS developer and consultant living in Rome, Italy. He also works as a GIS course instructor. He has a Ph.D in Geology. Being a very curious person, he has developed a deep knowledge of IT technologies, mainly focused on GIS Software and related standards. Starting his career as an ESRI employee, he was exposed to and became confident with proprietary GIS Software, mainly the ESRI suite of products. For the last 10 years, he has been involved with open source software and also the task of integrating it with commercial software. He loves the open source approach, and really trusts in the collaboration and sharing of knowledge. He strongly believes in the concept of open source, and constantly strives to spread it, and not only in the GIS sector. He has been using GeoServer since the release of Version 1.5; configuring, deploying, and hacking it in several projects. Some of the other GFOSS projects he mainly uses and likes are GDAL/OGR libraries, PostGIS, QGIS, and OpenLayers. When not playing with maps and geometric shapes, he loves reading about science, mainly physics and math, riding his bike, and having fun with his wife and his two daughters, Alice and Luisa.
Related to GeoServer Cookbook
Related ebooks
ArcGIS for Desktop Cookbook Rating: 5 out of 5 stars5/5QGIS By Example Rating: 3 out of 5 stars3/5Developing Mobile Web ArcGIS Applications Rating: 0 out of 5 stars0 ratingsBuilding Mapping Applications with QGIS Rating: 0 out of 5 stars0 ratingsOpenLayers 3.x Cookbook - Second Edition Rating: 0 out of 5 stars0 ratingsMapbox Cookbook Rating: 0 out of 5 stars0 ratingsLearning D3.js Mapping Rating: 0 out of 5 stars0 ratingsMySQL Admin Cookbook LITE: Configuration, Server Monitoring, Managing Users Rating: 4 out of 5 stars4/5OpenGL Data Visualization Cookbook Rating: 0 out of 5 stars0 ratingsLucene 4 Cookbook Rating: 0 out of 5 stars0 ratingsGeoServer Beginner's Guide Rating: 0 out of 5 stars0 ratingsMastering GeoServer Rating: 0 out of 5 stars0 ratingsQGIS Python Programming Cookbook - Second Edition Rating: 0 out of 5 stars0 ratingsPostGIS in Action, Second Edition Rating: 4 out of 5 stars4/5Python Geospatial Analysis Cookbook Rating: 0 out of 5 stars0 ratingsLearning QGIS - Third Edition Rating: 4 out of 5 stars4/5ArcGIS Server Third Edition Rating: 0 out of 5 stars0 ratingsLearning ArcGIS Runtime SDK for .NET Rating: 0 out of 5 stars0 ratingsMapping and Modeling Weather and Climate with GIS Rating: 0 out of 5 stars0 ratingsGeospatial Development By Example with Python Rating: 5 out of 5 stars5/5PostGIS Cookbook Rating: 0 out of 5 stars0 ratingsFocus on Geodatabases in ArcGIS Pro Rating: 4 out of 5 stars4/5PostGIS in Action, Third Edition Rating: 0 out of 5 stars0 ratingsQGIS Python Programming Cookbook Rating: 0 out of 5 stars0 ratingsLeaflet.js Essentials Rating: 4 out of 5 stars4/5Instant OpenLayers Starter Rating: 0 out of 5 stars0 ratingsMastering PostGIS Rating: 0 out of 5 stars0 ratingsPractical GIS Rating: 0 out of 5 stars0 ratingsMastering ArcGIS Server Development with JavaScript Rating: 4 out of 5 stars4/5An Introduction to Spatial Data Analysis: Remote Sensing and GIS with Open Source Software Rating: 0 out of 5 stars0 ratings
Internet & Web For You
Python: Learn Python in 24 Hours Rating: 4 out of 5 stars4/5The $1,000,000 Web Designer Guide: A Practical Guide for Wealth and Freedom as an Online Freelancer Rating: 4 out of 5 stars4/5Coding All-in-One For Dummies Rating: 4 out of 5 stars4/5Notion for Beginners: Notion for Work, Play, and Productivity Rating: 4 out of 5 stars4/5Coding For Dummies Rating: 5 out of 5 stars5/5Principles of Web Design Rating: 0 out of 5 stars0 ratingsStop Asking Questions: How to Lead High-Impact Interviews and Learn Anything from Anyone Rating: 5 out of 5 stars5/5Everybody Lies: Big Data, New Data, and What the Internet Can Tell Us About Who We Really Are Rating: 4 out of 5 stars4/5Grokking Algorithms: An illustrated guide for programmers and other curious people Rating: 4 out of 5 stars4/5Get Into UX: A foolproof guide to getting your first user experience job Rating: 4 out of 5 stars4/5The Basics of User Experience Design by Interaction Design Foundation Rating: 4 out of 5 stars4/5The Designer’s Guide to Figma: Master Prototyping, Collaboration, Handoff, and Workflow Rating: 0 out of 5 stars0 ratingsLearn JavaScript in 24 Hours Rating: 3 out of 5 stars3/5Cybersecurity For Dummies Rating: 5 out of 5 stars5/5Social Engineering: The Science of Human Hacking Rating: 3 out of 5 stars3/5The Logo Brainstorm Book: A Comprehensive Guide for Exploring Design Directions Rating: 4 out of 5 stars4/5Learn NodeJS in 1 Day: Complete Node JS Guide with Examples Rating: 3 out of 5 stars3/5Explain the Cloud Like I’m 10 Rating: 5 out of 5 stars5/5UX/UI Design Playbook Rating: 4 out of 5 stars4/5Token Economy: How the Web3 reinvents the Internet Rating: 4 out of 5 stars4/5Sad by Design: On Platform Nihilism Rating: 4 out of 5 stars4/52022 Adobe® Premiere Pro Guide For Filmmakers and YouTubers Rating: 5 out of 5 stars5/5RESTful API Design - Best Practices in API Design with REST: API-University Series, #3 Rating: 5 out of 5 stars5/5JavaScript All-in-One For Dummies Rating: 5 out of 5 stars5/5The Gothic Novel Collection Rating: 5 out of 5 stars5/5Deep Learning with Python Rating: 5 out of 5 stars5/5The Digital Marketing Handbook: A Step-By-Step Guide to Creating Websites That Sell Rating: 5 out of 5 stars5/5
Reviews for GeoServer Cookbook
0 ratings0 reviews
Book preview
GeoServer Cookbook - Stefano Iacovella
Table of Contents
GeoServer Cookbook
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why Subscribe?
Free Access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Sections
Getting ready
How to do it…
How it works…
There's more…
See also
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. Working with Vectors
Introduction
Using different WFS versions in OpenLayers
How to do it…
How it works…
There's more…
Using WFS nonspatial filters
How to do it…
How it works…
Using WFS spatial filters
How to do it…
How it works…
Using WFS vendor parameters
How to do it…
How it works…
Filtering data with CQL
How to do it…
How it works…
Filtering data with CQL spatial operators
How to do it…
How it works…
Creating a SQL view
How to do it…
How it works…
There's more…
Creating a parametric view
How to do it…
How it works…
Improving performance with pregeneralized features
How to do it…
How it works…
2. Working with Rasters
Introduction
Getting coverages in different formats
How to do it…
How it works…
Using WCS vendor parameters
How to do it…
How it works…
Publishing a mosaic
Getting ready
How to do it...
How it works…
Using pyramids
How to do it…
How it works…
Adding GDAL formats
Getting ready
How to do it…
How it works...
Adding a PostGIS raster data source
How to do it…
How it works…
3. Advanced Styling
Introduction
Installing the CSS module
How to do it…
How it works…
Creating a simple polygon style with CSS
How to do it…
How it works…
Adding filters to your style
How to do it…
How it works…
Adding labels with CSS
How to do it…
How it works…
Creating scale-dependent rules
How to do it…
How it works…
Rendering transformations for raster data
How to do it…
How it works…
Creating a dot density chart
How to do it…
How it works…
4. Geoprocessing
Introduction
Installing the WPS module
How to do it…
How it works…
Using the WPS process builder
How to do it…
How it works…
Chaining process – selecting features contained in a polygon
How to do it…
How it works…
Chaining process – building your own task
How to do it…
How it works…
There is more…
5. Advanced Configurations
Introduction
Upgrading GeoServer
How to do it…
How it works…
See also
Creating a script for automatic startup
How to do it…
How it works…
Optimizing Java
How to do it…
How it works…
Setting up a JNDI connection pool
How to do it…
How it works…
Working with CRS
How to do it…
How it works…
See also
Using the reprojection console
How to do it…
How it works…
Overriding an official EPSG code
How to do it…
How it works…
Setting up GeoWebCache – how to make pre-rendered tiles for high availability
How to do it…
How it works…
Storing configurations in an RDBMS
How to do it…
How it works…
6. Automating GeoServer Configurations
Introduction
Managing workspaces with REST
Getting ready
How to do it…
How it works…
There's more…
Creating and editing data stores with REST
How to do it…
How it works…
There's more…
Managing layers with REST
How to do it…
How it works…
There's more…
Uploading and updating styles with REST
How to do it…
How it works…
Managing layers with the GWC REST API
How to do it …
How it works …
Managing cache tiles with the GWC REST API
How to do it…
How it works…
7. Advanced Visualizations
Introduction
Adding time to WMS maps
Getting ready
How to do it…
How it works…
Using the WMS animator
How to do it…
How it works…
There's more…
Keyhole Markup Language styling
Getting ready
How to do it…
How it works…
There's more…
Using z-order creatively
How to do it…
How it works…
Using transparency creatively
Getting ready
How to do it…
How it works…
Using symbology encoding
How to do it…
How it works…
8. Monitoring and Tuning
Introduction
Installing the control flow module
How to do it…
How it works…
Setting a per-user limit
How to do it…
How it works…
Setting a per-request limit
Getting ready
How to do it…
How it works…
Installing the monitoring extension
Getting ready
How to do it…
How it works…
Configuring the monitoring extension
Getting ready
How to do it…
How it works…
Creating reports from the monitoring database
How to do it…
How it works…
There's more…
Limiting the GeoWebCache disk use
How to do it…
How it works…
A. OGC for ESRI Professionals
Introduction
ArcGIS versus GeoServer
Understanding standards
WMS versus the mapping service
WFS versus feature access
Publishing raster data with WCS
Index
GeoServer Cookbook
GeoServer Cookbook
Copyright © 2014 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: November 2014
Production reference: 1201114
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78328-961-5
www.packtpub.com
Credits
Author
Stefano Iacovella
Reviewers
Dan Blundell
Daniela Cristiana Docan
Antonio Santiago
Commissioning Editor
Usha Iyer
Acquisition Editor
Subho Gupta
Content Development Editor
Vaibhav Pawar
Technical Editor
Pooja Nair
Copy Editors
Roshni Banerjee
Adithi Shetty
Project Coordinator
Kranti Berde
Proofreaders
Simran Bhogal
Ameesha Green
Paul Hindle
Indexers
Mariammal Chettiyar
Tejal Soni
Production Coordinators
Kyle Albuquerque
Arvindkumar Gupta
Cover Work
Arvindkumar Gupta
About the Author
Stefano Iacovella is a long-time GIS developer and consultant living in Rome, Italy. He also works as a GIS instructor.
He has a PhD in Geology. Being a very curious person, he developed a deep knowledge of IT technologies, mainly focusing on GIS software and related standards.
Starting his career as an ESRI employee, he was exposed to and became confident in proprietary GIS software, mainly the ESRI suite of products.
In the last 14 years, he has been involved with open source software, integrating it with proprietary software. He loves the open source approach, and really trusts in collaboration and sharing knowledge. He strongly believes in the open source idea and constantly manages to spread it, not only in the GIS sector but also in others.
He has been using GeoServer since the release of Version 1.5, configuring, deploying, and hacking it in several projects. Some of the other GFOSS projects he mainly uses and likes are GDAL/OGR, PostGIS, QGIS, and OpenLayers.
Prior to this cookbook, Stefano worked on GeoServer Beginner's Guide, which covers the basics of GeoServer.
When not playing with maps and geometric shapes, he loves reading about science (mainly physics and math), riding his bike, and having fun with his wife and two daughters, Alice and Luisa. You can contact him at <[email protected]> or follow him on Twitter at @iacovellas.
Acknowledgments
I would like to thank all those people who helped me make this book a real thing.
A special mention for GeoServer's developers; they are the wonderful engine without which this software, and hence, this book too, would not exist.
I would like to thank all the people at Packt Publishing who worked on this book. They helped me a lot and were very patient and encouraging when I had difficulties meeting deadlines.
A special thanks to my technical reviewers; they constantly checked for my errors and omissions. This book has become better thanks to all their hard work.
Last but not least, I want to express my gratitude to Alessandra, Alice, and Luisa for their support and patience when I was working on this book.
About the Reviewers
Dan Blundell is a designer and developer with over 10 years of experience. He has worked in both the public and private sector, from the government to creative agencies. With clients ranging from district authorities and local businesses to international brands, Dan not only has a breadth of experience, but also a reputation for delivery. Today, he is working towards making the government more open, creative, and collaborative.
Daniela Cristiana Docan is a survey engineer. She works as a lecturer for the Faculty of Geodesy, Technical University of Civil Engineering Bucharest, Romania.
Formerly, she worked for ESRI Romania and ANCPI (National Agency for Cadastre and Land Registration).
While working for ESRI Romania, Daniela trained teams from different private or state companies as an authorized instructor in ArcGIS by Environmental Systems Research Institute, Inc., USA.
In 2009, she created the logical and physical data model of the National Topographic Dataset for ANCPI on a large scale (TOPRO5). She was also a member of different workgroups that elaborated on technical specifications and country reports for INSPIRE (Infrastructure for Spatial Information in the European Community) in 2010.
Antonio Santiago is a Computer Science graduate with more than 10 years of experience in designing and implementing systems.
Since the beginning of his professional life, his experience has always been related to the world of meteorology, working for different companies dealing with meteorology as an employee or a freelance programmer. He has experience in developing systems to collect, store, transform, analyze, and visualize data. He is interested in and actively pursues any GIS-related technology, with preference for data visualization.
As a restless person, which is what one mainly experiences while working in the Java ecosystem, he has also been actively involved with many web-related technologies, always looking to improve the client side of web applications.
As a firm believer of software engineering practices, he is an enthusiast of Agile methodologies involving customers as the main key for a project's success.
Antonio is also the author of OpenLayers Cookbook, Packt Publishing.
www.PacktPub.com
Support files, eBooks, discount offers, and more
You might want to visit www.PacktPub.com for support files and downloads related to your book.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
https://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books.
Why Subscribe?
Fully searchable across every book published by Packt
Copy and paste, print and bookmark content
On demand and accessible via web browser
Free Access for Packt account holders
If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access.
Preface
Until a decade ago, spatial data and the art of map building were considered tricky and complex—almost reserved for highly skilled and specialized professionals.
The advent of web mapping has changed the way geography is perceived by people. This has been largely powered by a few types of open source software that made it possible for everyone to collect, manage, and publish spatial data on the Internet.
GeoServer is one of these precious gems. Along with open JavaScript frameworks such as OpenLayers and Leaflet, it gives everyone the tools they need to create a powerful map server and lightweight applications that run in modern browsers. This allows users to show data visualizations, create online data editors, and do much more.
GeoServer is a complete and powerful type of server software that can publish data to a web mapping application. In recent releases, support for geoprocessing operations has been added, which lets you use GeoServer as a data processor.
Since the beginning, GeoServer has support to standards from Open Geospatial Consortium (OGC), which is kept compatible with its recent most relevant releases (for more information on OGC, have a look at http://www.opengeospatial.org).
This book will guide you through the details of configuring data for publication, creating geoprocessing tasks, and optimizing your server for optimal performance.
What this book covers
Chapter 1, Working with Vectors, discusses vector data publication with WFS. It covers how to use the data with a JavaScript client. It also explores how to use parametric SQL views and how to enhance performance with feature generalization.
Chapter 2, Working with Rasters, explores the different raster data types you can publish with GeoServer. It also covers the mosaic data creation and adding support for more formats that integrates GDAL libraries in your server.
Chapter 3, Advanced Styling, deals with the art of representing data on a map. Using the CSS module, you will explore how to create symbols for vector data and how to build a renderer for raster data.
Chapter 4, Geoprocessing, teaches you how to create data processing tasks on GeoServer. By following the recipes, you'll understand how you can use GeoServer to create complex server-side functions and use them in your client.
Chapter 5, Advanced Configurations, deals with some advanced configuration tasks. You'll explore database connection optimization, configuring the cache to improve performance, and Spatial Reference System (SRS) optimization.
Chapter 6, Automating GeoServer Configurations, explores the GeoServer REST interface. Using the operation published in that interface, you will discover how to create automatic tasks to update your site's configuration.
Chapter 7, Advanced Visualizations, focuses on some visualization techniques. You will explore how to add time support in WMS, create animated maps, and export data to Google Earth.
Chapter 8, Monitoring and Tuning, teaches you the use of the control flow and how to monitor extensions for GeoServer. With the tools provided, you can control how the requests are filtered and queued to your server. You will learn how to save information about users' requests and analyze them to build reports.
Appendix, OGC for ESRI Professionals, discusses a brief comparison between GeoServer and ArcGIS for Server, a map server created by ESRI. The importance of adopting OGC standards when building a geographical information system is stressed. You will learn how OGC standards lets you create a system where different pieces of software cooperate with each other.
What you need for this book
You will need a working instance of the following types of software:
Tomcat
GeoServer
PostGIS
The recipes work both with Linux and Windows operating systems, so you may select the one you prefer.
All the software used in this book is freely available, mostly as open source projects. Hardware requirements for development purposes are not very high. A relatively modern laptop or desktop will be enough to run the examples. Source code and data used in this book are freely available on the Packt Publishing site.
Who this book is for
If you are a developer or an analyst familiar with GIS, WMS, WFS, and spatial data, and you wish to get the most out of GeoServer, then this book is for you.
You can use it as a desktop quick reference guide to solve the common issues you find in your day-to-day job.
Sections
In this book, you will find several headings that appear frequently (Getting ready, How to do it…, How it works…, There's more…, and See also).
To give you clear instructions on how to complete a recipe, we use these sections:
Getting ready
This section tells you what to expect in the recipe, and describes how to set up any type of software or any preliminary settings required for the recipe.
How to do it…
This section contains the steps required to follow the recipe.
How it works…
This section usually consists of a detailed explanation of what happened in the previous section.
There's more…
This section consists of additional information about the recipe in order to make the reader more knowledgeable about the recipe.
See also
This section provides helpful links to other useful information for the recipe.
Conventions
In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.
Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: Save the file in a folder published on your server, such as TOMCAT_HOME/webapps/ROOT, and point your browser to it.
A block of code is set as follows: