1

So I've taken over a project from two other programmers as a part of my internship and I'm having a little trouble pinpointing why a part of it isn't working properly.

The website itself is a very simple bland site with an openlayers map and three buttons. One button is linked to geoserver, where I can fill in the name of the shapefile (*.shp) that I want to load and then it should load the shapefile data onto the openlayers map. The previous interns had this working on localhost and I've also set it up like that, but I still feel like it's a problem with my geoserver-setup rather than a problem with the file path.

My main question is whether it's possible to place a shapefile in the geoserver map > data_dir > data directory and if Geoserver is able to provide it just like that through the GetMap command of the Geoserver Get Map Service. Or whether I specifically have to add every shapefile manually, as described here: http://docs.geoserver.org/stable/en/user/gettingstarted/shapefile-quickstart/index.html

Adding the shapefile manually seems to require me to create a workspace, store & layer for each shapefile. Another problem I run into when I try this approach is that only the shapefile from the tutorial can be added without running into errors. And I can't load the shapefiles I provide by myself. The previous interns (who did not document how they did it) did manage to get it working, so I'm sure the shapefile itself isn't corrupt.

Steps in which I've added the shapefile to GeoServer:

I've probably added the new workspace correctly:

enter image description here

I've probably also added the new store correctly:

enter image description here

Adding a new Layer is where I believe I'm making a mistake:

enter image description here

I'm not 100% sure that the lon/lat generated from the Declared SRS are the right ones, but when I check it's coordinates it seems to check-out. I need the bounding box of the sea-area (Wadden Sea) in between Northwestern-Holland and the islands.

I also do not know if I picked the right style in the publish tab of the layer.

Anyway, when I preview the layer, I'm supposed to see something similar to the preview in the tutorial, yet what I see is this.

enter image description here

Please help, I have no clue what I'm doing wrong and usually I would second-guess the shapefile itself, but this is the only one I have of this bounding box area and it's the only area I am restricted to look at.

UPDATE:

I've managed to get it to work and the reason this was so difficult was because there were two problems causing this.

The first problem was that I was somehow supplied with a faulty shapefile and as soon as I was given an updated version of it, I was instantly able to display it through the layer preview option in Geoserver.

The second problem was that the coordinates of the Lat/Lon Bounding Box that were automatically computed from native bounds were switched around. So X min and max needed to be moved to Y and Y needed to be moved to X. And this allowed me to display the shapefile in my openlayers web application.

0

Without seeing the actual Shapefile it is hard to be sure what is wrong, but your lat/lon bounding box is definitely wrong if that shapefile should be near the Netherlands. In fact it is just wrong full stop, latitude should fall between -90->90 and longitude should be between -180->180.

The most likely cause of this is that GeoServer has guessed the projection of your data incorrectly or that you have told it the wrong answer. If your shapefile came with a.prj file try pasting it into prj2epsg.org to see if you can get a better answer for the EPSG code.

To answer your other question (which really should be in a separate question, do please take the tour) you need to create a new store and layer for each new Shapefile you add (sharing Workspaces is normal and encouraged). If you are looking at an automated upload service you probably want to be using the REST interface.

  • Actually if all shapefiles are in the same directory, one can create a single "directory of shapefiles" data store for all of them. – Andrea Aime Feb 11 '16 at 12:51
  • But does that update if you add another shapefile? – Ian Turton Feb 11 '16 at 13:23
  • I clicked 'compute from data' to generate the native bounding box values, while I generated the Latitude & Longitude from the Declared SRS. The shapefile also did not come with a .prj file, but I have tried creating one for it, which is what generated the word "UNKNOWN" in the Native SRS textfield. My current goal is to get this one shapefile to display properly. I could display the shapefile itself, but it's hundreds of lines of data. – user3776022 Feb 11 '16 at 13:36
  • then you need to ask the data supplier what projection the shapefile is in, it is almost impossible to guess correctly – Ian Turton Feb 11 '16 at 14:00
  • Isn't there a way to find out what projection it is by myself. since the only person I can ask won't really know or understand what I'm trying to ask. Also, I myself have no idea what I'm asking them either. Unless you mean ESRI? And I could provide the shapefile itself if that would help? – user3776022 Feb 11 '16 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.