Using USGS TNM Vector Data to Create Seamless Topographic Maps in ArcGIS

One of the most popular download on this site is how to convert USGS geopdf to geotiffs using ArcGIS.  So I started to thinking about why not use the USGS Topo Vector Data to create seamless maps that are very similar to the USGS geopdfs? Why do I want to use the USGS Topo Vector Data to create topographic maps? Because it’s a hassle and a pain in neck to get USGS GeoPDFs into a GIS, and sometimes the web mapping services just don’t cut it (e.g. resolution not good enough, limited control over styling, etc.).

This post is a follow up post to the previous, USGS TNM Style Template ArcGIS. Data for Hawaii is now available to use with the ArcGIS map document template. I like the USGS TNM Topographic maps as basemaps – it provides an informative but clean background for whatever data layers I overlay on top of it and plus most people are familiar with it. If you are looking to recreate a USGS Topographic Quadrangle maps (7.5-Minute topo quads) in ArcGIS – I suggest you follow the instructions given on the USGS site. What I want is to assemble a statewide dataset for use with the TNM style template to create a seamless USGS topo maps. You should read the USGS FAQ on using the USGS TNM style template.

Step 1: Download Datasets and TNM Style Template

So, the first step is to download the datasets needed for Hawaii and the style template.

1. A good place to look for data is here: https://viewer.nationalmap.gov/basic/ or go directly to https://viewer.nationalmap.gov/tools/topotemplate/

First you should download the TNM Style template and Topo Map Vector Data GDBs for all the 7.5-Minute quads of interest. Here I have the Topo_TNM_Style Template which contains the ArcMap map document that will be used for the styling and map making later.

Fig0002.png

Also I have downloaded all the vector data by island. Make sure you download data as file geodatabases and not shapefiles. If you know what you're doing then you can go directly to the Cloud Browse FTP site and download what you need. Unfortunately the listing of staged vector data doesn't include Hawaii so I have use the data download service instead.

Topo Vector Data for 7.5-Minute cells for Oahu

Topo Vector Data for 7.5-Minute cells for Oahu

If you look at the topo vector data GDB file you'll see that it contains the following data - shown below is a example for Pearl Harbor quad, but all the GDBs should contains the same datasets. Using this as a reference I'm going to download the statewide (Hawaii) equivalents to created my Statewide Topo Vector Data GDB.

Fig0004.png

You will need to download the following datasets:

Fig0005.png
  • GOVTUNIT_Hawaii_State_GDB.gdb - file GDB containing boundary layers for Hawaii

  • MAPINDICES_Hawaii_State_GDB.gdb - file GDB containing map indices for Hawaii. You'll want to use the 7.5-Minute map index

  • NHD_H_Hawaii_GDB.gdb - file GDB containing the National Hydro Dataset for Hawaii

  • STRUCT_Hawaii_State.GDB.gdb - file GDB containing point structures for Hawaii

  • TRAN_15_Hawaii_GU_STATEORTERRITORY.gdb - file GDB containing transportation layers for Hawaii

  • WOODLAND_15_Hawaii_GU_STATEORTERRITORY.gdb - file GDB containing woodland land use for Hawaii

For the Elevation Data - you can download the contour data directly from the Cloud Browse FTP site or use the Download GIS Data web service. Here I am using the data download service.

Fig0006.png
Fig0007.png

Step 2: Create an empty geodatabase schema

So after downloading the data I need, I going to create an empty geodatabase schema based on one of the Vector Data Quad GDB (e.g. Vector_34545_Pearl_Harbor_7_5_Min.gdb). I'm going to then load the statewide datasets into this new GDB and this will be my new Topo Vector Data GDB for Hawaii.

Export existing Vector_xxx_7_5_Min.gdb schema

1. In ArcCatalog, right click on the Vector_xxx_7_5_Min.gdb >> Export >> XML Workspace Document

2. In the Export XML Workspace window: Select only the schema to export and give the output xml a name. Click Next and make sure you Select all features to included in the export

Fig0008.png
Fig0009.png

Create a new file geodatabase with existing schema

