45,59 €
This step-by-step guide will teach you how to use GeoServer to build custom and interactive maps using your data.
If you are a web developer with knowledge of server side scripting, have experience in installing applications on the server, and want to go beyond Google Maps by offering dynamically built maps on your site with your latest geospatial data stored in MySQL, PostGIS, MySQL, or Oracle, this is the book for you.
GeoServer is an opensource server written in Java that allows users to share, process, and edit geospatial data. This book will guide you through the new features and improvements of GeoServer and will help you get started with it. GeoServer Beginner's Guide gives you the impetus 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, and apply style points, lines, polygons, and labels to impress site visitors with real-time maps. Then you follow a step-by-step guide that installs GeoServer in minutes. You will explore the web-based administrative interface to connect to backend data stores such as PostGIS, and Oracle. Going ahead, you can display your data on web-based interactive maps, use style lines, points, polygons, and embed images to visualize this data for your web visitors. You will walk away from this book with a working application ready for production.
After reading GeoServer Beginner's Guide, you will be able to build beautiful custom maps on your website using your geospatial data.
Step-by-step instructions are included and the needs of a beginner are totally satisfied by the book. The book consists of plenty of examples with accompanying screenshots and code for an easy learning curve.
Sie lesen das E-Book in den Legimi-Apps auf:
Seitenzahl: 337
Veröffentlichungsjahr: 2017
BIRMINGHAM - MUMBAI
Copyright © 2017 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: February 2013
Second edition: October 2017
Production reference: 1111017
ISBN 978-1-78829-737-0
www.packtpub.com
Author
Stefano Iacovella
Copy Editor
Zainab Bootwala
Reviewer
Colin Henderson
Project Coordinator
Prajakta Naik
Commissioning Editor
Merint Mathew
Proofreader
Safis Editing
Acquisition Editor
Chaitanya Nair
Indexer
Aishwarya Gangawane
ContentDevelopmentEditors
Lawrence Veigas
Akshada Iyer
Graphics
Abhinash Sahu
Technical Editor
Tiksha Sarang
Production Coordinator
Melwyn Dsa
Stefano Iacovella is a long-time GIS developer and consultant living in Rome, Italy. He also works as a GIS courses instructor, and he has a PhD. in Geology. Being a very curious person, he 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. In the last 14 years, he has become more and more involved with Open Source software, also integrating it with proprietary software. He loves the Open Source approach and really trusts in the collaboration and sharing of knowledge. He strongly believes in the Open Source idea and constantly manages to spread it out, not limiting it to the GIS sector. He has been using GeoServer since release 1.5 by configuring, deploying, and hacking it on several projects. Other GFOSS projects he uses and likes are GDAL/OGR, PostGIS, QGIS, and OpenLayers. He is the author of the GeoServer Cookbook, which consists of a set of recipes to use GeoServer at an advanced level, by Packt, and he has also authored the first edition of this book. When not playing with maps and geometric shapes, he loves reading about science, mainly Physics and Maths, riding his bike, and having fun with his wife and two daughters, Alice and Luisa.
Colin Henderson is a spatial solutions architect with 18 years of experience working on solutions to complex spatial problems. He is currently the Geospatial Systems Capability Lead for Atkins, one of the world's leading design, engineering, and project management consultancies. He is the Technical Architect and Lead Developer of Atkins' open source-based spatial integration platform, CIRRUSmaps™, a solution built on the best breed of open source spatial software, including PostGIS and OpenLayers, with GeoServer at its heart, and designed from the ground up for deployment in cloud environments. Colin is the author of Mastering GeoServer, also published by Packt.
A self-confessed techie, Colin enjoys digging deeper to understand technology and software, and then applying this learning to create innovative solutions to problems. He is currently working on building automated damage detection algorithms using the structured-light depth sensing equipment on iOS platforms. When possible, he likes to "pay it forward" by helping others with their problems, through contributions on GIS Stack Exchange in particular.
For support files and downloads related to your book, please visit www.PacktPub.com.
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.
www.packtpub.com/mapt
Get the most in-demand software skills with Mapt. Mapt gives you full access to all Packt books and video courses, as well as industry-leading tools to help you plan your personal development and advance your career.
Fully searchable across every book published by Packt
Copy and paste, print, and bookmark content
On demand and accessible via a web browser
Thanks for purchasing this Packt book. At Packt, quality is at the heart of our editorial process. To help us improve, please leave us an honest review on this book's Amazon page at https://www.amazon.com/dp/1788297377.
If you'd like to join our team of regular reviewers, you can e-mail us at [email protected]. We award our regular reviewers with free eBooks and videos in exchange for their valuable feedback. Help us be relentless in improving our products!
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
GIS Fundamentals
What is GIS about?
The foundation of any GIS - spatial data
Measuring the world
Moving on to the planet with decimal degree coordinates
Projecting a sphere on a plane
Understanding coordinate systems
Commonly used coordinate systems
Universal Transverse Mercator system
Web Mercator
Spatial Reference Identifier (SRID)
Exploring the EPSG registry
Representing geometrical shapes
Modelling the real world with raster data
Representing the world
Exploring OpenStreetMap
Adding more colors to your maps
Choropleth maps
Proportional maps
Making your thematic map
Summary
Getting Started with GeoServer
Installing required components
Checking presence of Java on your windows machine
Checking the presence of Java on your Linux machine
Installing JRE on your server
Installing Tomcat on your server
Configuring Tomcat as a service on Linux Mint
Installing GeoServer
Deploying GeoServer on Tomcat
Implementing basic security
Improving security settings
Understanding the GeoServer release cycle
Upgrading your installation
Summary
Exploring the Administrative Interface
Understanding the interface
The About & Status section
The Server Status link
The GeoServer Logs section
The Contact Information section
The About GeoServer section
Manually reloading the configuration
The Data section
The OpenLayers preview
The KML preview
The Services section
WMTS
WMS
WFS
WCS
Limiting the SRS list from WMS
Settings
Changing your logging configuration
Tile Caching
The Security panel
The Settings panel
Users, Groups, and Roles
Data
Catalog security
Services security
Demos
Exploring Demo requests
Filtering the projection list
Summary
Adding Your Data
Configuring your data
Configuring vector data sources
Java properties files
Adding properties files
Using shapefile
Adding shapefiles
Using PostGIS
Installing PostgreSQL and PostGIS
Loading data in PostGIS and publishing them in GeoServer
Configuring raster data sources
ArcGrid
GeoTiff
Gtopo30
ImageMosaic
WorldImage
Adding a raster
Exploring additional data sources
Using Oracle
Adding Oracle support in GeoServer
Loading data in Oracle
Summary
Accessing Layers
Web services
WMS formats
OpenLayers
Exploring the OpenLayers options
Working with tiles
Exploring further Web Map Service output formats
The AtomPub format
The GIF format
The GeoRSS format
The JPEG format
The KML (Plain) format
The KMZ (Compressed) format
The PDF format
The PNG format
The SVG format
The TIFF format
Web Feature service
The CSV format
The GeoJSON format
Parsing GeoJSON
Shapefile
Extra output options
The TEXT/HTML format
Using the GetFeatureInfo freemarker template
ImageMap
Using the WMS Reflector
Summary
Styling Your Layers
Understanding Styled Layer Descriptor (SLD)
Editing styles
Installing the CSS module
Exploring the standard structure of a style
Exploring GeoServer bundled styles
Loading data for styling
Working with point symbols
Creating a simple point style
Adding a stroke value
Dealing with angles and transparency
Composing simple shapes
Using external graphics
Composing your symbol
LineString symbols
Creating a simple line style
Adding a border and a centerline
Using hatching
Using dashed lines
Mixing dashing lines and markers
Working with polygon symbols
Creating a simple polygon style
Using a graphic filling
Using hatching with polygons
Adding labels
Labeling points
Labeling lines
Labeling polygons
Thematic mapping
Classifying roads
Setting visibility
Enhancing thematic roads maps
Putting it all together
Grouping layers
Styling with CSS
Creating a style with CSS
Summary
Creating Simple Maps
Exploring the Google Maps API
Adding a GeoServer layer as overlay
Adding a GeoServer layer as a base layer
Using OpenLayers
Integrating GeoServer and OpenLayers
Using tiled WMS
Mixing WMS and WFS
Exploring Leaflet
Creating a basic map with Leaflet
Summary
Performance and Caching
Exploring GeoWebCache
Configuring GeoWebCache
Configuring Disk Quota
Setting Caching Defaults
Direct integration
WMS-C
TMS and WMTS
Default layers options
Default Cached Gridsets
Configuring gridsets
Creating a custom gridset
Configuring Tile Layers
Configuring layers and layer groups for caching
Using tiles with OpenLayers
Seeding a layer
Using an external GeoWebCache
Summary
Automating Tasks - GeoServer REST Interface
Introducing REST
Using REST
Installing the Requests library
Managing data
Working with workspaces and namespaces
Managing workspaces
Using data stores
Managing data stores
Using feature types
Adding a new shapefile
Adding a PostGIS table
Publishing data
Working with Styles
Adding a new style
Working with Layers
Managing Layers
Administer GeoServer with REST
Managing global settings
Reloading configuration
Managing services
Summary
Securing GeoServer Before Production
Basic Security Settings
Enabling strong encryption
Changing the master password
Defining users, groups, and roles
User definition
Group definition
The Users/Groups services
Roles definition
Creating users and groups
Defining roles
Accessing data and services
Securing layers
Summary
Tuning GeoServer in a Production Environment
Tuning Java
Configuring Java runtime parameters
Installing native JAI
Removing unused services
Enabling the Marlin rasterizer
Setting a proxy
Avoiding service faults
Configuring a cluster
Summary
Going Further - Getting Help and Troubleshooting
Going beyond maps
Delivering vector data
Retrieving vector data
Delivering raster data
Retrieving raster data
Advanced configuration - Database connection pooling
Creating a connection pool
Advanced configuration - Monitoring GeoServer
Installing and configuring the monitoring extension
Getting help
Summary
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 many 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 practiced a little into something you can apply at any level to meet your needs in incorporating maps into a site. I hope you will enjoy reading this book as much as I enjoyed 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 through 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 of 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, 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 is also discussed.
Chapter 5, Accessing Layers, guides you through data publication and 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 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, Creating Simple Maps, 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.X 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. It 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. The source code and data used in this book are freely available on the Packt website.
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 into complex systems. System administrators may also find this book useful for planning installation, tuning, and maintenance.
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, and user input are shown as follows: "Under the subdirectory structure ofC:\chapter8-benchmark\src\main\java\com\packtis theMyBenchmark.javafile."
A block of code is set as follows:
http://localhost:8080/geoserver/web/wicket/bookmarkable/ org.geoserver.wms.web.data.StyleEditPage? 6&name=PopulatedPlacesBlueLabeled
Any command-line input or output is written as follows:
<display-name>GeoServer</display-name>
New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "TheEncryptionsection lets you hide web admin parameters."
Feedback from our readers is always welcome. Let us know what you think about this book-what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of. To send us general feedback, simply email [email protected], and mention the book's title in 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 at 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 this book 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 emailed directly to you. You can download the code files by following these steps:
Log in or register to our website using your email address and password.
Hover the mouse pointer on the
SUPPORT
tab at the top.
Click on
Code Downloads & Errata
.
Enter the name of the book in the
Search
box.
Select the book for which you're looking to download the code files.
Choose from the drop-down menu where you purchased this book from.
Click on
Code Download
.
Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:
WinRAR / 7-Zip for Windows
Zipeg / iZip / UnRarX for Mac
7-Zip / PeaZip for Linux
The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/GeoServer-Beginners-Guide-Second-Edition. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
We also provide you with 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 https://www.packtpub.com/sites/default/files/downloads/GeoServerBeginnersGuideSecondEdition_ColorImages.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 could 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 Errata Submission Form 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. To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.
Piracy of copyrighted 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.
If you have a problem with any aspect of this book, you can contact us at [email protected], and we will do our best to address the problem.
In this chapter, you will learn the foundation of Geographic Information System (GIS) 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 learning in this book. This chapter will introduce you to the magic of spatial data and processing.
In this chapter, we will cover the following topics:
Why spatial data is special
Spatial data formats
The magical world of
Spatial Reference System (SRS)
What is a map and why does it matter?
The art of Cartography.
By the end of this 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 many 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 way, 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 Geographic Information System. Does it sound too complicated to you? Do not be afraid; it is not so different from many other systems to manage the information you probably already know. The main difference is the spatial component 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, process, and 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 understanding of GIS is far beyond the scope of this book, and it is not required to start with GeoServer. However, you will need to have some basic skills in spatial data, maps, and spatial reference systems.
Let's go; we will 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 a poor map output.
Then what is spatial data in simple words? Let us start considering, from a general point of view, what a piece of spatial information is. Each description of an object contains a reference to its position on the Earth's surface. Although this is not a rigorous formal definition, it reminds you the mandatory requirements for any spatial data. Any spatial data should contain enough information, irrespective of its format, for determining where it is located on the earth's surface. For now we are fine with this simplistic definition.
Think of some lists of familiar objects:
A list of bookshops with addresses
A list of places you visited during your trips
A list of points of interest, for example, restaurants, museums, and hotels you collected with your mobile phone
An aerial photo with a view of a city, where you can recognize notable places
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, 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 strongly structured piece of information. If you are using your spatial data with GeoServer, you need to organize it more accurately. We will talk specifically about GeoServer's data connectors in Chapter 4, Adding Your Data, 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.
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 east or west angle from a reference meridian (for example, the one passing through Greenwich observatory) to another meridian that passes through that point. Angular measures can be expressed in decimal degrees or in degrees, minutes, and seconds.
If you want to store the location of the Statue of Liberty, you can express it in the decimal degree form, as shown here:
40.689167, -74.044444
Alternatively, you can use the degrees, minutes, and seconds form as follows:
Lat. 40° 41′ 21″ N, Long. 74° 2′ 40″ W
Consider the image of the model of the Earth given as follows:
We normally think of the Earth as a sphere, but this is not its real shape. Geodesy, the science studying the shape of the Earth, defines the Earth, as represented by a geoid, an ideal surface defined by the level of the sea if oceans were to cover all of Earth. For practical purposes, as in projections, the geoid is too complicated to use, and so the Earth 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? Do not be afraid and explore locations on Earth with latitude and longitude coordinates. In the following table, there are a few famous places with coordinates in decimal degrees. Point your browser to http://maps.google.com, insert coordinates in the search textbox, and then press Enter. Your map will shift to the location.
Google Maps enables you to query for coordinates of any place on Earth; find that function and look for some great places.
Latitude
Longitude
Place
41.890
12.492
Rome, Italy
36.055
-112.122
Colorado Grand Canyon, USA
48.858
2.294
Paris, France
-25.688
-54.442
Iguazú National Park, Argentina
-25.345
131.036
Ayers Rock, Australia
Did you ever play with an orange peel? I did it a lot when I was a child, often pressing them in the hope to flatten it almost perfectly. It's a hopeless challenge, but kids are stubborn and ambitious. Many years later, I found a similar analogy in a geography book. It was about cartographic projection and used an orange as a model of the Earth. If you think of the orange's peel as the Earth's surface, it is suddenly clear why you can't have a planar representation of Earth's surface without a great amount of distortion.
All the maps you will ever find are on a plain paper sheet. Curved digital screens are quite uncommon in GeoGeek's nests. So, how do cartographers represent a curved surface on a plane? This is done by means of a mathematical operation called projection. Consider the following image:
Indeed, there are several different projections developed in the last few centuries by cartographers and mathematicians. There is no mathematical method to transfer a sphere or an ellipsoid to a two-dimensional space without distortion. Hence, projections modify the data and include some deformations about lengths, areas, or shapes you can observe and measure on maps.
We can classify projections according to the geographical features and properties they preserve, as shown here:
Conformal projections preserve angles locally. Meridian and parallels intersect at 90-degree angles.
Equal-area projections preserve proportions between areas. In a map with equal-area projections, each part has the same proportional area as the corresponding part of the Earth.
Equidistant projections maintain a scale along one or more lines, or from one or two points to all other points on the map. Lines along which the scale (distance) is correct are of the same proportional length as the lines they refer to on the globe.
It is important that you understand there is no best projection; choosing one for your map is a trade-off. According to the portion of the earth's surface, the map that you are designing will contain and/or use the projections that suit best. Let's explore some widely-used projections.
You learned about Earth's shape and projection. Coordinate systems use these concepts to build a frame of reference to place objects on the Earth's surface. There are two types of coordinate systems: projected coordinate systems and geographic coordinate systems. Let's understand these as follows:
Geographic coordinate systems
: These use latitude and longitude as angles measured from the Earth's center, as we saw previously. A geographic coordinate system is substantially defined by the ellipsoid used to model the Earth, and the position of the ellipsoid positioned relative to the center of the Earth called the
datum
.
Projected coordinate systems
: These are defined on a flat two-dimensional surface. A projected coordinate system is always based on a geographic coordinate system; hence, it uses an ellipsoid and a datum. Besides, a projected coordinate system includes a projection method to project coordinates from the Earth's spherical surface onto a two-dimensional Cartesian coordinate plane.
Although there are hundreds of different projections, you can limit your knowledge to some that are widely used.
Commonly known as UTM, this is not really a projection. It is a system based on the Transverse Mercator projection. This projection uses a cylinder tangent to a meridian to unwrap the Earth's surface. A maximum of 5° of distortion from the central meridian is acceptable. The UTM splits the world into a series of 6° of longitudinal-wide zones. As you may guess, there are 60 zones numbered from Longitude 180W toward the east. Note that you cannot have a map representing more than one UTM zone. Indeed, UTM is well suited for large-scale maps. Consider the following image:
Web Mercator is a projection derived from Transverse Mercator. It maps ellipsoidal latitude and longitude coordinates onto a plane using Spherical Mercator equations. This projection was popularized by Google in Google Maps, and it is now widely used in online mapping systems. It stretches areas in a north-south direction and, unlike the Transverse Mercator, it is not conformal. Consider the following image:
A spatial reference system identifier is a code to easily reference a spatial reference system (SRS). An SRS contains parameters about projection, ellipsoid, and datum. It can be defined using the Open Geospatial Consortium's (OGC) well-known text (WKT) representation. The SRS for the geographic WGS84 reference system is as follows:
GEOGCS["WGS 84", DATUM["WGS_1984", SPHEROID["WGS 84",6378137,298.257223563, AUTHORITY["EPSG","7030"]], AUTHORITY["EPSG","6326"]], PRIMEM["Greenwich",0, AUTHORITY["EPSG","8901"]], UNIT["degree",0.01745329251994328, AUTHORITY["EPSG","9122"]], AUTHORITY["EPSG","4326"]]
The last line contains the number 4326; this is the SRID uniquely identifying this SRS. The long form should also contain the authority, that is EPSG:4326, but you will often find it indicated only by the number.
It is very important that you know what SRID your data is in. Without it, you can't represent data on a map without the risk of great errors.
We described a couple of common and widely used SRSs, but there are a lot of them. There are several archives on the internet where you can find detailed information about SRSs and their elements, that is ellipsoids, datums, unit of measurements, projected, or geographic reference systems. One of the most authoritative and complete data sets is the EPSG Geodetic Parameter Registry. If you are curious about it, you can open your browser and point it to http://epsg-registry.org. Then, try a simple search by inserting a location name in the Area textbox as shown in the following screenshot:
You learned how to calculate coordinates on the Earth's surface. However, how can you represent a real object, for example, a river, in a convenient way for a GIS?
There are two main approaches when building a spatial database: modeling vector data or raster data. Vector data uses a set of discrete locations to build basic geometrical shapes, such as points, polylines, and polygons. This is shown in the following image:
Of course, real objects are neither a point, nor a polyline or a polygon. In your model, you have to decide which basic shape better suits the real object. For example, a town can be represented as a point if you draw a map of the world with the countries' capitals shown. On the other hand, if you publish a countries map, a polygon will enable you to draw the city boundaries to give a more realistic representation.
The simpler geometric object is a point. Points are defined as single coordinate pairs (x,y) when we work in two-dimensional space, or coordinate triplets (x,y,z) if you want to take account of the height coordinates. In the following examples, we use point features to store the location of active volcanoes:
Name of volcano
Latitude
Longitude
Etna
37.751
37.751
Krakatoa
-6.102
105.423
Aconcagua
-32.653
-70.011
Kilimanjaro
-3.065
37.358
Did you guess the units and projections used? The coordinates are in decimal degrees and SRS is WGS84 geographic, that is, EPSG:4326.
Points are simple to understand but do not give you many details about the spatial extent of an object. If you want to store rivers, you need more than a coordinate pair. Indeed, you have to memorize an array of coordinate pairs for each feature in a structure called polyline shown as follows:
Colorado; (40.472 -105.826, ... , 31.901 -114.951) Nile; (-2.282 29.331, ... , 30.167 31.101) Danube; (48.096 8.155, ... ,45.218 29.761)
