index.rst 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. .. _geopkg_quickstart:
  2. Publishing a GeoPackage
  3. =======================
  4. This tutorial walks through the steps of publishing a GeoPackage with GeoServer.
  5. .. note:: This tutorial assumes that GeoServer is running at ``http://localhost:8080/geoserver``.
  6. Data preparation
  7. ----------------
  8. First let's gather that the data that we'll be publishing.
  9. #. The sample data folder includes :file:`data/ne/natural_earth.gpkg`
  10. #. This file contains small scale 1:110m data:
  11. * `coastlines <https://www.naturalearthdata.com/downloads/110m-physical-vectors/110m-coastline/>`__
  12. * `countries <https://www.naturalearthdata.com/downloads/110m-cultural-vectors/110m-admin-0-countries/>`__
  13. * `boundary lines <https://www.naturalearthdata.com/downloads/110m-cultural-vectors/110m-admin-0-boundary-lines/>`__
  14. * `populated places <https://www.naturalearthdata.com/downloads/110m-cultural-vectors/110m-populated-places/>`__
  15. .. note:: This :file:`data/ne/natural_earth.gpkg` file has been processed from https://www.naturalearthdata.com/downloads/ page, to download the original (much larger) file visit the above page and download `GeoPackage <https://naciscdn.org/naturalearth/packages/natural_earth_vector.gpkg.zip>`__ link.
  16. Creating a new workspace
  17. ------------------------
  18. The next step is to create a workspace for the geopackage. A workspace is a folder used to group similar layers together.
  19. .. note:: This step is optional if you'd like to use an existing workspace. Usually, a workspace is created for each project, which can include stores and layers that are related to each other.
  20. #. In a web browser, navigate to ``http://localhost:8080/geoserver``.
  21. #. Log into GeoServer as described in the :ref:`logging_in` section.
  22. #. Navigate to :menuselection:`Data --> Workspaces`.
  23. .. figure:: /data/webadmin/img/data_workspaces.png
  24. Workspaces page
  25. #. Click the :guilabel:`Add new workspace` button to display the :guilabel:`New Workspace` page.
  26. #. You will be prompted to enter a workspace :guilabel:`Name` and :guilabel:`Namespace URI`.
  27. .. list-table::
  28. :header-rows: 1
  29. * - Field
  30. - Value
  31. * - Name:
  32. - :kbd:`tutorial`
  33. * - Namespace URI
  34. - :kbd:`http://localhost:8080/geoserver/tutorial`
  35. .. note:: A workspace name is an identifier describing your project. It must not exceed ten characters or contain spaces.
  36. .. note:: A Namespace URI (Uniform Resource Identifier) can usually be a URL associated with your project with an added trailing identifier indicating the workspace. The Namespace URI filed does not need to resolve to an actual valid web address.
  37. #. Press the :guilabel:`Submit` button.
  38. .. figure:: images/workspace.png
  39. New workspace
  40. #. The ``tutorial`` workspace will be added to the :guilabel:`Workspaces` list.
  41. Create a store
  42. --------------
  43. Once the workspace is created, we are ready to add a new store. The store tells GeoServer how to connect to the geopackage.
  44. #. Navigate to :menuselection:`Data-->Stores`.
  45. .. figure:: images/stores.png
  46. Stores page
  47. #. This page displays a list of stores, including the type of store and the workspace that the store belongs to.
  48. #. In order to add the geopackage, you need to create a new store. Click the :guilabel:`Add new Store` button. You will be redirected to a list of the data sources supported by GeoServer. Note that the data sources are extensible, so your list may look slightly different.
  49. .. figure:: images/stores_new.png
  50. New data source
  51. #. From the list of :guilabel:`Vector Data Sources` locate and click the :guilabel:`GeoPackage` link.
  52. The :guilabel:`New Vector Data Source` page will display.
  53. #. Begin by configuring the :guilabel:`Basic Store Info`.
  54. .. list-table::
  55. :header-rows: 1
  56. * - Field
  57. - Value
  58. * - workspace
  59. - ``tutorial``
  60. * - Data Source Name
  61. - ``NaturalEarth``
  62. * - Description
  63. - ``GeoPackage of NaturalEarth data``
  64. This information is internal to GeoServer and is not used as part of the web service protocols. We recommend keeping the :guilabel:`Data Source Name` simple as they will be used to form folders in the data directory (so keep any operating system restrictions on character use in mind).
  65. .. figure:: images/basic.png
  66. Basic Store info
  67. #. Connection parameters are used to establish the connection with your database. As GeoPackage is a file based database this will primarily consist of the geopackage location.
  68. #. Under :guilabel:`Connection Parameters`, browse to the location :guilabel:`URL` of the geopackage, in our example :file:`data/ne.shp`.
  69. .. figure:: images/connection_browse.png
  70. :width: 75%
  71. Browse database location
  72. #. The :guilabel:`Connection Parameters` for our geopackage are:
  73. .. list-table::
  74. :header-rows: 1
  75. * - Field
  76. - Value
  77. * - Database
  78. - ``file:data/ne/natural_earth.gpkg``
  79. * - Read only
  80. - checked
  81. The use of :guilabel:`read_only` above indicates that we will not be writing to this GeoPackage, allowing GeoServer to avoid managing write locks when accessing this content for greater performance.
  82. .. figure:: images/connection.png
  83. Connection Parameters
  84. #. Press :guilabel:`Save`.
  85. #. You will be redirected to the :guilabel:`New Layer` page (as this is the most common next step when adding a new data store).
  86. Creating a layer
  87. ----------------
  88. Now that we have connected to the GeoPackage, we can publish the layer.
  89. #. On the :guilabel:`New Layer` page, click :guilabel:`Publish` beside the ``countries`` :guilabel:`layer name`.
  90. .. figure:: images/layer_new.png
  91. New Layer
  92. #. The :guilabel:`Edit Layer` page defines the data and publishing parameters for a layer.
  93. .. figure:: images/layer.png
  94. Edit Layer Data tab
  95. #. There are three critical pieces of information required on the :guilabel:`Data` tab before we can even save.
  96. * :guilabel:`Basic Resource Info` - describes how the layer is presented to others
  97. * :guilabel:`Coordinate Reference System` - establishes how the spatial data is to be interpreted or drawn on the world
  98. * :guilabel:`Bounding Boxes` - establishes where the dataset is located in the world
  99. #. Locate :guilabel:`Basic Resource Info` and define the layer:
  100. .. list-table::
  101. :header-rows: 1
  102. * - Field
  103. - Value
  104. * - Name
  105. - ``countries``
  106. * - Title
  107. - `Countries`
  108. * - Abstract
  109. - ``Sovereign states``
  110. The naming of a layer is important, and while GeoServer does not offer restrictions many of the individual protocols will only work with very simple names.
  111. .. figure:: images/layer_basic.png
  112. Basic Resource Info
  113. #. Double check the :guilabel:`Coordiante Reference Systems` information is correct.
  114. .. list-table::
  115. :header-rows: 1
  116. * - Field
  117. - Value
  118. * - Native SRS
  119. - ``EPSG:4326``
  120. * - Declaired SRS
  121. - ``EPSG:4326``
  122. * - SRS Handling
  123. - ``Force declared``
  124. .. figure:: images/layer_crs.png
  125. Coordinate Reference Systems
  126. #. Locate :guilabel:`Bounding Boxes` and generate the layer's bounding boxes by clicking the :guilabel:`Compute from data` and then :guilabel:`Compute from native bounds` links.
  127. .. figure:: images/layer_bbox.png
  128. Generating bounding boxes
  129. #. Press :guilabel:`Apply` to save your work thus far without closing the page.
  130. This is a good way to check that your information has been entered correctly, GeoServer will provide a warning if any required information is incomplete.
  131. #. Scroll to the top of the page and navigate to the :guilabel:`Publishing` tab.
  132. #. Locate the :guilabel:`WMS Settings` heading, where we can set the style.Ensure that the :guilabel:`Default Style` is set to ``polygon```.
  133. .. figure:: images/layer_style.png
  134. WMS Settings
  135. #. Press :guilabel:`Save` to complete your layer edits.
  136. Previewing the layer
  137. --------------------
  138. In order to verify that the ``tutorial:countries`` layer is published correctly, we can preview the layer.
  139. #. Navigate to the :menuselection:`Data > Layer Preview` page and find the ``tutorial:countries`` layer.
  140. .. note:: Use the :guilabel:`Search` field with :kbd:`tutorial` as shown to limit the number of layers to page through.
  141. .. figure:: images/preview.png
  142. Layer Preview
  143. #. Click the :guilabel:`OpenLayers` link in the :guilabel:`Common Formats` column.
  144. #. An OpenLayers map will load in a new tab and display the shapefile data with the default line style.
  145. You can use this preview map to zoom and pan around the dataset, as well as display the attributes of features.
  146. .. figure:: images/openlayers.png
  147. Preview map of countries