1. In ArcCatalog, create a new file geodatabase then import the existing XML schema your exported previously (Right click on file GDB >> Import >> XML Workspace Document)

2. In the Import XML Workspacec Document, select to import only the schema

Fig0010.png

Step 3: Load Data into the New Statewide GDB

1. You should now have an empty file GDB with the proper schema to load data into.

Fig0011.png

2. In ArcCatalog start loading the corresponding statewide data into the correct feature classes. For example, here I'm going to load the features from my MAPINDICES_Hawaii_State_GDB.gdb\Cells\CellGrid_7_5Minute layer into the corresponding TopoVectorDataHawaii_2017.gdb\CELLS\CellGrid_7_5Minute layer. Right click on the feature class for which you want to load features into >> Load >> Load Data. In the Simple Data Loader window: input your parameters.

Fig0012.png
Fig0013.png
Fig0014.png
Fig0015.png

3. Use the Simple Loader method to load features into all the corresponding feature classes - exceptions below. You can load features from multiple layers -- see example below for elev_contours.

Note: For Transportation Road features the Target Fields and Matching Source Fields will not all match (some Source Fields will be blank or None) - this should be ok since the fields for display (TNMFRC) and label (FULL_STREET_NAME) match. Also the TNMDerivedNames feature class does not have a statewide equivalent (explained further below) - follow Step 3A below for a work around solution.

Fig0016.png

Step 3A: Batch Selecting and Merging TNM Derived Names Points

