Time for action – managing layers
In the previous section, you created a new style; but it's useless if you can't add a layer to it. We will now update the populatedplace
layer by adding the new style.
Retrieve information on the layer
ne_50m_populated_places
.curl -u admin:password -XGET -H 'Accept: text/xml' http://localhost:8080/geoserver/rest/layers/ne_50m_populated_places -o ne_50m_populated_places.xml
In Python, it is written as follows:
>>> myUrl = 'http://localhost:8080/geoserver/rest/layers/ne_50m_populated_places' >>> headers = {'Accept: text/xml'} >>> resp = requests.get(myUrl, auth=('admin','password'), headers=headers)
Open the
ne_50m_populated_places.xml
file; it starts with astyles
collection. You need to insert the code for the new style you created. We don't need all the elements returned from GeoServer. Modify the file as in the following code. (Please note that we inserted theenabled
element; the default value beingfalse
for it. If you make...