Skip to content

Latest commit

 

History

History
92 lines (62 loc) · 2.79 KB

geoserver-layer-management.md

File metadata and controls

92 lines (62 loc) · 2.79 KB

GeoServer Layer Management

Environments

NYU has the following GeoServer instances:

Staging

Production

Convert Shapefile into GeoServer Layer

This section show you how to make a shapefile available as a GeoServer layer via a PostGIS table.

For these steps you will need the following tools installed:

On macOS you can install these using Homebrew:

$ brew install gdal
$ brew install postgis
$ brew install postgresql

Re-project Vector Data to EPSG:4326 (WGS84)

First we need to re-project the vector data to EPSG:4326 (WGS84).

To view the Shapefile's current CRS, use the following command and look for the SOURCECRS entry.

$ ogrinfo -so -al original.shp 

To re-project the Shapefile to EPSG:4326 use the following command:

$ ogr2ogr -t_srs EPSG:4326 -lco ENCODING=UTF-8 reprojected.shp original.shp

Convert Shapefile to SQL Statements

Next we need to convert our Shapefile into a file of SQL statements that will create a table and populate it with records:

$ shp2pgsql -I -s 4326 reprojected.shp table_name > table_name.sql

Import Vector Data into PostGIS

Finally, we run the SQL file against the PostGIS database:

$ psql --host=HOSTNAME_HERE --username=USERNAME_HERE --dbname=geospatial_data --file=table_name.sql

Publish a PostGIS Table as a GeoServer Layer

After logging into your desired GeoServer instance, do the following:

  1. Under Data click on Layers.
  2. Click on Add a new layer.
  3. In Add layer from select sdr:vector_postgis.
  4. In the list of available layers, filter for the layer you want to add.
  5. Click Publish next to the layer you want to publish.
  6. Scroll down to Bounding Boxes:
    1. For Native Bounding Box click Compute from data.
    2. For Lat/Lon Bounding Box click Compute from native bounds.
  7. Click Save.
  8. In the sidebar click on Layer Review.
  9. Search for your layer in the resulting list.
  10. Click on OpenLayers in that result's row.

Unpublish a GeoServer Layer

After logging into your desired GeoServer instance, do the following:

  1. Under Data click on Layers.
  2. Use the search box to find the Layer you want to remove
  3. Check the box in the first column of the row.
  4. Click Remove selected layers.
  5. Click OK in the confirmation dialog.