The USGS TNM Style guide says that "TNM Derived Names is a filtered and enriched dataset intended specifically to be used for labeling named features. TNM Derived Names data are provided only in conjunction with Topo Map Vector Data products." So there are no national or statewide data for TNMDerivedNames layer - you'll have to merged all the points from each of the Vector Quad GDB. Note that you can't just merged the points together because a quad can contain points for other adjacent quads as well so you'll end up having duplicates if you don't filter them first. What you'll need to do is select only the points in the quad of interest then do the merge so the resulting layer won't contain duplicates (see example image below:

Fig0017.png

Batch Selecting TNM Derived Names Points of Interest

The example shown here is batch selecting features for all 6 quads for Lanai.

1. Create a new file GDB for the data staging (e.g. LanaiStaging.gdb)

2. In ArcToolbox, go to Analysis Tools >> Extract >> Right click on Select >> Batch

3. In the Batch Select grid: (there are 6 quad cells so there should be 6 output feature classes)

  • Input Features: TNMDerivedNames layer from each quad

  • Setup your Environment settings to use your staging GDB as the Scratch Workspace (e.g. LanaiStaging.gdb)

  • Output Feature Class: Use the default or input a name

Fig0018.png

Here is an example for the LanaiStaging.gdb

Fig0019.png

Merging or Loading the TNMDerivedNames Output Feature Classes

After you are done with the batch feature selections, use the Simple Data Loader (right click on the target layer >> Load >> Load Data) to load in the features from your staging GDB into the TNMDerivedNames feature class. Alternatively you could also use the Merge Tool in ArcCatalog.

Fig0020.png

Once you are done with the merging or feature loading, you can then link the data sources in the TNM Style Template MXD.

Step 4: Linking Data Sources to TNM Style Template

1. Open the TNM Style Template map document (e.g. TopoTNMStyleTemplate_v10_0.mxd)

2. Modify the map document to fit your needs:

  • Delete data frames that you don't need - I only kept the Map Layers and Images Data Frames

  • Change the coordinate system of the Map Layers Data Frame

  • Set the Data Source links for layers with missing data links. Note PLSS does not exist for Hawaii.

  • Save a copy of the map document

Fig0021.png

3. "Layers" under the Images Data Frame are web services. Note that the WetlandsTopoService needs fixing (exising URL to service is doesn't work).

  • In a web browser, go to https://viewer.nationalmap.gov/services/ and scroll down to Themed Overlays  >> FWS Wetlands - Topo Symbols >> Click on REST - this should open a new page to the REST service - copy this URL up to "...services/"

Fig0022.png
  • In ArcCatalog, add this web service. Go to GIS Servers >> Add ArcGIS Server. In the Add GIS Server window: select use GIS server >> Next. Then Paste the Server URL you copied and click Finish

Fig0023.png

You should now have the FWS Wetlands Topo Services added to your GIS server in ArcCaalog - see below.

Fig0024.png

4. Back in the ArcMap document, what you have to do is remove the existing WetlandsTopoService then add it back in using the new FWS GIS Server. Note: Setting the data source/link to the existing WetlandsTopoService didn't seem to work for me - not sure why (I'm using ArcGIS Desktop 10.5.1).

Fig0027.png

5. Modify your map document and map layout to fit your needs. That's it.

Example showing a "seamless" TNM Style map -- very similar to the USGS topo quad maps

Example showing a "seamless" TNM Style map -- very similar to the USGS topo quad maps

Another example showing a more close up view with no modifications of labels or symbology - note since this is all vector data (with exception of web services) everything looks sharp and can be modified as needed.

Another example showing a more close up view with no modifications of labels or symbology - note since this is all vector data (with exception of web services) everything looks sharp and can be modified as needed.

Installing Apache, QGIS Server, and Lizmap Web Client on Windows OS

See Updated New Posting with screenshots and updated for Apache 2.4.33, QGIS Server LTR 2.18.21 and Lizmap Web Client 3.1.12

This post is my notes on the process/procedures I went through to install QGIS Server, Lizmap Web Client (Lizmap WC), and Apache on a Windows 10 x64 laptop and Windows Server 2012 R2 machine. For the most part I followed the instructions on Lizmap site, Installing Lizmap Web Client on Windows (last accessed 6/13/2017), however the instructions there seems like it hasn't been updated in a while and some things didn’t quite work as expected when I tried them. So, this blog post is my version of those instructions including notes on what I did to make all the components work. A look at the demo is shown below with notes/instructions below if you want to try it yourself. Sorry there are no screenshots.

Lizmap Web App Demo Slides

Requirements/Software used:

  • Lizmap WC and QGIS Server must be on same machine

  • QGIS Server LTR 2.14 (installed via OSGeo4W x64)

  • QGIS Desktop (installed via OSGeo4W x64)

  • Lizmap Web Plugin (installed via QGIS desktop plugin manager)

  • Lizmap Web Client 3.1.1 – download link

  • Apache 2.4

    • Mod fcgid

    • C++ Redistributable VS 2015

    • PHP 7.1

For my test on my Windows 10 laptop, I have everything on the same machine. But on the Windows Server 2012 machine, I have QGIS Desktop with Lizmap Web Plugin on a different machine. For my installation I put Apache and Lizmap side-by-side inside a C:/webserver directory. You can however, put your installations inside of Apache root directory (e.g. C:/Apache24/Lizmap) or inside Apache htdocs directory (e.g. C:/Apache24/htdocs/lizmap). If installation of lizmap and Apache are side by side or lizmap is inside Apache root directory then you need to properly configure the virtual hosts.

Part 1: Apache 2.4 Server Installation and Configuration

For more info on installing Apache on Windows, see: https://httpd.apache.org/docs/2.4/platform/windows.html#winsvc

1.       Create a webserver directory on C: Drive (e.g. C:\webserver)

2.       Go to apachelounge.com/download page

3.       Download Apache 2.4  httpd-2.4.25-win64-VC14.zip

You should read the read me file for more info on installing Apache.

4.       Download  mod_fcgid-2.3.9-win64-VC14.zip – make sure this matches you Apache download above (e.g. xxx-win64-VC14)

5.      Download C++ Redistributable VS 2015 – the link to vc_redist_x64/86.exe is broken when I tried it on 6/12/2017. You can try this link  here: https://www.microsoft.com/en-us/download/details.aspx?id=52685

Note: The Visual C Redistributable Package is needed to run Apache HTTPD as a Windows Service but the version required will depend on which binary you are installing: If you are installing Apache 2.4 VC14 then you need Microsoft Visual Studio C 2015 Redistributable

6.       Install C++ VS 2015 (vc_redist.x64.exe) that you downloaded.

7.       Unzip or extract from httpd-2.4.25-win64-VC14.zip\Apache24 directory to C: \webserver folder (e.g. C:\webserver\Apache24)

8.       Unzip or extract from mod_fcgid-2.3.9-win64-VC14.zip\mod_fcgid-2.3.9\mod_fcgid.so to C:\webserver\Apcahce24\modules folder

9.       Open the Apache configuration file: C:\webserver\Apache24\conf\httpd.conf in a text editor (I use Notepad++)

  • Replace all occurrences of c:/Apache24 to c:/webserver/Apache24

  • Find “ServerName” – this should be ServerName localhost:80 (if using default port 80) or if not using default port then it should be ServerName localhost:port (e.g. ServerName localhost:90)

  • Change the default port if needed. Find “Listen 80” to Listen port (e.g. Listen 90). You need to use a port that is not already in used by another service.

  • Find “DirectoryIndex index.html” and add index.php (e.g. DirectoryIndex index.html index.php)

  • Save and close the file when done

10.   Check to see is Apache will start:

  • Open the Command Prompt window: type cmd and run it as administrator

  • Command window: Type in C:\webserver\Apache24\bin\httpd.exe

  • Notice of Windows Firewall popup: Allow Access for All

Note from Lizmap Installation docs: If a popup didn’t display, it probably means you have an anti-virus software managing your firewall in which case you will need to allow the Apache service. Also you may need to add port 80 or whatever port you use as inbound/outbound port in Advanced Windows Firewall Properties (Control Panel >> Administrative Tools >> Windows Firewall with Advanced Security)

Note: On Windows 10 laptop the popup showed and on Windows Server 2012 R2 I didn’t get a popup. However, when I opened http:localhost in web browser it works.

  • Open a web browser and type in http://localhost if using default port 80 or localhost:port if using a different port (e.g. http://localhost:90)

You should see a webpage with “It Works” – this means Apache is installed correctly

  • Back in the Command Prompt window: Crtl + C to stop Apache. This may take a few seconds.

11.   Append Apache to your Windows System Path so you can directly access Apache by typing httpd.exe instead of the full path to the exe.

12.   Start Apache as windows service: https://httpd.apache.org/docs/2.4/platform/windows.html#winsvc

  • In Command Prompt window: cmd (as administrator)

  • To install Apache as a service: httpd.exe -k install

  • Check windows services to see that Apache in installed and started

  • Stop Apache for now if it’s started – you’ll configure it and then restart later

13.   Open the Apache configuration file: C:\webserver\Apache24\conf\httpd.conf in a text editor. Enable the following modules by uncommenting or removing the # character.

Note: if you don’t see the module already in the file then you need to type it in

  • LoadModule actions_module modules/mod_actions.so

  • LoadModule deflate_module modules/mod_deflate.so

  • LoadModule expires_module modules/mod_expires.so

  • LoadModule ext_filter_module modules/mod_ext_filter.so

  • LoadModule fcgid_module modules/mod_fcgid.so

  • LoadModule headers_module modules/mod_headers.so

  • LoadModule ident_module modules/mod_ident.so

  • LoadModule rewrite_module modules/mod_rewrite.so

  • LoadModule ssl_module modules/mod_ssl.so

Note: If you are using a different port than the default 80 then you need to also enable these modules as well.

  • LoadModule cache_module modules/mod_cache.so

  • LoadModule cache_disk_module modules/mod_cache_disk.so

  • LoadModule proxy_module modules/mod_proxy.so

  • LoadModule proxy_connect_module modules/mod_proxy_connect.so

  • LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so

  • LoadModule proxy_http_module modules/mod_proxy_http.so

Add the following code to the end of the httpd configuration file:

<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\\.0[678] no-gzip
BrowserMatch \\bMSIE !no-gzip !gzip-only-text/html
SetEnvIfNoCase Reuqest_URI \\.(?:gif|jpe?g|png|rar|zip)$ no-gzip dont-vary
Header append Vary User-Agent env=!dont-vary
</IfModule>

14.   Save the changes to httpd.conf file then restart Apache

Part 2: PHP 7.1 Configuration

Note: Lizmap Web Client require at least PHP version 5.4. Also make sure you use the non-thread safe file

1.       Go to PHP downloads page and download the appropriate file for your OS and Apache version installed earlier – I install VC14 x64 non-thread safe file, php-7.1.6-nts-Win32-VC14-x64.zip

2.       Unzip or extract the zipped file contents to your php directory (e.g. C:\webserver\php-7.1). Create the php folder if you need to inside the main webserver directory)

