SlideShare a Scribd company logo
GIS Solution
With Open-Source GIS Solutions
Geoserver
QGIS
Openlayers
Prepared By : Keshav Sharma www.keshavsharma.ml
Pre-Requisites
 Geoserver with Jetty Web Server (2.15.1 Latest)
 SQL Server with SQL Server Management Studio
 NodeJS
 JAVA JDK(have JRE embedded) and JRE 8+
 Visual Studio (Any version) as Code IDE
 QGIS 3
 Shape2SQL / GDAL
 USA Zip ShapeData
 Openlayer3 CLI-npm
Prepared By : Keshav Sharma www.keshavsharma.ml
Geoserver Section Hierarchy
Geoserver
Workspace 1
Store 1.1
Layer 1.1
Layer 1.2
Layer 1.x
Workspace 2
Store 2.1
Layer 2.1
Layer 2.2
Layer 2.x
Workspace X
Store X.1
Store X.2
Store X.3
Prepared By : Keshav Sharma www.keshavsharma.ml
Geoserver
 Go to :http://localhost:8080/geoserver/web
 Login with your credentials: Default Being:
UserID: admin
Password:geoserver
 In Geoserver we have 3 major sections:
1. Workspaces
2. Stores
3. Layers
 Workspaces : This section is the home of all the activities and every Geo-
related object is added and manipulated inside this section.
This wraps the Layers and data-stores under one roof.
Each workspace can have one or more sources and multiple layers.
Prepared By : Keshav Sharma www.keshavsharma.ml
Geoserver
 Stores : This section deals with Shape data which will be rendered and
processed by Geoserver.
A Store can be a Database (SQL Server, POSTGIS, Oracle, etc.) or
It can be a File Based Data (ESRI Shapefile). This is the fuel for Geoserver.
A Store is a collection of Layers
 Layers : This section is the basic unit of Shape Hierarchy.
It is the actual DataTable or ShapeFile which contains geometry data and will
be rendered and processed by Geoserver at elementary level.
This section actually is the basis of Projection of Geometry Data in form of 2D
Vector/Tiled/ Image data.
Prepared By : Keshav Sharma www.keshavsharma.ml
Geoserver : Creating Workspace
 Go to Data->Workspaces -> Add New Workspace
 Enter the Workspace Name (Any String depicting your workspace)
 Enter Namespace URI – Any URI corresponding to Workspace we are creating
for. If you don’t have any URI u can just enter a simple String in this section
Prepared By : Keshav Sharma www.keshavsharma.ml
Geoserver : Creating Store
 Go To : Data-> Stores->Add New Store
 Select the Data-Source you are interested in:
 By default, Only PostGIS is supported. For SQL Server, we need to add
Plugin(explained in later slides)
Prepared By : Keshav Sharma www.keshavsharma.ml
Connect To DB
 We have out-of-the-box support for POSTGRE in Geoserver but we can also add support to MS
SQL Server with official supported Plugins “Microsoft JDBC Connection Plugins”.
 We need to get spatial data for Polygon shape and Datadots
 Installing the SQL Server extension
 GeoServer files
 Download the SQL Server extension from the GeoServer download page.
 Warning Make sure to match the version of the extension to the version of the GeoServer
instance!
 Extract the contents of the archive into the WEB-INF/lib directory of the GeoServer
installation.
 Restart the GeoServer to load the extension.
 Microsoft files
 Navigate to the download page for Microsoft JDBC Drivers for SQL Server.
 Extract the contents of the archive.
 Copy the file sqljdbc4.jar to the WEB-INF/lib directory of the GeoServer installation.
 If GeoServer is installed on Windows, additionally copy authx86sqljdbc_auth.dll and
xax86sqljdbc_xa.dll to C:WindowsSystem32.
Prepared By : Keshav Sharma www.keshavsharma.ml
Connect to DB continued
 So if all steps are followed properly, we will see SQL Server option in
Geoserver ->New Stores -> Microsoft SQL Server
Prepared By : Keshav Sharma www.keshavsharma.ml
Connect to SQL-DB
 Basic Store Infos:
Select the Workspace from the dropdown box
Data Source Name : Database of SQL Server having Geometry Data
 Connection Parameters:
