I am generating a shapefile with a Python script and I want to publish it via GeoServer. The GeoServer is running on localhost 8080.
I learned from this website that the workflow would be:
- Add a store
- Specify the data source name
- Specify the getCapabilities URL
- Enter password that is the same as the server
- Publish
So far I have come up with this code, but it is somehow a mess and I do not know what exactly I am doing...
from geoserver.catalog import Catalog
from random import randrange
import geoserver.util
nomen='test{}'.format(randrange(10000))
cat = Catalog("http://localhost:8080/geoserver/rest/", "admin", "geoserver")
geosolutions = cat.get_workspace("workspacename")
shapefile_plus_sidecars = geoserver.util.shapefile_and_friends('25832')
ft = cat.create_featurestore(nomen, shapefile_plus_sidecars, workspacename)
that_layer = cat.get_layer(nomen)
print(that_layer.name)
How can I sort this out?
1 Answer 1
You don't want to cascade a remote WFS (that is republish someone else's layers in your own GeoServer). You want to use the GeoServer REST API to add and publish a shapefile.
So you need to look at this tutorial from GeoSolutions