3.       Make a backup copy of C:\webserver\php-7.1\php.ini-production just in case. Then rename it to php.ini

4.       Open C:\webserver\php-7.1\php.ini in a text editor

  • Uncomment out the extension_dir = “ext” to say the following (this is the path to your php ext folder) extension_dir = "C:\webserver\php-7.1\ext"

  • Enable the following php modules:

    •  extension=php_curl.dll

    • extension=php_fileinfo.dll

    • extension=php_gd2.dll

    • extension=php_mbstring.dll

    • extension=php_pdo_pgsql.dll

    • extension=php_pdo_sqlite.dll

    • extension=php_pgsql.dll

    • extension=php_sqlite3.dll

  • Find where it says upload_max_filesize and change to 15M

  • Find where it says post_max_size and change to 15M

5.       Save the php.ini file

6.       Add PHP to your Windows System Path

7.       Open Command Prompt window: check PHP is correctly declared in System Path. Type php-m

8.       In Command Prompt window: check Apache configuration. Type httpd -S

9.       Create a php configuration in Apache for using PHP.

  • Open a new file in a text editor then put in the following code:

FcgidInitialEnv PHPRC "C:\\webserver\\php-7.1"
 <FilesMatch \\.php$>
AddHandler fcgid-script .php
FcgidWrapper "C:/webserver/php-7.1/php-cgi.exe" .php
</FilesMatch>
  • Save the file as php-7.1.conf in C:\webserver\Apache24\conf\extra

