Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Say I have a layer L in Geoserver to which i attach a style S (in the GS backend i published L using S). Of course, If I use the style editor in the GS backend and change the SLD for S and then 'submit' the new style, my layer looks different next time I load it in a browser.

Now, I am planning to re-generate the SLD for S regularly directly into the Geoserver styles folder using php : each time the database has a new entry, it is queried, the appropriate style/legend is calculated and my php is parsed and prints the SLD code for S in the styles folder, overwriting the previous version of S in the process. It does not work, i.e. if I modify or overwrite S directly in the styles folder and then reload my layer in a browser the style is not updated.

Hence my question: what does the 'submit' button in the GS backend style editor do and how can it be simulated using code instead of manually.

Hope this makes sense. Thanks for your help. B

share|improve this question
up vote 3 down vote accepted

U can use the geoserver restful interface to change all the catalog objects on-the-fly including styles. Check the documentation for examples, its quite straigthfoward.

curl -u admin:geoserver -XPUT -H 'Content-type: application/vnd.ogc.sld+xml' -d @roads.sld http://localhost:8080/geoserver/rest/styles/roads_style

where "roads.sld" is a file with all the SLD xml content.

share|improve this answer
Hi Pedro. Could you extend your answer with a short example maybe? – underdark Jul 2 '11 at 16:48
Thanks! just where i needed to look. i think i can call curl from inside PostgreSQL. ideal! – Barnabe Jul 6 '11 at 16:46

The link to the rest interface curl examples: If you upload the stylesheet through the rest API, it will be reloaded.

share|improve this answer
hi Zach, this is great but it seems that once you have done that the layer in question becomes disabled... any idea why and if this can be avoided? – Barnabe Jul 19 '11 at 8:37
i have seen the same issue (disabled layer post curl rest API call) here… – Barnabe Jul 19 '11 at 8:38
answer might be this:… – Barnabe Jul 19 '11 at 8:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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