In GeoServer, assume I have a layer named "myLayer".

Using GeoServer's REST API, I want to make a complete copy of the layer, let's say "myLayer2" in the same workspace.

What would be my best approach?

I am on GeoServer 2.9.0, the workspace is a Shape-Directory (although I am looking for a generic solution). I also have the Importer Extension available.


There is no copy facility in the UI, but I believe you could create one using the REST API and a bit of programming instead, just grab both the resource (feature type or coverage) and the layer using a GET request, and then POST a modified version with only the name changed back: http://docs.geoserver.org/stable/en/user/rest/index.html

  • Can you elaborate on how to "grab the resource and the layer"? Do i need to download the layers features via WFS, or can it be done even simpler? I want to have a real copy of the layer, so that when the features geometries get updated through WFS-T, the new layer is not affected. Thx! – hnrch Jul 7 '16 at 12:23
  • I issued a get request to the feature type, took the json response with the feature type's definition, changed the name of the feature type in the json and posted back. That way, I could republish the layer. Nice, but not exactly what I intended. Next time, I also changed the Native_Name and posted back. That gave me a complete new resource (it even created the shape file in the background) with the feature type's defintion. Not bad. Now, how can I transfer the features from one Layer to the empty layer? Maybe WFS-T? Is that the best option? – hnrch Jul 7 '16 at 12:55
  • It's the only one I can think of, but WFS-T is not designed for mass data transfers, it's going to be pretty slow... if I had to do it, I'd have a look at the importer extension, and modify/improve it so that the source of an import can be an existing layer. – Andrea Aime Jul 8 '16 at 12:45
  • Would love to contribute, but I am not a Java programmer. I am gonna do it with WFS-T for now. – hnrch Jul 8 '16 at 13:00
  • Got it working now with WFS-T, but as you said, it is way too slow. In my case, a featureType with around 8.000 polygons, for example, took more than 5 minutes (not sure how long exactly because the request timed out). I think I have to come up with a different solution. – hnrch Jul 8 '16 at 16:04

I went with a different approach in the end:

  1. Download a complete layer through WFS with outputFormat set to SHAPE-ZIP. What you get is a zipped shapefile of that layer.
  2. Import that file back into Geoserver via the restful Importer Extension.

Although this might feel a bit hacky, it works quite well for me.

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.