10.       Open C:\webserver\Apache24\conf\httpd.conf in text editor

  •  Uncomment out the line to include virtual host configuration file and save the file

 Include conf/extra/httpd-vhosts.conf

11.       Open C:\webserver\Apache24\conf\extra\httpd-vhosts.conf in text editor

At the end of the file copy and paste following code:

Note: change the port if using something other than 80

<VirtualHost *:80>
  Include conf/extra/php-7.1.conf
  ServerName localhost
  DocumentRoot "C:/webserver/lizmap/"

  <Directory "C:/webserver/lizmap">
  Options -Indexes +FollowSymLinks +ExecCGI
  AllowOverride All
  Require all granted
 </Directory>

 CustomLog "logs/lizmap-access.log" common
 ErrorLog "logs/lizmap-error.log"
</VirtualHost>

12.       Create Lizmap folder inside the webserver directory (e.g. C:\webserver\lizmap)

13.       Create a text file with the following code and save as index.php inside lizmap directory (e.g. C:\webserver\lizmap\index.php)

php <?php phpinfo(); ?>

14.       Restart Apache service

15.       Open a web browser and type in http://localhost/index.php (don’t forget to include the port if you are using something other than default 80 – e.g. http://localhost:90/index.php)

You should get a webpage with the PHP information.

          Note: If you are getting a 403 Forbidden Access Error. Open the C:\webserver\Apache24\conf\httpd.conf

In a text editor and change the access permission to your server’s filesystem to Require all granted. Save the file and restart Apache service then try to access index.php again.

Fig01.png

Part 3: QGIS Server Installation and Configuration

I installed QGIS Server using OSGeo4W installer x64 version – download on QGIS site or on OSGeo4W site. Lizmap Web Client doesn’t work properly with the newer versions of QGIS Server, so you must use the LTR 2.14.

Note: When I installed QGIS desktop and server LTR 2.14 via the Advanced Setup – I had issues with QGIS starting up properly (something about missing components), even though the installation itself didn’t give me any errors. So I uninstalled and started fresh with Express Setup first then Advanced Setup and that resolved my issues.

Express Setup

  • Run the installer: Select Express Setup

  • Install from Internet

  • Root Directory: use default (C:\OSGeo4W64) and install for all users

  • Keep default Local Package Directory and Start Menu Name

  • Select the Packages: GDAL, Grass, QGIS Desktop

  • Install software dependencies required and let installation complete.

