39,59 €
GeoServer is an open source server-side software written in Java that allows users to share and edit geospatial data. Designed for interoperability, it publishes data from any major spatial data source using open standards. GeoServer allows you to display your spatial information to the world. Implementing the Web Map Service (WMS) standard, GeoServer can create maps in a variety of output formats. OpenLayers, a free mapping library, is integrated into GeoServer, making map generation quick and easy. GeoServer is built on Geotools, an open source Java GIS toolkit.GeoServer Beginner's Guide gives you a kick start to build custom maps using your data without the need for costly commercial software licenses and restrictions. Even if you do not have prior GIS knowledge, you will be able to make interactive maps after reading this book.You will install GeoServer, access your data from a database, style points, lines, polygons, and labels to impress site visitors with real-time maps.Follow along through a step-by-step guide that installs GeoServer in minutes. Explore the web-based administrative interface to connect to backend data stores such as MySQL, PostGIS, MSSQL, and Oracle. Display your data on web-based interactive maps, style lines, points, polygons, and embed images to visualize this data for your web visitors. Walk away from this book with a working application ready for production.After reading the GeoServer Beginner's Guide, you will have beautiful, custom maps on your website built using your geospatial data.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 342
Veröffentlichungsjahr: 2013
Copyright © 2013 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 authors, 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: February 2013
Production Reference: 1110213
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-84951-668-6
www.packtpub.com
Cover Image by Brian Youngblood (<[email protected]>)
Authors
Stefano Iacovella
Brian Youngblood
Reviewers
Pablo Rodríguez Bustamante
Daniela Cristiana DOCAN
Brett Gaines
Eric-Jan Groen
Antonio Santiago
Acquisition Editor
Usha Iyer
Lead Technical Editor
Dayan Hyames
Technical Editor
Jalasha D'costa
Copy Editors
Aditya Nair
Laxmi Subramanian
Ruta Waghmare
Project Coordinator
Amey Sawant
Proofreader
Aaron Nash
Indexer
Hemangini Bari
Production Coordinator
Shantanu Zagade
Cover Work
Shantanu Zagade
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.
I would like to thank many people who have helped me to make this book a reality.
A special mention for GeoServer's developers; they are the wonderful engine without which this book would not exist.
I would like to thank Usha Iyer, Dayan Hyames, Amey Sawant, and everyone else at Packt Publishing for all their hard work to get this book published.
My gratitude to Luca Morandini, a colleague and friend; he spurred me to take this challenge.
Last but not the least, I want to express my gratitude to Alessandra, Alice, and Luisa for their support and patience.
Brian Youngblood is a open source developer living in Montgomery, AL with more than a decade of experience developing, integrating, and managing high traffic websites.
Brian was the Online Operations Manager and Technical Lead at the Southern Poverty Law Center for over 12 years. The SPLC is a nationally recognized nonprofit, and its websites SPLCenter.org and Tolerance.org have continued to get sharp increases in visitors year-on-year, resulting in growth in its online operations with open source. The SPLC won two Webby Awards in 2002 and 2004.
Brian was also the founding partner and Chief Technology Officer for IntelliTours, a GPS-guided multimedia tour. He worked with several companies developing hardware and software including Alcorn McBride, Volkswagen, and Garmin. His work explored San Diego, Santa Cruz, Hawaii, and miles and miles of I-95 on the East Coast. Most notably, his work was featured on the cover of Entertainment Engineering magazine, Martha Stewart radio, the LA Times, and NPR.
Embracing the spirit of other open source communities such as Drupal, and a combined passion for scalable GIS solutions, led him to adopt GeoServer for rapidly changing geospatial data stores.
You can contact him at <[email protected]> or follow him on twitter @brianyoungblood.
The GeoServer developers and community. So many have contributed to bringing this software to this point. Specifically, Andrea Aime, Chris Holmes, Gabrel Roldan, and David Winslow have fielded my questions on GeoServer's mailing list and in IRC. Their tireless commitment to the GeoServer project has helped me and so many others immensely.
Other contributors are also listed on the contributors page at http://geoserver.org/display/GEOS/Contributors.
Thank you Melissa Henninger for helping edit and proof chapters. To Bill Fitzgerald for his advice as a Packt author.
Pablo Rodríguez Bustamante is a geographer and an Environment and Geographic Information Systems (GIS) Consultant with experience in the field of water resource planning and natural hazards.
He has 4 years' experience in the field of GIT (Geographic Information Technologies) and thematic mapping, 3 years' experience in environmental consulting, and 2 years' experience in water planning issues and natural hazards.
He is a GIS specialist. He has expertise in EIA and Urban and Regional Planning.
He is fluent in Spanish, English, and Italian.
GEOCyL Environmental and Territorial Consultancy
GEOCyL is an environmental and territorial consultancy specializing in environmental studies, risk management, GIS development, land management, urban planning, geomarketing, and spreading knowledge about nature and our environment.
Our company optimizes various territorial areas in different sectors. For that, we use the newest technologies in geographical science concerning environmental and territorial issues. On the basis of GIS, we provide specific and optimized solutions for public authorities and/or private companies.
R&D lines (lines of research)
I would like to thank my family and my GEOCyL partners (Eduardo Bustillo, Florian Schilling, …), who always supported me, even in difficult times. Special thanks to my girlfriend Patricia and my friends.
Daniela Cristiana DOCAN is a lecturer at Technical University of Civil Engineering, Bucharest, Romania. She works within the Faculty of Geodesy, mainly in GIS and survey engineering.
Formerly, she worked for ESRI Romania and ANCPI (National Agency of Cadastre and Land Registration).
She obtained her Ph.D in 2009 in Civil Engineering, with the thesis "Contributions to quality improvement of spatial data in GIS".
While working for ESRI Romania, she has trained (as an authorized Instructor in ArcGIS by Environmental Systems Research Institute, Inc. (ESRI), Redlands, California, USA) teams from different states and privately owned companies. Also, she has created and administrated databases (geodatabase format) for different domains of activity.
For ANCPI (National Agency of Cadastre and Land Registration), in 2009 she created (for the first time in the field) a logical and physical datamodel for the National Topographic Data set on a large scale (TOPRO5). She was a member of different workgroups who elaborated the standards and technical specifications and the country report, in 2010 for INSPIRE (Infrastructure for Spatial Information in the European Community).
Brett Gaines is a GIS programmer and remote sensing analyst. He holds a B.S. degree in Geography with a specialization in GIS, along with a M.Sc. degree in GIS.
He stays on the leading edge of GIS and database technologies, and he is always eager to learn new things. He prefers challenging projects and solving tough geospatial intelligence problems.
Eric-Jan Groen is a Linux Professional from the Netherlands. Formerly, he worked at Automotive Navigation Data.
I would like to thank everyone who helped create this book in any way.
Antonio Santiago is a computer science professional with a keen interest in the subject. He is an extremely curious Software Engineer who loves programming and learning new things.
GIS is his preferred area of interest, mainly because of the amount of things it encloses: databases with spatial capabilities, servers, protocols and standards, desktop and web development, and scalability.
After working with different technologies, such as C, Perl, and PHP, he found his preferred language, Java.
In 2004, while on a weather radar project with the IDL language (Interactive Data Language), he started working with OGC standards and GeoTools/GeoServer projects.
Nowadays, he is more focused on the JavaScript language because of the great performance implementation of current browsers and the growing adoption of the HTML5 specification.
He has authored the book OpenLayers Cookbook, by Packt Publishing.
To my partner, Pilar, for understanding my passion for computers, and to my parents for igniting in me the spark to see the beauty of learning.
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 <[email protected]> for more details.
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.
http://PacktLib.PacktPub.com
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.
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.
Get notified! Find out when new books are published by following @PacktEnterprise on Twitter, or the Packt Enterprise Facebook page.
I would like to express all my gratitude, affecttion, and professional respect to Ruggero Faggioni.
He was a colleague and a friend. He helped me discover my skills; he gave me the opportunity to grow as a GIS consultant. In the years we worked together, he was not only a boss, but also a kind tutor, and he taught me a lot.
I would like to dedicate this book to Ruggero, unfortunately he isn't there anymore to read it, but I am sure he would have liked it.
Stefano Iacovella
I would like to thank Jon Fisher from Auburn University Montgomery who ultimately led me to pursue a career in the Information Technology field. His patience, mentoring, and willingness to share his knowledge planted the seed that continues to grow today.
To Jim Carrier, the founder and my partner at IntelliTours for sharing the passion to explore the world around us through the use of GPS, story-telling, and writing.
My grandmother, mom, dad, brother, sister-in-law, and two nephews. They have seen my highs and lows during the process of writing this book and provided encouragement when I needed it most.
Also, it would be remiss if I didn't mention my dog Cooper, who has never been too far from me and my keyboard as I have written this book over many long nights and weekends.
Brian Youngblood
Nowadays, web mapping is all over the Internet. User friendly-interfaces and efficiency are mandatory requirements for GIS, as for any other system. If you are going to start a new web mapping application, you will not start from scratch. GeoServer is one of the biggest players in the web mapping field. It has a solid developer community and a high maturity level. Although it's not an easy piece of software to master, the latest releases have greatly improved stability and ease of management.
GeoServer Beginner's Guide offers you a practical introduction to GeoServer. Beginning with the installation and basic usage, you will learn to use the administration interface for adding data, configuring layers, customizing OGC services, and securing your site. You will find included lots of step-by-step examples, covering topics from data store configuration to layer publication and style customization. If all this sounds new and strange to you, don't worry; GeoServer Beginner's Guide will introduce you to the fundamentals of GIS and will then clearly explain all the basic tasks performed in order to build maps.
This book is meant to expand your knowledge of web mapping from something you have either heard of or have practised a little, into something you can apply at any level to meet your needs in incorporate maps for a site. I hope you will enjoy reading this book as much as I did writing it.
Chapter 1, GIS Fundamentals, introduces you to GIS concepts. It guides you through spatial data types and maps. You will discover how spatial information is stored and how to set up a map. You may want to skip this chapter if you already have a solid background in GIS.
Chapter 2, Getting Started with GeoServer, guides you in setting up your first GeoServer instance. It shows you, step by step, how to download the most recent version of the software and its requirements, that is, JAVA and a servlet container. For each component, a detailed description about how to install it is included.
Chapter 3, Exploring the Administrative Interface, covers GeoServer's web administration interface. It explains how to log in and access each section. You will familiarize yourself with data configuration following a common workflow that starts by adding data to GeoServer and guides you through to publication. Included in this chapter are screen captures that define the main areas of the program and menu items—all of which is very helpful when accessing the interface for the first time.
Chapter 4, Accessing Layers, guides you through data publication. The chapter covers in detail all output types offered by GeoServer for your data. Raster formats such as JPEG and PNG are discussed for maps, while vector formats such as GeoRSS and GEOJSON are explained for vector output. We will also explore OpenLayers, a JavaScript framework that GeoServer includes in its output format, when you want to serve your data as an application.
Chapter 5, Adding Your Data, demonstrates how you can configure data in GeoServer. The examples included will show you how to add and publish shapefiles and PostGIS tables, two of the most common formats, which are also natively supported by GeoServer. The extensions for Oracle and MySQL are also discussed.
Chapter 6, Styling Your Layers, explains how to apply styles to your layers. Styles let you render your data according to attributes, in order to build pretty maps. SLD's syntax, the standard for data rendering, will be explained in detail, with examples for different geometry types such as point, polyline, and polygons. The chapter also illustrates how to build scale-dependent symbology and how to compose different rendering in a group, to mimic a map in WMS.
Chapter 7, Building a Simple Map for Your Site Using OpenLayers, Google Maps, and Your Geospatial Data, describes how to build client applications with the JavaScript framework. JavaScript is a powerful and widespread language and, unsurprisingly, it is one of the best choices when developing a web application. We will build some sample maps using Google Maps API, OpenLayers, and Leaflet.
Chapter 8, Performance and Caching, covers the use of integrated GeoWebCache. Caching maps is a common strategy with map servers; it allows you to serve pretty complex maps without running out of resources. The GeoServer 2.2 release introduces a great change: you can fully administer the integrated GeoWebCache from the web admin interface. In the examples included, you will configure cache with different strategies, optimizing performance, or disk usage.
Chapter 9, Automating Tasks: GeoServer REST Interface, explains how to control the GeoServer configuration from a remote location through the REST interface. This may prove a great help if you have to administer a GeoServer site without the possibility of using the web admin interface, or if you want to automatize, in an external procedure, some admin tasks. The included examples will let you add data, configure styles and layers, and publish them. All the operations are demonstrated with Python and cURL syntaxes.
Chapter 10, Securing GeoServer Before Production, covers the GeoServer security module. The chapter first discusses general configuration for security, that is, password encryption, and then the security model is explained. A case history shows you how to create a configuration where different users are in charge of administration, editing, and publication tasks.
Chapter 11, Tuning GeoServer in a Production Environment, explains the advanced considerations for running a successful GeoServer site. It covers Java Runtime tuning and data and services optimization. Finally, a high availability configuration is detailed, with instructions for configuring a balanced GeoServer installation.
Chapter 12, Going Further: Getting Help and Troubleshooting, shows you how to access community tools and help for going further than what you will learn from this book. It also covers a concise introduction to other data publication standards implemented in GeoServer, WCS, and WFS. With WCS and WFS, you can serve vector and raster data to clients that not only need to show a map but have to perform some processing on the data.
Installation and download instructions are described for all the software packages you will need. You just need to have access to a computer with an online connection for downloading packages. The instructions cover both Linux and Windows operating systems, so you may select the one you prefer.
All the software used in this book is freely available, most of the time as an open source project. Hardware requirements for development purposes are not very high. A relatively modern laptop or desktop will be enough for running examples. Source code and data used in this book are freely available on the Packt Publishing site.
If you are going to use maps on your site, incorporate spatial data in a desktop application, or you are just curious about web mapping, this book offers you a fast-paced and practical introduction.
Particularly if you need to develop a web application supporting maps, you will find that GeoServer is one of the best solutions you can choose.
Analysts will discover how GIS works and how it can be integrated in complex systems. System administrators may also find this book useful for planning installation, tuning, and maintenance.
In this book, you will find several headings appearing frequently.
To give clear instructions of how to complete a procedure or task, we use:
Instructions often need some extra explanation so that they make sense, so they are followed with:
This heading explains the working of tasks or instructions that you have just completed.
You will also find some other learning aids in the book, including:
These are short multiple-choice questions intended to help you test your own understanding.
These practical challenges and give you ideas for experimenting with what you have learned.
You will also find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.
Code words in text are shown as follows: "Get the 6686_05_mysql_usacounties.sql.zip file and unzip it. Create a new database in MySQL. Call it geoserver."
A block of code is set as follows:
Newterms and importantwords are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Start Tomcat service and then log in to the GeoServer administration interface. Go to the Data | Stores section and click on Add new store. You can now see some new options. Select MySQL".
Warnings or important notes appear in a box like this.
Tips and tricks appear like this.
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.
To send us general feedback, simply send an e-mail to <[email protected]>, and mention the book title through the subject of your message.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
We also provide you a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from http://www.packtpub.com/sites/default/files/downloads/6686OS_Graphics.pdf.
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the erratasubmissionform link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website, or added to any list of existing errata, under the Errata section of that title.
Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at <[email protected]> with a link to the suspected pirated material.
We appreciate your help in protecting our authors, and our ability to bring you valuable content.
You can contact us at <[email protected]> if you are having a problem with any aspect of the book, and we will do our best to address it.
In this chapter, you will learn the foundation of geographical information system and spatial data. Although you do not need to understand these subjects in great depth to take advantage of the features of GeoServer, we will give you the basic information required to understand what you will be doing in the book. You will be introduced to the magic of spatial.
We are going to cover the following topics:
By the end of the chapter, you will have the basic skills to identify which spatial data format best suits your needs.
Since you were a kid at school you have been exposed to a lot of maps. Maps of countries, where you spent hours memorizing the boundaries, rivers, and capitals; historical maps, with the rise and fall of ancient empires, where you dreamed of being a great conqueror; economics maps, with the locations and amounts of goods and services. Every day on newspapers, on TV, or in a far more accurate presentation, in books and academic papers you look at data represented on a map. Maps are a spatial representation of data and are often the main output of a GIS.
GIS is an acronym for GeographicalInformationSystem. Does it sounds too complicated to you? Don't be afraid; it is not so different from many other systems for managing information you probably already know. The main difference is in the spatial piece of information. All the data contained in a GIS has a spatial dimension or a link to another object with spatial attributes.
So what is GIS? In a nutshell, we can define it as a system to acquire and store data, to process data, and to produce data representations, that is, maps. In this book you will learn that working with GeoServer requires you to prepare your data, process it to render in a beautiful map, and build up a set of functions that enable a user to interact with your data. So building up a GeoServer instance may be described as GIS-building.
A detailed comprehension of GIS is far beyond the scope of this book and it is not required for starting with GeoServer. But you need to have some basic skills in spatial data, maps, and spatial reference systems.
Let's go; we are going to turn you into a neo-cartographer!
If you have ever built a simple map to annotate your hiking on mountains or to send driving directions to your girlfriend or boyfriend, you have dealt with spatial data.
Spatial data is the foundation of any GIS. You know that a building is likely to fall down unless it is sitting atop a strong foundation. So you need to understand spatial data or you will be producing poor map output.
But what is spatial data in simple words? From a general point of view you can consider a piece of spatial information. Each description of an object contains a reference to its position on the Earth's surface. Well, that is not a rigorous formal definition as there are a lot of objects below and over the earth's surface, but for now we are fine with this simplistic definition.
Think of some lists of familiar objects:
You can say where each element is located in a more or less precise way. They are real objects represented with spatial data. As you may have noted, the spatial information is represented in quite a heterogeneous way. Most people are able to recognize spatial information in any group from the previous list. Unfortunately, GIS software and GeoServer are an exception to this and tend to prefer a strong structured piece of information. If you are going to use your spatial data with GeoServer, you need to organize it more accurately. We will talk specifically about GeoServer's data connectors in Chapter 5, Adding Your Own DataStore, but for now it is important that you understand how spatial data is commonly organized and stored. As you keep on making maps, you will deal with lots of different spatial data.
So spatial data are references for an object's position on the earth's surface. How can you measure and store them in a numeric format? An elementary model of the earth could be a sphere. On a sphere's surface, you can measure positions with angular units called latitude and longitude. Latitude (ϕ) measures the angle between the equatorial plane and a line that passes through that point and is normal to the surface; whereas longitude (λ) measures the angle east or west from a reference meridian (for example, that passing through Greenwich observatory) to another meridian that passes through that point. Angular measures can be expressed in digital degrees or in degrees, minutes, and seconds.
If you want to store the location of The Statue of Liberty, you can express it as Lat. 40° 41′ 21″ N, Long. 74° 2′ 40″ W with degrees, minutes, and seconds or as 40.689167, -74.044444 using decimal degrees.
(Image from http://en.wikipedia.org/wiki/Latitude)
We normally think of earth as a sphere but this is not its real shape. Geodesy, the science of studying the earth's shape, defines earth as represented by a geoid, an ideal surface defined by the level of sea if oceans would cover the entire earth. For practical purposes, as in projections, geoid is too complicated to use and the earth's shape is defined by an ellipsoid. The ellipsoid is described by its semi-major axis (equatorial radius) and flattening.
Does it sound a little bit complicated? Don't be afraid and explore locations on earth with Lat. Long. coordinates. In the following table, there are a few famous places with coordinates in decimal degrees. Point your browser to http://maps.google.com
