Skip to content

Uploading a shapefile to the GeoServer

Heather Baier edited this page Jan 29, 2024 · 1 revision
  1. Once you have saved the file in shapefile format, upload it to the server's myshapefile folder using the following command in a terminal on your local machine: scp <path_to_local_file> globaled@globaleducationobservatory.org:/home/globaled/myshapefile An example would be: scp /Users/heatherbaier/Desktop/test/slv.zip globaled@globaleducationobservatory.org:/home/globaled/myshapefile

  2. Log into the server and change into the myshapefile directory

ssh globaled@globaleducationobservatory.org
cd myshapefile
  1. Unzip the zipfile you just uploaded: unzip <zip_file_name> -d <new_folder_to_extract_to> An example would be: unzip slv.zip -d slv

  2. Delete the zipfile rm slv.zip

  3. Switch into the new folder you just extract to cd slv

  4. Upload the file to the PostGIS database using the shp2pgsql command: shp2pgsql -s 4326 <ISO> <ISO> | psql -d globaled_geo An example would be: shp2pgsql -s 4326 slv slv | psql -d globaled_geo This command will halt until you enter the password and then it will upload the file. It is doen when it prints the message: "ANALYZE"

  5. Log into the GeoServer at globaleducationobservatory.org/geoserver. Get the username and password from Heather and login.

  6. In the Data section on the left-hand sidebar, click on 'Layers'

  7. Choose 'Add new layer"

  8. In the dropdown labeled 'Add a layer from' choose 'geo:GEO_PostGIS'

  9. Next to the layer name you just uploaded, click 'Publish'

  10. In the 'Data' tab, scroll down to the 'Bounding Boxes' section and click on 'Compute from native bounds' under 'Lat/Lon Bounding Box'. Two boxes will populate with bounding box information.

  11. Scroll backup and under the 'Publishing' tab click on the dropdown labeled 'Default Style' and select 'geo:school' (you have to scroll up a bit in the dropdown to find it)

  12. At the bottom of the screen, click on 'Save'. The file is snow fully loaded!

  13. To double check everything looks okay, go to 'Layer Preview' under the 'Data' section int he left-hand sidebar. Next to the layer you just uploaded, click on 'OpenLayers'. The map should render in a new tab!

Clone this wiki locally