Advanced Setup

  • Run the installer again: Select Advance Setup

  • Install from Internet

  • Keep Root Directory default and install for all users

  • Keep default Local Package Directory and Start Menu Name

  • Select these Packages:

    • Commandline_Utilities: GDAL

    • Desktop: QGIS LTR 2.14 full

    • Libs: fcgi

    • Optional Lib: filegdb (only if you want to be able to use ESRI's file gdb)

    • Web: QGIS Server LTR 2.14

  • Resolve Unmet Dependencies: Install the required dependencies, accept license agreements, and allow installation to complete

  • After installation completes, check in C:\OSGeo4W64\apps\qgis-ltr\bin folder to make sure these files are in there.

    • qgis_mapserv.fcgi.exe

    • qgis_server.dll

    • wms_metadata.xml

Part 4: QGIS Server Configuration

1.       Open C:\webserver\Apache24\conf\extra\httpd-vhosts.conf in text editor and modified to contain this content:

Note: change host port if needed if other then 80

<VirtualHost *:80>
 Include conf/extra/php-7.1.conf
ServerName localhost

# Lizmap Production
DocumentRoot "C:/webserver/lizmap/prod/"
<Directory "C:/webserver/lizmap/prod/">
 Options -Indexes +FollowSymLinks +ExecCGI
AllowOverride All
Require all granted
</Directory>

# LizMap Pre-production
Alias /preprod/ "C:/webserver/lizmap/preprod/"
<Directory "C:/webserver/lizmap/preprod/">
Options -Indexes +FollowSymLinks +ExecCGI
AllowOverride All
Require all granted
</Directory>

Alias /qgis/ "C:/OSGeo4W64/apps/qgis-ltr/bin/"
<Directory "C:/OSGeo4W64/apps/qgis-ltr/bin/">
SetHandler fcgid-script
Options +ExecCGI
AllowOverride All
Require all granted
</Directory>

Alias /document/ "C:/webserver/data/document/"
<Directory "C:/webserver/Data/document/">
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>

CustomLog "logs/lizmap-access.log" common
ErrorLog "logs/lizmap-error.log"
</VirtualHost>

2.       Save changes in file

3.       Open C:/webserver/Apache24/conf/extra/php-7.1.conf and modify to contain this content:

FcgidInitialEnv PHPRC "C:\\webserver\php-7.1"

FcgidInitialEnv PATH "C:\OSGeo4W64\bin;C:\OSGeo4W64\apps\qgis-ltr\bin;C:\OSGeo4W64\apps\grass\grass-7.2.1\lib;C:\OSGeo4W64\apps\grass\grass-7.2.1\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\WBem"
FcgidInitialEnv QT_PLUGIN_PATH "C:\OSGeo4W64\apps\qgis-ltr\qtplugins;C:\OSGeo4W64\apps\Qt4\plugins"
FcgidInitialEnv PYTHONHOME "C:\OSGeo4W64\apps\Python27"
FcgidInitialEnv PYTHONPATH "C:\OSGeo4W64\apps\qgis-ltr\.\python;C:\OSGeo4W64\apps\qgis-ltr\.\python\plugins;C:\OSGeo4W64\apps\Python27\DLLs;C:\OSGeo4W64\apps\Python27\lib;C:\OSGeo4W64\bin;C:\OSGeo4W64\apps\Python27;C:\OSGeo4W64\apps\Python27\lib\site-packages"

FcgidInitialEnv QGIS_SERVER_LOG_LEVEL 0
FcgidInitialEnv QGIS_SERVER_LOG_FILE "C:\\webserver\\Apache24\\logs\\qgis_server.log"

FcgidIOTimeout 120
  FcgidInitialEnv LC_ALL "en_US.UTF-8"
  FcgidInitialEnv PYTHONIOENCODING UTF-8
  FcgidInitialEnv LANG "en_US.UTF-8"
  FcgidInitialEnv QGIS_DEBUG 1
  FcgidInitialEnv QGIS_SERVER_LOG_FILE "C:\\webserver\Apache24\logs\\qgis_server.log"
  FcgidInitialEnv QGIS_SERVER_LOG_LEVEL 0
  FcgidInitialEnv QGIS_PLUGINPATH "C:\OSGeo4W64\apps\qgis-ltr\python\plugins"

SetEnvIf Request_URI ^/qgis QGIS_PREFIX_PATH "C:\OSGeo4W64\apps\qgis-ltr"
SetEnvIf Request_URI ^/qgis TEMP "C:\Windows\Temp"

SetEnvIf Request_URI ^/qgis GDAL_DATA "C:\OSGeo4W64\share\gdal"
SetEnvIf Request_URI ^/qgis GDAL_DRIVER_PATH "C:\OSGeo4W64\bin"
SetEnvIf Request_URI ^/qgis PDAL_DRIVER_PATH "C:\OSGeo4W64\bin"
SetEnvIf Request_URI ^/qgis GDAL_SKIP "JP2ECW"
SetEnvIf Request_URI ^/qgis PROJ_LIB "C:\OSGeo4W64\share\proj"

<FilesMatch \.php$>
AddHandler fcgid-script .php
FcgidWrapper "C:/webserver/php-7.1/php-cgi.exe" .php
</FilesMatch>

4.       Save the file

5.       Restart Apache service

6.       Open a web browser and type in http://localhost/qgis/qgis_mapserv.fcgi.exe - include the port after localhost if you’re using something different than the default port (e.g. http://localhost:90/qgis/qgis_mapserv.fcgi.exe )

You will most likely get a page where it says Service unknown or unsupported

Try typing in the following in a browser:

http://localhost:90/qgis/qgis_mapserv.fcgi.exe?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities

http://localhost:90/qgis/qgis_mapserv.fcgi.exe?SERVICE=WMS&REQUEST=GetCapabilities

If you get something back that isn’t an error then you are ok – means QGIS Server installed properly and you can call WMS Get Capabilities

Part 5: Lizmap Web Client Installation and Configuration

Using Lizmap Web Client 3.1.1 Other versions like 3.0.x or Master did not work for me. When I did install version 3.0.x the Lizmap demo site wouldn’t load in the web browser. Also for this portion I have several directories and subfolders for production and preproduction work on my server.  

1.       Download Lizmap Web Client – I used lizmap-web-client-3.1.1.zip.

2.       Create in C:\webserver\lizmap directoy, 2 new folders for your production and preproduction work

C:\webserver\lizmap\prod

C:\webserver\lizmap\preprod

3.       Create in C:\webserver directory a new cache directory to hold 2 new subfolders: prod and preprod

C:\webserver\cache\prod

C:\webserver\cache\preprod

4.       Unzip or extract lizmap-web-client-3.1.1.zip to C:\webserver\lizmap\prod directory. So what you end up having is C:\webserver\lizmap\prod\lizmap-web-client-3.1.1

5.       Open C:/webserver/Apache24/conf/extra/httpd-vhosts.conf in text editor and modified the section to the virtual host to point to C:/webserver/lizmap/prod/lizmap-web-client-3.1.1/lizmap/www folder

Note: change host port if needed if other then 80

<VirtualHost *:80>
Include conf/extra/php-7.1.conf
 ServerName localhost

# Lizmap Production
DocumentRoot " C:/webserver/lizmap/prod/lizmap-web-client-3.1.1/lizmap/www/"
<Directory " C:/webserver/lizmap/prod/lizmap-web-client-3.1.1/lizmap/www/">
Options -Indexes +FollowSymLinks +ExecCGI
AllowOverride All
Require all granted
</Directory>

# LizMap Pre-production
Alias /preprod/ "C:/webserver/lizmap/preprod/lizmap-web-client-3.1.1/lizmap/www/"
<Directory "C:/webserver/lizmap/preprod/lizmap-web-client-3.1.1/lizmap/www/">
Options -Indexes +FollowSymLinks +ExecCGI
AllowOverride All
Require all granted
</Directory>

6.       Save your changes

7.       Restart Apache service

8.       Open the Command Prompt window (run as Administrator) and type in the following lines:

cd C:\\webserver\\lizmap\\prod\\lizmap-web-client-3.1.1\\
cd lizmap/var/config
copy lizmapConfig.ini.php.dist lizmapConfig.ini.php
copy localconfig.ini.php.dist localconfig.ini.php
copy profiles.ini.php.dist profiles.ini.php
cd ../../..

9.       Keep the Command Prompt window open.

10.   Open C:\webserver\lizmap\prod\lizmap311\lizmap\var\config\ localconfig.ini.php in a text editor and include the following code (if you want to install the lizmap demo websites) – make sure you have admin rights to modify and save this file (e.g. run notepad++ as Administrator then modify and save changes).

[modules]
lizmap.installparam=demo

11.   Save your changes and close file

12.   Back in the Command Prompt window:  launch lizmap installation. After installation completes, close the command prompt window.

cd C:\webserver\lizmap\prod\lizmap-web-client-3.1.1\
php lizmap/install/installer.php

14.   In the Lizmap home page, click the Connect button on the top right - or go to http://localhost/admin.php

  • Login with default username = admin, password = admin

  • Change password

  • Lizmap Configuration menu: Modify the input as follows and then Save new configuration

  • WMS Server URL: http://127.0.0.1/qgis/qgis_mapserv.fcgi.exe

  • Cache root directory: C:/webserver/cache/prod/

15.   From the Administrator page, you can click on the Project and view the Montpellier – Transport demo. Click Load the Map button. Or you can just type in http://localhost/index.php/view/map/?repository=montpellier&project=montpellier

You should see the demo Montpellier web application.

16.   If you go to your website: http://xx.xx.xx/index.php you should also be able to see the demo application.

Lizmap Folder Organization (optional)

1.       Create Lizmap directories for organizing production and preproduction work. Create the directories via a *.bat file (e.g. write the following lines into a text editor and save as with .bat extension, such as CreateLZDir.bat). The examples below are directories for a main webapp directory with subfolders for map repositories in a prod and preprod environments.

mkdir C:\webserver\webapp\common\
mkdir C:\webserver\webapp\document\
mkdir C:\webserver\webapp\document\svg\
mkdir C:\webserver\webapp\prod\
mkdir C:\webserver\webapp\prod\maprep\
mkdir C:\webserver\webapp\prod\maprep\data
mkdir C:\webserver\webapp\prod\maprep\data\vector
mkdir C:\webserver\webapp\prod\maprep\data\raster
mkdir C:\webserver\webapp\prod\maprep\media\
mkdir C:\webserver\webapp\prod\maprep\media\js\
mkdir C:\webserver\webapp\prod\maprep\media\image\
mkdir C:\webserver\webapp\preprod
mkdir C:\webserver\webapp\preprod\maprep\
mkdir C:\webserver\webapp\preprod\maprep\data
mkdir C:\webserver\webapp\preprod\maprep\data\vector
mkdir C:\webserver\webapp\preprod\maprep\data\raster
mkdir C:\webserver\webapp\preprod\maprep\media\
mkdir C:\webserver\webapp\preprod\maprep\media\js\
mkdir C:\webserver\webapp\preprod\maprep\media\image\

2.       Save your *.bat file (e.g. createDir.bat) and then run it in the Command Prompt window.

  • In the Command Prompt window: cd into your directory that contains the *.bat file

  • Run the *.bat file

SVG and QGIS Server Bug:

I’m not sure if this still holds true or not, but not a bad idea to do it. 

In Apache you need to Add a vhost to publish SVG and images files via HTTP this will avoid the bug in QGIS Server under Windows which cannot display SVG icon when you have a relative path. Create a folder to contain the svg files then modify C:/webserver/Apache24/conf/extra/httpd-vhosts.conf . Add the codes before the CustomLog portion.

Alias /document/ "C:/webserver/webapp/document/"
<Directory "C:/webserver/webapp/document/">
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>

Save and restart Apache service. Check if you can add svg file in the folder C:/webserver/webapp/document/svg then access it via http://localhost/document/svg/my_icon.svg and use it as the SVG path in the style properties of a vector layer.

After you have the installation set up, see the LizWeb Map Client Documentation on how to create your maps in QGIS and web application.