dbtype* : sqlserver (auto-populated)
host* : localhost (if your SQL Server and Geoserver are on same
machine)
else, enter the IP address of the sql-server.
Port : 1433 (Default Port Used by SQL Server. Remember to open
TCP/IP connection for SQL Server in “SQL Server Configuration
Setting”.
Database : blank
Schema : blank
User* : sql login userID
passwd : sql login password
* means mandatory field
Prepared By : Keshav Sharma www.keshavsharma.ml
Connect to SQL DB ….. continued
Prepared By : Keshav Sharma www.keshavsharma.ml
Adding Layer in Geoserver
 Select Layers from left navigation panel
 Select “Add Layers”->select “Workspace:Store” from dropdown.
 On selecting desired store, you will see all the tables available in the
Database you are targeting. (Screenshot for reference).
Prepared By : Keshav Sharma www.keshavsharma.ml
Adding Layer in Geoserver …… Continued
 On clicking on Publish, you will be redirected to “Edit Layer” page.
 Only Bounding Boxes needs to be
tickled a bit, rest configuration is
kept as it is.
 Click on “Compute from Data” to
compute “Native Bounding Boxes”.
 Again click on “Compute from
native bounds” to compute
“Lat/Lon Bounding Box”.
 Finally, click on
Save button at the
bottom and
You are done.
 Now you can see your
published Layer in
Layers section.
Prepared By : Keshav Sharma www.keshavsharma.ml
Geoserver : Layer Preview
 Go to “Data”->Layer Preview.
 You will get a list of Layers which are published on Geoserver till now.
 You can click on Openlayers to have a rendered preview of your published
layer
Output formats supported by Openlayer. You can
also get shapefile from the published Layer
Prepared By : Keshav Sharma www.keshavsharma.ml
Troubleshooting
 Sometimes, on clicking Openlayers in “Layer Preview Section” you will get
some “wms” file downloaded with no extension. This means there is some
problem with Layers.
 The most obvious problem can be default style definition.
 To fix this: Go to Layers->select layer having issue. This will open Edit Layer
Page.
 Select “Publishing” Tab. Scroll down to WMS Setting-> Layer Setting.
 There You will see default style as “generic”.
 Change it to “Giant Polygon” or your custom created SLD file from QGIS.
 Hurray… Issue is fixed. Now you can go to preview layer and selecting
openlayer will give you rendered view of ShapeData.
Prepared By : Keshav Sharma www.keshavsharma.ml
Troubleshooting… Continued
 Now you will se something like this:
Prepared By : Keshav Sharma www.keshavsharma.ml
Few tips to remember……..
 You have to open TCP/IP connectivity and port (say, 1433) from SQL
configuration Tool Manager.
 Do remember to place the jar files(explained in previous slide) before
proceeding.
 A point to remember : Vectors layers are feature layers.
 If encountered with CORS error, just refer next slide for resolution.
 Do remember to update Java.exe path in Startup.bat file and change port
from 8080 to anything like 8899 if 8080 is already occupied.
Prepared By : Keshav Sharma www.keshavsharma.ml
Changing Default Port in Geoserver - The
way I Did: for v2.10 or above
 Open Start.ini in the root directory of Geoserver installation
 Search for 8080 and replace it by desired Port(greater that 1024), say 8899.
 Similarly go to bin/start.bat and perform same replacement of 8080 with
8899.
 Now restart the Geoserver and Go to:
https://localhost:8899/web/geoserver
https://<local-ipaddress>:8899/web/geoserver
Prepared By : Keshav Sharma www.keshavsharma.ml
CORS Error - Resolved
 You might face CORS related error while getting the GeoJSON Data or feature
layer. To rectify this:
Go to : C:Program Files (x86)GeoServer 2.15.0webappsgeoserverWEB-
INFweb.xml.
 You will see commented code as below, just uncomment it and you are done.
 <!-- Uncomment following filter to enable CORS <filter> <filter-name>cross-
origin</filter-name> <filter-
class>org.eclipse.jetty.servlets.CrossOriginFilter</filter-class> <init-param>
<param-name>chainPreflight</param-name> <param-value>false</param-
value> </init-param> <init-param> <param-
name>allowedOrigins</param-name> <param-value>*</param-value>
</init-param> <init-param> <param-name>allowedMethods</param-
name> <param-value>GET,POST,PUT,DELETE,HEAD,OPTIONS</param-value>
</init-param> <init-param> <param-name>allowedHeaders</param-
name> <param-value>*</param-value> </init-param> </filter> -->
Prepared By : Keshav Sharma www.keshavsharma.ml
Tips Continued (Only if any issue occurred)
 Install the JRE according to the instructions included with the release.*
 Set an environment variable JAVA_HOME to the pathname of the directory into which you installed the JDK.
 (1) Download and install the GeoServer binaryThere is more help available at the GeoServer home page (http://geoserver.org) *
Download a binary distribution of GeoServer
 For the purposes of the remainder of this document, the symbolic name GEOSERVER_HOME is used to refer to the directory
where GeoServer resides.
 (2) Start Up GeoServerThere are two techniques by which GeoServer can be started:*
 Use an environment variable: - Set an environment variable GEOSERVER_HOME to the path of the directory into which you
have installed GeoServer. -
Execute the shell command:
Windows: %GEOSERVER_HOME%binstartup
UNIX: $GEOSERVER_HOME/bin/startup.sh*
 Modify your current working directory: - Execute the following shell commands:
Windows: cd %GEOSERVER_HOME%bin startup
UNIX: cd $GEOSERVER_HOME/bin ./startup.sh
 After startup, the default web administration tool included with GeoServer will be available by browsing:
http://localhost:8080/
 (3) Troubleshooting : There are two common problems encountered when attempting to use the binary distribution of
GeoServer:
(a) Another web server (or other process) is already using port 8080. This is the default HTTP port that GeoServer attempts
to bind to at startup.
 (4) Further informationFor more information about configuring and running GeoServer, please see the GeoServer web site:
http://geoserver.org/
Prepared By : Keshav Sharma www.keshavsharma.ml
QGIS
 QGIS is a open-source desktop application supporting Geospatial data
rendering and other Spatial Operations.
 You can use “Browser” to Open and
Render ShapeData.
 You can use File System to open .shp
files. (eg., C:/, D:/)
 Or you can use DB connection (eg.,
SQL, Oracle, POSTGIS) to fetch the
ShapeData from DB.
 To connect to SQL, you need to enter:
1. Name: Any String to name the
Connection.
2. Host: SQLServer Name or IP of the server.
3 .User ID and Password: SQL User credentials
Prepared By : Keshav Sharma www.keshavsharma.ml
How to create SQL-Connection in QGIS
Prepared By : Keshav Sharma www.keshavsharma.ml
Rendering Shape Data on QGIS
 Once the connection to SQL Geo-Database is successful we can simply Add the
Geo-Table as a layer in QGIS and it will start rendering in the View-Space.
Prepared By : Keshav Sharma www.keshavsharma.ml
Rendering Shape Data on QGIS
 You can also use ESRI shapefile (.shp) and render it in QGIS
Prepared By : Keshav Sharma www.keshavsharma.ml
What we have achieved till now….
 Installing and setting up Geoserver and QGIS with SQL server as Geo-
DB
 Connecting Geoserver to SQL Server
 Creating Workspace->Stores->Layers in Geoserver
 Publishing Shape Data to Geoserver and previewing in Layer Preview.
 Connecting QGIS to SQL Server and File System(out-of-the-box
support)
 Rendering Shape Data on QGIS using :
Geodata from DB.
Geodata from ESRI-ShapeFile.
Prepared By : Keshav Sharma www.keshavsharma.ml
Dissolving Layers in QGIS
 Dissolving is a process of clubbing different divisions of shape into single one
on a specific dissolve criteria.
 We can have a layer of State created from District layer by dissolving on the
basis of StateName. For Example, All districts of Goa will be having a column
“State Name” as Goa and hence on dissolving on “State Name” basis we will
get a single shape of Goa.
 So in this way we can create multiple layers of different levels, say town,
city, districts, states, country, continents, world.
Prepared By : Keshav Sharma www.keshavsharma.ml
Dissolving Layers in QGIS ……. continued
 First select the layer you want to dissolve.
 Go To: Vector Tab -> Geoprocessing Tools -> Dissolve
 A dissolve dialog box will appear.
 Select the input layer:
indiandistricts
 Uncheck Dissolve All
 Select Unique ID field:
State(field which is criteria
for dissolve)
 Select output path and you
are done.
Prepared By : Keshav Sharma www.keshavsharma.ml
Styling Layers in GeoServer: Symbology
 Go to : Right Click on Layer you want to add style to.
 Select “Style” in the Layer Properties.
 Change dropdown from “Single Symbol”
to “Categorized”.
 Select “Column” value to categorize the
shape-data. I used State Name for this.
 Click on Classify and Random colors will
be assigned to each distinct State name.
 To save this, click on Save Style and it in
.sld format. This format will be fed to
Geoserver as style.
Prepared By : Keshav Sharma www.keshavsharma.ml
Styling Layers in GeoServer: Symbology
 This sld file will be consumed in Geoserver.
 I saved it as StyleDemo.sld
 Go to : Data-> Style-> Add New Style -> Upload a style file
 Select Workspace and select “sld” style file.
 I will select StyleDemo.sld and it will auto-populate the Name.
 At the bottom, Apply and submit.
 Now select the newly created style ad go to “Publishing” and select
the layer for which you want to add style to. You are Done.
Below is the layer with our created style.
Prepared By : Keshav Sharma www.keshavsharma.ml
Shape to SQL and Vice Versa
 You can convert shape files to Datatables in SQL Server and vice versa by
below mentioned tools:
 Shape2SQL :Untested CommandLine support.
https://www.sharpgis.net/page/shape2sql
 Ogr2Ogr : Bundled with QGIS and most stable among all. It is a command line
tool.
https://www.npmjs.com/package/ogr2ogr
If you have QGIS installed, you will have ogr2ogr.exe in bin folder og QGIS
installation. For me it was present @ C:Program FilesQGIS Brightonbin
Prepared By : Keshav Sharma www.keshavsharma.ml
Shape to SQL and Vice Versa… Continued
 SQL to Shape
 ogr2ogr -f "ESRI Shapefile" “<shape file fully qualifying name>" "MSSQL:server=<SQL Server IP or
Name>;database=<Database Name>;trusted_connection=yes;"-sql “<Select cols1,cols2,etc from
tablename>” -overwrite
 Example 1:
ogr2ogr -f "ESRI Shapefile" "C:tempx.shp" " Server" -sql "SELECT
ogr_fid,oMSSQL:server=Keshav/sqlexpress;database=webPortal;trusted_connection=yes;driver=SQLgr
_geometry,dst_id,district,state FROM indianstates" -overwrite
 Example 2:
ogr2ogr -f "ESRI Shapefile" "C:tempx.shp"
"MSSQL:server=Keshavsqlexpress;database=geoDatabase;trusted_connection=yes;driver=SQL Server"
-sql "SELECT OBJECTID, Shape, ZIP, PO_NAME, STATE, SUMBLKPOP, POP2008,POP08_SQMI, SQMI,
POSTCODE FROM US_ZIP_POLYGON" –overwrite
---------------------------------------------------------------------------------------------------------------------------
 Shape to SQL
 ogr2ogr -f "MSSQLSpatial"
"MSSQL:server=<SERVERNAME>;database=<DATABASENAME>;trusted_connection=yes;driver=SQL
Server" "D:TempMWAYS.shp" -overwrite -SkipFailures -nln "UK_Motorways" -lco PRECISION=NO -
progress
Prepared By : Keshav Sharma www.keshavsharma.ml
Join in QGIS
 You can Join metadata to spatial data-tables.
 For example, You can add more column on the Spatial Data table using join on
particular key( column value).
 Thereafter we can use particular Column to Dissolve Shape.
 Like, dissolve the district layer on the basis of states to get the State spatial
data.
Prepared By : Keshav Sharma www.keshavsharma.ml
Congratulations……..
 So Now we have achieved basic functionality of Geoserver, QGIS and how to
utilize it for Map Creation
 We can now:
 Create dissolved Layers
 Add styles to layers
 Publish map to geoserver.
 If you found this Helpful. Please give a thumps up. It will motivate us to do
more stuff like this.
Prepared By : Keshav Sharma www.keshavsharma.ml
Prepared By : Keshav Sharma www.keshavsharma.ml

More Related Content

What's hot (11)

PDF
SQL Track: Restoring databases with powershell
ITProceed
 
PDF
fast_bitcoin_data_mining
Jason Papapanagiotakis
 
PPTX
SQL Server vs Postgres
chandra sekhar pathivada , PMP,ITIL,MCTS
 
PDF
Scaling Twitter 12758
davidblum
 
PPTX
Rally - Benchmarking_as_a_service - Openstack meetup
Ananth Padmanabhan
 
DOC
Schema replication using oracle golden gate 12c
uzzal basak
 
PPTX
DBCC - Dubi Lebel
sqlserver.co.il
 
PDF
Pluggable database tutorial 2
Osama Mustafa
 
PDF
New Flash Builder 4 WSDL and HTTP Connectors
rtretola
 
ODP
Common schema my sql uc 2012
Roland Bouman
 
TXT
Oracle11g notes
Manish Mudhliyar
 
SQL Track: Restoring databases with powershell
ITProceed
 
fast_bitcoin_data_mining
Jason Papapanagiotakis
 
Scaling Twitter 12758
davidblum
 
Rally - Benchmarking_as_a_service - Openstack meetup
Ananth Padmanabhan
 
Schema replication using oracle golden gate 12c
uzzal basak
 
DBCC - Dubi Lebel
sqlserver.co.il
 
Pluggable database tutorial 2
Osama Mustafa
 
New Flash Builder 4 WSDL and HTTP Connectors
rtretola
 
Common schema my sql uc 2012
Roland Bouman
 
Oracle11g notes
Manish Mudhliyar
 

Similar to Geoserver GIS Mapping Solution (20)

PDF
GEOSERVER - DOWNLOAD AND INSTALLATION STEP BY STEP TUTORIAL
Sohail Akbar Goheer
 
PDF
Mastering Geoserver Colin Henderson Henderson Colin
alwayssn
 
PPTX
GeoServer Feature Frenzy
Jody Garnett
 
PDF
GeoServer Feature FRENZY
GeoSolutions
 
PDF
Fossgis 2013 GeoServer Presentation
GeoSolutions
 
PDF
GeoServer Ecosystem 2018
Jody Garnett
 
PDF
Geoserver rest: Python package for managing spatial data
Tek Kshetri
 
PDF
GeoServer, The Open Source Solution for the interoperable management of geo...
GeoSolutions
 
PPTX
Geoserver introduction, GeoBusiness 2015
GeoSolutions
 
PPT
Foss4g2009tokyo Cholmes Gs Og Jp
OSgeo Japan
 
PPTX
Geospatial information materials sv.pptx
2031qq028
 
PPTX
My experience and suggestions as a web-GIS developer
Tek Kshetri
 
PDF
Using GeoServer with NASA WorldWind
Ilya Rosenfeld
 
PDF
GeoServer Past Present Future 2009
Justin Deoliveira
 
PDF
GeoServer Orientation
Jody Garnett
 
PPT
Open Source GIS
Joe Larson
 
PDF
Scaling_GeoServer_in_the_cloud__clustering_state_of_the_art.pdf
NebojsaKuduz1
 
PPTX
GIS User to Web-GIS Developer Journey
Tek Kshetri
 
PDF
State of GeoServer 2013 (FOSS4G)
Jody Garnett
 
ODP
Mapping, GIS and geolocating data in Java @ JAX London
Joachim Van der Auwera
 
GEOSERVER - DOWNLOAD AND INSTALLATION STEP BY STEP TUTORIAL
Sohail Akbar Goheer
 
Mastering Geoserver Colin Henderson Henderson Colin
alwayssn
 
GeoServer Feature Frenzy
Jody Garnett
 
GeoServer Feature FRENZY
GeoSolutions
 
Fossgis 2013 GeoServer Presentation
GeoSolutions
 
GeoServer Ecosystem 2018
Jody Garnett
 
Geoserver rest: Python package for managing spatial data
Tek Kshetri
 
GeoServer, The Open Source Solution for the interoperable management of geo...
GeoSolutions
 
Geoserver introduction, GeoBusiness 2015
GeoSolutions
 
Foss4g2009tokyo Cholmes Gs Og Jp
OSgeo Japan
 
Geospatial information materials sv.pptx
2031qq028
 
My experience and suggestions as a web-GIS developer
Tek Kshetri
 
Using GeoServer with NASA WorldWind
Ilya Rosenfeld
 
GeoServer Past Present Future 2009
Justin Deoliveira
 
GeoServer Orientation
Jody Garnett
 
Open Source GIS
Joe Larson
 
Scaling_GeoServer_in_the_cloud__clustering_state_of_the_art.pdf
NebojsaKuduz1
 
GIS User to Web-GIS Developer Journey
Tek Kshetri
 
State of GeoServer 2013 (FOSS4G)
Jody Garnett
 
Mapping, GIS and geolocating data in Java @ JAX London
Joachim Van der Auwera
 
Ad

Recently uploaded (20)

PPTX
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
PPTX
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PDF
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
PPTX
Tally software_Introduction_Presentation
AditiBansal54083
 
PDF
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
PDF
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
PPTX
Human Resources Information System (HRIS)
Amity University, Patna
 
PDF
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
PPTX
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
PDF
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
PDF
Online Queue Management System for Public Service Offices in Nepal [Focused i...
Rishab Acharya
 
PDF
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
PDF
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
PPTX
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PDF
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
PDF
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PPTX
Migrating Millions of Users with Debezium, Apache Kafka, and an Acyclic Synch...
MD Sayem Ahmed
 
PPTX
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
Tally software_Introduction_Presentation
AditiBansal54083
 
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
Human Resources Information System (HRIS)
Amity University, Patna
 
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
Online Queue Management System for Public Service Offices in Nepal [Focused i...
Rishab Acharya
 
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
Migrating Millions of Users with Debezium, Apache Kafka, and an Acyclic Synch...
MD Sayem Ahmed
 
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
Ad

Geoserver GIS Mapping Solution

  • 1. GIS Solution With Open-Source GIS Solutions Geoserver QGIS Openlayers Prepared By : Keshav Sharma www.keshavsharma.ml
  • 2. Pre-Requisites  Geoserver with Jetty Web Server (2.15.1 Latest)  SQL Server with SQL Server Management Studio  NodeJS  JAVA JDK(have JRE embedded) and JRE 8+  Visual Studio (Any version) as Code IDE  QGIS 3  Shape2SQL / GDAL  USA Zip ShapeData  Openlayer3 CLI-npm Prepared By : Keshav Sharma www.keshavsharma.ml
  • 3. Geoserver Section Hierarchy Geoserver Workspace 1 Store 1.1 Layer 1.1 Layer 1.2 Layer 1.x Workspace 2 Store 2.1 Layer 2.1 Layer 2.2 Layer 2.x Workspace X Store X.1 Store X.2 Store X.3 Prepared By : Keshav Sharma www.keshavsharma.ml
  • 4. Geoserver  Go to :http://localhost:8080/geoserver/web  Login with your credentials: Default Being: UserID: admin Password:geoserver  In Geoserver we have 3 major sections: 1. Workspaces 2. Stores 3. Layers  Workspaces : This section is the home of all the activities and every Geo- related object is added and manipulated inside this section. This wraps the Layers and data-stores under one roof. Each workspace can have one or more sources and multiple layers. Prepared By : Keshav Sharma www.keshavsharma.ml
  • 5. Geoserver  Stores : This section deals with Shape data which will be rendered and processed by Geoserver. A Store can be a Database (SQL Server, POSTGIS, Oracle, etc.) or It can be a File Based Data (ESRI Shapefile). This is the fuel for Geoserver. A Store is a collection of Layers  Layers : This section is the basic unit of Shape Hierarchy. It is the actual DataTable or ShapeFile which contains geometry data and will be rendered and processed by Geoserver at elementary level. This section actually is the basis of Projection of Geometry Data in form of 2D Vector/Tiled/ Image data. Prepared By : Keshav Sharma www.keshavsharma.ml
  • 6. Geoserver : Creating Workspace  Go to Data->Workspaces -> Add New Workspace  Enter the Workspace Name (Any String depicting your workspace)  Enter Namespace URI – Any URI corresponding to Workspace we are creating for. If you don’t have any URI u can just enter a simple String in this section Prepared By : Keshav Sharma www.keshavsharma.ml
  • 7. Geoserver : Creating Store  Go To : Data-> Stores->Add New Store  Select the Data-Source you are interested in:  By default, Only PostGIS is supported. For SQL Server, we need to add Plugin(explained in later slides) Prepared By : Keshav Sharma www.keshavsharma.ml
  • 8. Connect To DB  We have out-of-the-box support for POSTGRE in Geoserver but we can also add support to MS SQL Server with official supported Plugins “Microsoft JDBC Connection Plugins”.  We need to get spatial data for Polygon shape and Datadots  Installing the SQL Server extension  GeoServer files  Download the SQL Server extension from the GeoServer download page.  Warning Make sure to match the version of the extension to the version of the GeoServer instance!  Extract the contents of the archive into the WEB-INF/lib directory of the GeoServer installation.  Restart the GeoServer to load the extension.  Microsoft files  Navigate to the download page for Microsoft JDBC Drivers for SQL Server.  Extract the contents of the archive.  Copy the file sqljdbc4.jar to the WEB-INF/lib directory of the GeoServer installation.  If GeoServer is installed on Windows, additionally copy authx86sqljdbc_auth.dll and xax86sqljdbc_xa.dll to C:WindowsSystem32. Prepared By : Keshav Sharma www.keshavsharma.ml
  • 9. Connect to DB continued  So if all steps are followed properly, we will see SQL Server option in Geoserver ->New Stores -> Microsoft SQL Server Prepared By : Keshav Sharma www.keshavsharma.ml
  • 10. Connect to SQL-DB  Basic Store Infos: Select the Workspace from the dropdown box Data Source Name : Database of SQL Server having Geometry Data  Connection Parameters: dbtype* : sqlserver (auto-populated) host* : localhost (if your SQL Server and Geoserver are on same machine) else, enter the IP address of the sql-server. Port : 1433 (Default Port Used by SQL Server. Remember to open TCP/IP connection for SQL Server in “SQL Server Configuration Setting”. Database : blank Schema : blank User* : sql login userID passwd : sql login password * means mandatory field Prepared By : Keshav Sharma www.keshavsharma.ml
  • 11. Connect to SQL DB ….. continued Prepared By : Keshav Sharma www.keshavsharma.ml
  • 12. Adding Layer in Geoserver  Select Layers from left navigation panel  Select “Add Layers”->select “Workspace:Store” from dropdown.  On selecting desired store, you will see all the tables available in the Database you are targeting. (Screenshot for reference). Prepared By : Keshav Sharma www.keshavsharma.ml
  • 13. Adding Layer in Geoserver …… Continued  On clicking on Publish, you will be redirected to “Edit Layer” page.  Only Bounding Boxes needs to be tickled a bit, rest configuration is kept as it is.  Click on “Compute from Data” to compute “Native Bounding Boxes”.  Again click on “Compute from native bounds” to compute “Lat/Lon Bounding Box”.  Finally, click on Save button at the bottom and You are done.  Now you can see your published Layer in Layers section. Prepared By : Keshav Sharma www.keshavsharma.ml
  • 14. Geoserver : Layer Preview  Go to “Data”->Layer Preview.  You will get a list of Layers which are published on Geoserver till now.  You can click on Openlayers to have a rendered preview of your published layer Output formats supported by Openlayer. You can also get shapefile from the published Layer Prepared By : Keshav Sharma www.keshavsharma.ml
  • 15. Troubleshooting  Sometimes, on clicking Openlayers in “Layer Preview Section” you will get some “wms” file downloaded with no extension. This means there is some problem with Layers.  The most obvious problem can be default style definition.  To fix this: Go to Layers->select layer having issue. This will open Edit Layer Page.  Select “Publishing” Tab. Scroll down to WMS Setting-> Layer Setting.  There You will see default style as “generic”.  Change it to “Giant Polygon” or your custom created SLD file from QGIS.  Hurray… Issue is fixed. Now you can go to preview layer and selecting openlayer will give you rendered view of ShapeData. Prepared By : Keshav Sharma www.keshavsharma.ml
  • 16. Troubleshooting… Continued  Now you will se something like this: Prepared By : Keshav Sharma www.keshavsharma.ml
  • 17. Few tips to remember……..  You have to open TCP/IP connectivity and port (say, 1433) from SQL configuration Tool Manager.  Do remember to place the jar files(explained in previous slide) before proceeding.  A point to remember : Vectors layers are feature layers.  If encountered with CORS error, just refer next slide for resolution.  Do remember to update Java.exe path in Startup.bat file and change port from 8080 to anything like 8899 if 8080 is already occupied. Prepared By : Keshav Sharma www.keshavsharma.ml
  • 18. Changing Default Port in Geoserver - The way I Did: for v2.10 or above  Open Start.ini in the root directory of Geoserver installation  Search for 8080 and replace it by desired Port(greater that 1024), say 8899.  Similarly go to bin/start.bat and perform same replacement of 8080 with 8899.  Now restart the Geoserver and Go to: https://localhost:8899/web/geoserver https://<local-ipaddress>:8899/web/geoserver Prepared By : Keshav Sharma www.keshavsharma.ml
  • 19. CORS Error - Resolved  You might face CORS related error while getting the GeoJSON Data or feature layer. To rectify this: Go to : C:Program Files (x86)GeoServer 2.15.0webappsgeoserverWEB- INFweb.xml.  You will see commented code as below, just uncomment it and you are done.  <!-- Uncomment following filter to enable CORS <filter> <filter-name>cross- origin</filter-name> <filter- class>org.eclipse.jetty.servlets.CrossOriginFilter</filter-class> <init-param> <param-name>chainPreflight</param-name> <param-value>false</param- value> </init-param> <init-param> <param- name>allowedOrigins</param-name> <param-value>*</param-value> </init-param> <init-param> <param-name>allowedMethods</param- name> <param-value>GET,POST,PUT,DELETE,HEAD,OPTIONS</param-value> </init-param> <init-param> <param-name>allowedHeaders</param- name> <param-value>*</param-value> </init-param> </filter> --> Prepared By : Keshav Sharma www.keshavsharma.ml
  • 20. Tips Continued (Only if any issue occurred)  Install the JRE according to the instructions included with the release.*  Set an environment variable JAVA_HOME to the pathname of the directory into which you installed the JDK.  (1) Download and install the GeoServer binaryThere is more help available at the GeoServer home page (http://geoserver.org) * Download a binary distribution of GeoServer  For the purposes of the remainder of this document, the symbolic name GEOSERVER_HOME is used to refer to the directory where GeoServer resides.  (2) Start Up GeoServerThere are two techniques by which GeoServer can be started:*  Use an environment variable: - Set an environment variable GEOSERVER_HOME to the path of the directory into which you have installed GeoServer. - Execute the shell command: Windows: %GEOSERVER_HOME%binstartup UNIX: $GEOSERVER_HOME/bin/startup.sh*  Modify your current working directory: - Execute the following shell commands: Windows: cd %GEOSERVER_HOME%bin startup UNIX: cd $GEOSERVER_HOME/bin ./startup.sh  After startup, the default web administration tool included with GeoServer will be available by browsing: http://localhost:8080/  (3) Troubleshooting : There are two common problems encountered when attempting to use the binary distribution of GeoServer: (a) Another web server (or other process) is already using port 8080. This is the default HTTP port that GeoServer attempts to bind to at startup.  (4) Further informationFor more information about configuring and running GeoServer, please see the GeoServer web site: http://geoserver.org/ Prepared By : Keshav Sharma www.keshavsharma.ml
  • 21. QGIS  QGIS is a open-source desktop application supporting Geospatial data rendering and other Spatial Operations.  You can use “Browser” to Open and Render ShapeData.  You can use File System to open .shp files. (eg., C:/, D:/)  Or you can use DB connection (eg., SQL, Oracle, POSTGIS) to fetch the ShapeData from DB.  To connect to SQL, you need to enter: 1. Name: Any String to name the Connection. 2. Host: SQLServer Name or IP of the server. 3 .User ID and Password: SQL User credentials Prepared By : Keshav Sharma www.keshavsharma.ml
  • 22. How to create SQL-Connection in QGIS Prepared By : Keshav Sharma www.keshavsharma.ml
  • 23. Rendering Shape Data on QGIS  Once the connection to SQL Geo-Database is successful we can simply Add the Geo-Table as a layer in QGIS and it will start rendering in the View-Space. Prepared By : Keshav Sharma www.keshavsharma.ml
  • 24. Rendering Shape Data on QGIS  You can also use ESRI shapefile (.shp) and render it in QGIS Prepared By : Keshav Sharma www.keshavsharma.ml
  • 25. What we have achieved till now….  Installing and setting up Geoserver and QGIS with SQL server as Geo- DB  Connecting Geoserver to SQL Server  Creating Workspace->Stores->Layers in Geoserver  Publishing Shape Data to Geoserver and previewing in Layer Preview.  Connecting QGIS to SQL Server and File System(out-of-the-box support)  Rendering Shape Data on QGIS using : Geodata from DB. Geodata from ESRI-ShapeFile. Prepared By : Keshav Sharma www.keshavsharma.ml
  • 26. Dissolving Layers in QGIS  Dissolving is a process of clubbing different divisions of shape into single one on a specific dissolve criteria.  We can have a layer of State created from District layer by dissolving on the basis of StateName. For Example, All districts of Goa will be having a column “State Name” as Goa and hence on dissolving on “State Name” basis we will get a single shape of Goa.  So in this way we can create multiple layers of different levels, say town, city, districts, states, country, continents, world. Prepared By : Keshav Sharma www.keshavsharma.ml
  • 27. Dissolving Layers in QGIS ……. continued  First select the layer you want to dissolve.  Go To: Vector Tab -> Geoprocessing Tools -> Dissolve  A dissolve dialog box will appear.  Select the input layer: indiandistricts  Uncheck Dissolve All  Select Unique ID field: State(field which is criteria for dissolve)  Select output path and you are done. Prepared By : Keshav Sharma www.keshavsharma.ml
  • 28. Styling Layers in GeoServer: Symbology  Go to : Right Click on Layer you want to add style to.  Select “Style” in the Layer Properties.  Change dropdown from “Single Symbol” to “Categorized”.  Select “Column” value to categorize the shape-data. I used State Name for this.  Click on Classify and Random colors will be assigned to each distinct State name.  To save this, click on Save Style and it in .sld format. This format will be fed to Geoserver as style. Prepared By : Keshav Sharma www.keshavsharma.ml
  • 29. Styling Layers in GeoServer: Symbology  This sld file will be consumed in Geoserver.  I saved it as StyleDemo.sld  Go to : Data-> Style-> Add New Style -> Upload a style file  Select Workspace and select “sld” style file.  I will select StyleDemo.sld and it will auto-populate the Name.  At the bottom, Apply and submit.  Now select the newly created style ad go to “Publishing” and select the layer for which you want to add style to. You are Done. Below is the layer with our created style. Prepared By : Keshav Sharma www.keshavsharma.ml
  • 30. Shape to SQL and Vice Versa  You can convert shape files to Datatables in SQL Server and vice versa by below mentioned tools:  Shape2SQL :Untested CommandLine support. https://www.sharpgis.net/page/shape2sql  Ogr2Ogr : Bundled with QGIS and most stable among all. It is a command line tool. https://www.npmjs.com/package/ogr2ogr If you have QGIS installed, you will have ogr2ogr.exe in bin folder og QGIS installation. For me it was present @ C:Program FilesQGIS Brightonbin Prepared By : Keshav Sharma www.keshavsharma.ml
  • 31. Shape to SQL and Vice Versa… Continued  SQL to Shape  ogr2ogr -f "ESRI Shapefile" “<shape file fully qualifying name>" "MSSQL:server=<SQL Server IP or Name>;database=<Database Name>;trusted_connection=yes;"-sql “<Select cols1,cols2,etc from tablename>” -overwrite  Example 1: ogr2ogr -f "ESRI Shapefile" "C:tempx.shp" " Server" -sql "SELECT ogr_fid,oMSSQL:server=Keshav/sqlexpress;database=webPortal;trusted_connection=yes;driver=SQLgr _geometry,dst_id,district,state FROM indianstates" -overwrite  Example 2: ogr2ogr -f "ESRI Shapefile" "C:tempx.shp" "MSSQL:server=Keshavsqlexpress;database=geoDatabase;trusted_connection=yes;driver=SQL Server" -sql "SELECT OBJECTID, Shape, ZIP, PO_NAME, STATE, SUMBLKPOP, POP2008,POP08_SQMI, SQMI, POSTCODE FROM US_ZIP_POLYGON" –overwrite ---------------------------------------------------------------------------------------------------------------------------  Shape to SQL  ogr2ogr -f "MSSQLSpatial" "MSSQL:server=<SERVERNAME>;database=<DATABASENAME>;trusted_connection=yes;driver=SQL Server" "D:TempMWAYS.shp" -overwrite -SkipFailures -nln "UK_Motorways" -lco PRECISION=NO - progress Prepared By : Keshav Sharma www.keshavsharma.ml
  • 32. Join in QGIS  You can Join metadata to spatial data-tables.  For example, You can add more column on the Spatial Data table using join on particular key( column value).  Thereafter we can use particular Column to Dissolve Shape.  Like, dissolve the district layer on the basis of states to get the State spatial data. Prepared By : Keshav Sharma www.keshavsharma.ml
  • 33. Congratulations……..  So Now we have achieved basic functionality of Geoserver, QGIS and how to utilize it for Map Creation  We can now:  Create dissolved Layers  Add styles to layers  Publish map to geoserver.  If you found this Helpful. Please give a thumps up. It will motivate us to do more stuff like this. Prepared By : Keshav Sharma www.keshavsharma.ml
  • 34. Prepared By : Keshav Sharma www.keshavsharma.ml