Using Natural Earth Cultural and Physical Data in Geoserver

Home Forums Advice & Tutorials Software & Services Using Natural Earth Cultural and Physical Data in Geoserver

This topic contains 6 replies, has 1 voice, and was last updated by  chiragmo 6 years, 9 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #3431

    wlerner
    Participant

    I am attempting to use the Natural Earth cultural and physical data with GeoServer. Importing the data to GeoServer is not difficult. However, the data does not appear to be displaying correctly. For example, when I attempt to add the 10m_populated_places layer, the layer displays small, red boxes. This is not the desired behavior. I would like to see a small dot, with the name of the city above the dot.

    Does this require modification of the styled layer descriptor (SLD) file? I am unsure how to proceed, so any advice or assistance would be appreciated.

    Thank you.

    #4152

    chiragmo
    Participant

    I am on a similar issue myself…i got the same results with that map as well. Im using GeoServer also.

    #4153

    wlerner
    Participant

    You may want to take a look at this link:

    http://earthatlas.info/naturalearth/

    The website here has the desired effect I think we are both looking for. I have contacted to website author, so any advice he offers I will repost here. Please let me know if you discover anything in the mean time. 8)

    #4154

    chiragmo
    Participant

    Thanks, i’ll post what i find out as well.

    #4155

    wlerner
    Participant

    I have discovered that you must edit the styled layer descriptor (SLD) or make a new one in order for the data to be shown correctly. A good resource for this is the SLD Cookbook, written by the GeoServer folks. This book contains some wonderful examples that I used to get the data to display correctly.

    If you use GeoServer and examine the layer, you can see that there is a fair amount of data attached to the 10m_populated_places layer, which allows you to display all sorts of data.

    It would be most helpful if people would post their SLD files regarding the Natural Earth data, both cultural and physical.

    #4156

    wlerner
    Participant

    To place black points with location names above the points, you could use the following in your SLD:

    <FeatureTypeStyle>
    <Rule>
    <PointSymbolizer>
    <Graphic>
    <Mark>
    <WellKnownName>circle</WellKnownName>
    <Fill>
    <CssParameter name="fill">#000000</CssParameter>
    </Fill>
    </Mark>
    <Size>4</Size>
    </Graphic>
    </PointSymbolizer>
    <TextSymbolizer>
    <Label>
    <ogc:PropertyName>Name</ogc:PropertyName>
    </Label>
    <Font>
    <CssParameter name="font-family">Arial</CssParameter>
    <CssParameter name="font-size">4</CssParameter>
    <CssParameter name="font-style">normal</CssParameter>
    <CssParameter name="font-weight">bold</CssParameter>
    </Font>
    <LabelPlacement>
    <PointPlacement>
    <AnchorPoint>
    <AnchorPointX>0.5</AnchorPointX>
    <AnchorPointY>0.0</AnchorPointY>
    </AnchorPoint>
    <Displacement>
    <DisplacementX>0</DisplacementX>
    <DisplacementY>5</DisplacementY>
    </Displacement>
    </PointPlacement>
    </LabelPlacement>
    <Fill>
    <CssParameter name="fill">#000000</CssParameter>
    </Fill>
    </TextSymbolizer>
    </Rule>
    </FeatureTypeStyle>

    For this to work with Natural Earth data, note the following line:

    <ogc:PropertyName>Name</ogc:PropertyName>

    The property “Name” must be exactly as shown. This is because the “Name” property is what is actually called from the map layer to display the name.

    Please understand that this is not the complete file! Do not cut and paste this. In order for this to work, one also needs the headers, which you can find in any of the GeoServer sample styles built in to the software.

    I hope this was helpful.

    Warren

    #4157

    chiragmo
    Participant

    Thanks, i just discovered this as well while trying to figure out how to change the color of the ocean in some of my maps from gray to it’s blue-ish shade. Also keep in mind for some of these maps…mostly all i believe, the default style is polygon..therefore when you want to create the labels for the countries, you will need to state the polygon symbolizer tag in your sld. The example above is for a point symbolizer…Here is an example to get the labels working with GEOSERVER and natural earth maps using the SLD(from geoserver’s SLD cookbook):

    <?xml version=”1.0″ encoding=”ISO-8859-1″?>

    <StyledLayerDescriptor version=”1.0.0″

    xsi:schemaLocation=”http://www.opengis.net/sld StyledLayerDescriptor.xsd”

    xmlns=”http://www.opengis.net/sld”

    xmlns:ogc=”http://www.opengis.net/ogc”

    xmlns:xlink=”http://www.w3.org/1999/xlink”

    xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”>

    <NamedLayer>

    <Name>Polygon with default label</Name>

    <UserStyle>

    <Title>SLD Cook Book: Polygon with default label</Title>

    <FeatureTypeStyle>

    <Rule>

    <PolygonSymbolizer>

    <Fill>

    <CssParameter name=”fill”>#40FF40</CssParameter>

    </Fill>

    <Stroke>

    <CssParameter name=”stroke”>#FFFFFF</CssParameter>

    <CssParameter name=”stroke-width”>2</CssParameter>

    </Stroke>

    </PolygonSymbolizer>

    <TextSymbolizer>

    <Label>

    <ogc:PropertyName>name</ogc:PropertyName>

    </Label>

    </TextSymbolizer>

    </Rule>

    </FeatureTypeStyle>

    </UserStyle>

    </NamedLayer>

    </StyledLayerDescriptor>

    Also if you need to reference the data from these shape files and if your using OPENLAYERS, you can reference it through the getfeatureinfo method (which is a openlayers method).

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.