Skip to content

Latest commit

 

History

History

06_Simbologia

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Simbología para Mapas Web

SLD (Styled Layer Descriptor )

Styled Layer Descriptor https://www.opengeospatial.org/standards/sld

The OpenGIS® Styled Layer Descriptor (SLD) Profile of the OpenGIS® Web Map Service (WMS)
Encoding Standard [http://www.opengeospatial.org/standards/wms] defines
an encoding that extends
 the WMS standard to allow user-defined symbolization
and coloring of geographic feature[http://www.opengeospatial.org/ogc/glossary/f]
and coverage[http://www.opengeospatial.org/ogc/glossary/c] data.

https://en.wikipedia.org/wiki/Styled_Layer_Descriptor

In cartography, a Styled Layer Descriptor (SLD) is an XML
schema specified by the Open Geospatial Consortium (OGC)
for describing the appearance of map layers.
It is capable of describing the rendering of vector and raster data.
A typical use of SLDs is to instruct a Web Map Service (WMS)
how to render a specific layer.

Ejemplo simbología SLD para geometría de tipo línea

<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor version="1.1.0"
  xmlns="http://www.opengis.net/sld"
  xmlns:se="http://www.opengis.net/se"
  xmlns:ogc="http://www.opengis.net/ogc"
  xmlns:xlink="http://www.w3.org/1999/xlink"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.opengis.net/sld
  http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd">
<NamedLayer>
  <se:Name>country_bounds</se:Name>
    <UserStyle>
      <se:Name>xxx</se:Name>
      <se:FeatureTypeStyle>
        <se:Rule>
          <se:LineSymbolizer>
            <se:Geometry>
              <ogc:PropertyName>center-line</ogc:PropertyName>
            </se:Geometry>
            <se:Stroke>
              <se:SvgParameter name="stroke">#0000ff</se:SvgParameter>
            </se:Stroke>
          </se:LineSymbolizer>
        </se:Rule>
      </se:FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

Ejemplo simbología SLD para geometría de tipo punto con etiquetado

<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor version="1.0.0" 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"
  xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd">
  <NamedLayer>
    <Name>poi</Name>
    <UserStyle>
      <Name>poi</Name>
      <Title>Points of interest</Title>
      <Abstract>Manhattan points of interest</Abstract>
      <FeatureTypeStyle>
        <Rule>
          <PointSymbolizer>
            <Graphic>
              <Mark>
                <WellKnownName>circle</WellKnownName>
                <Fill>
                  <CssParameter name="fill">#FF0000</CssParameter>
                  <CssParameter name="fill-opacity">1.0</CssParameter>
                </Fill>
              </Mark>
              <Size>11</Size>
            </Graphic>
          </PointSymbolizer>
          <PointSymbolizer>
            <Graphic>
              <Mark>
                <WellKnownName>circle</WellKnownName>
                <Fill>
                  <CssParameter name="fill">#EDE513</CssParameter>
                  <CssParameter name="fill-opacity">1.0</CssParameter>
                </Fill>
              </Mark>
              <Size>7</Size>
            </Graphic>
          </PointSymbolizer>
        </Rule>
        <Rule>
          <MaxScaleDenominator>32000</MaxScaleDenominator>
          <TextSymbolizer>
            <Label>
              <ogc:PropertyName>NAME</ogc:PropertyName>
            </Label>
            <Font>
              <CssParameter name="font-family">Arial</CssParameter>
              <CssParameter name="font-weight">Bold</CssParameter>
              <CssParameter name="font-size">14</CssParameter>
            </Font>
            <LabelPlacement>
              <PointPlacement>
                <AnchorPoint>
                  <AnchorPointX>0.5</AnchorPointX>
                  <AnchorPointY>0.5</AnchorPointY>
                </AnchorPoint>
                <Displacement>
                  <DisplacementX>0</DisplacementX>
                  <DisplacementY>-15</DisplacementY>
                </Displacement>
              </PointPlacement>
            </LabelPlacement>
            <Halo>
              <Radius>
                <ogc:Literal>2</ogc:Literal>
              </Radius>
              <Fill>
                <CssParameter name="fill">#FFFFFF</CssParameter>
              </Fill>
            </Halo>
            <Fill>
              <CssParameter name="fill">#000000</CssParameter>
            </Fill>
          </TextSymbolizer>
        </Rule>
      </FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

Vista:

alt text

Ejemplo simbología SLD para geometría de tipo polígono clasificada por un atributo

<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:se="http://www.opengis.net/se" version="1.1.0" xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <NamedLayer>
    <se:Name>u0_distritos ejemplo clase polígonos</se:Name>
    <UserStyle>
      <se:Name>u0_distritos ejemplo clase polígonos</se:Name>
      <se:FeatureTypeStyle>
        <se:Rule>
          <se:Name>CENTRAL EAST</se:Name>
          <se:Description>
            <se:Title>CENTRAL EAST</se:Title>
          </se:Description>
          <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
            <ogc:PropertyIsEqualTo>
              <ogc:PropertyName>DISTRICT</ogc:PropertyName>
              <ogc:Literal>CENTRAL EAST</ogc:Literal>
            </ogc:PropertyIsEqualTo>
          </ogc:Filter>
          <se:PolygonSymbolizer>
            <se:Fill>
              <se:SvgParameter name="fill">#ec14d7</se:SvgParameter>
            </se:Fill>
            <se:Stroke>
              <se:SvgParameter name="stroke">#232323</se:SvgParameter>
              <se:SvgParameter name="stroke-width">1</se:SvgParameter>
              <se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter>
            </se:Stroke>
          </se:PolygonSymbolizer>
        </se:Rule>
        <se:Rule>
          <se:Name>CENTRAL WEST</se:Name>
          <se:Description>
            <se:Title>CENTRAL WEST</se:Title>
          </se:Description>
          <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
            <ogc:PropertyIsEqualTo>
              <ogc:PropertyName>DISTRICT</ogc:PropertyName>
              <ogc:Literal>CENTRAL WEST</ogc:Literal>
            </ogc:PropertyIsEqualTo>
          </ogc:Filter>
          <se:PolygonSymbolizer>
            <se:Fill>
              <se:SvgParameter name="fill">#ef8393</se:SvgParameter>
            </se:Fill>
            <se:Stroke>
              <se:SvgParameter name="stroke">#232323</se:SvgParameter>
              <se:SvgParameter name="stroke-width">1</se:SvgParameter>
              <se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter>
            </se:Stroke>
          </se:PolygonSymbolizer>
        </se:Rule>
        <se:Rule>
          <se:Name>EAST</se:Name>
          <se:Description>
            <se:Title>EAST</se:Title>
          </se:Description>
          <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
            <ogc:PropertyIsEqualTo>
              <ogc:PropertyName>DISTRICT</ogc:PropertyName>
              <ogc:Literal>EAST</ogc:Literal>
            </ogc:PropertyIsEqualTo>
          </ogc:Filter>
          <se:PolygonSymbolizer>
            <se:Fill>
              <se:SvgParameter name="fill">#19ddc0</se:SvgParameter>
            </se:Fill>
            <se:Stroke>
              <se:SvgParameter name="stroke">#232323</se:SvgParameter>
              <se:SvgParameter name="stroke-width">1</se:SvgParameter>
              <se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter>
            </se:Stroke>
          </se:PolygonSymbolizer>
        </se:Rule>
        <se:Rule>
          <se:Name>NORTH</se:Name>
          <se:Description>
            <se:Title>NORTH</se:Title>
          </se:Description>
          <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
            <ogc:PropertyIsEqualTo>
              <ogc:PropertyName>DISTRICT</ogc:PropertyName>
              <ogc:Literal>NORTH</ogc:Literal>
            </ogc:PropertyIsEqualTo>
          </ogc:Filter>
          <se:PolygonSymbolizer>
            <se:Fill>
              <se:SvgParameter name="fill">#bbde7d</se:SvgParameter>
            </se:Fill>
            <se:Stroke>
              <se:SvgParameter name="stroke">#232323</se:SvgParameter>
              <se:SvgParameter name="stroke-width">1</se:SvgParameter>
              <se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter>
            </se:Stroke>
          </se:PolygonSymbolizer>
        </se:Rule>
        <se:Rule>
          <se:Name>NORTH CENTRAL</se:Name>
          <se:Description>
            <se:Title>NORTH CENTRAL</se:Title>
          </se:Description>
          <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
            <ogc:PropertyIsEqualTo>
              <ogc:PropertyName>DISTRICT</ogc:PropertyName>
              <ogc:Literal>NORTH CENTRAL</ogc:Literal>
            </ogc:PropertyIsEqualTo>
          </ogc:Filter>
          <se:PolygonSymbolizer>
            <se:Fill>
              <se:SvgParameter name="fill">#1eee33</se:SvgParameter>
            </se:Fill>
            <se:Stroke>
              <se:SvgParameter name="stroke">#232323</se:SvgParameter>
              <se:SvgParameter name="stroke-width">1</se:SvgParameter>
              <se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter>
            </se:Stroke>
          </se:PolygonSymbolizer>
        </se:Rule>
        <se:Rule>
          <se:Name>SOUTH</se:Name>
          <se:Description>
            <se:Title>SOUTH</se:Title>
          </se:Description>
          <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
            <ogc:PropertyIsEqualTo>
              <ogc:PropertyName>DISTRICT</ogc:PropertyName>
              <ogc:Literal>SOUTH</ogc:Literal>
            </ogc:PropertyIsEqualTo>
          </ogc:Filter>
          <se:PolygonSymbolizer>
            <se:Fill>
              <se:SvgParameter name="fill">#ca8a22</se:SvgParameter>
            </se:Fill>
            <se:Stroke>
              <se:SvgParameter name="stroke">#232323</se:SvgParameter>
              <se:SvgParameter name="stroke-width">1</se:SvgParameter>
              <se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter>
            </se:Stroke>
          </se:PolygonSymbolizer>
        </se:Rule>
        <se:Rule>
          <se:Name>WEST</se:Name>
          <se:Description>
            <se:Title>WEST</se:Title>
          </se:Description>
          <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
            <ogc:PropertyIsEqualTo>
              <ogc:PropertyName>DISTRICT</ogc:PropertyName>
              <ogc:Literal>WEST</ogc:Literal>
            </ogc:PropertyIsEqualTo>
          </ogc:Filter>
          <se:PolygonSymbolizer>
            <se:Fill>
              <se:SvgParameter name="fill">#2571e2</se:SvgParameter>
            </se:Fill>
            <se:Stroke>
              <se:SvgParameter name="stroke">#232323</se:SvgParameter>
              <se:SvgParameter name="stroke-width">1</se:SvgParameter>
              <se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter>
            </se:Stroke>
          </se:PolygonSymbolizer>
        </se:Rule>
        <se:Rule>
          <se:Name></se:Name>
          <se:Description>
            <se:Title>DISTRICT is ''</se:Title>
          </se:Description>
          <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
            <ogc:Or>
              <ogc:PropertyIsEqualTo>
                <ogc:PropertyName>DISTRICT</ogc:PropertyName>
                <ogc:Literal></ogc:Literal>
              </ogc:PropertyIsEqualTo>
              <ogc:PropertyIsNull>
                <ogc:PropertyName>DISTRICT</ogc:PropertyName>
              </ogc:PropertyIsNull>
            </ogc:Or>
          </ogc:Filter>
          <se:PolygonSymbolizer>
            <se:Fill>
              <se:SvgParameter name="fill">#6720eb</se:SvgParameter>
            </se:Fill>
            <se:Stroke>
              <se:SvgParameter name="stroke">#232323</se:SvgParameter>
              <se:SvgParameter name="stroke-width">1</se:SvgParameter>
              <se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter>
            </se:Stroke>
          </se:PolygonSymbolizer>
        </se:Rule>
        <se:Rule>
          <se:TextSymbolizer>
            <se:Label>
              <ogc:PropertyName>DISTRICT</ogc:PropertyName>
            </se:Label>
            <se:Font>
              <se:SvgParameter name="font-family">.AppleSystemUIFont</se:SvgParameter>
              <se:SvgParameter name="font-size">13</se:SvgParameter>
            </se:Font>
            <se:LabelPlacement>
              <se:PointPlacement>
                <se:AnchorPoint>
                  <se:AnchorPointX>0</se:AnchorPointX>
                  <se:AnchorPointY>0.5</se:AnchorPointY>
                </se:AnchorPoint>
              </se:PointPlacement>
            </se:LabelPlacement>
            <se:Fill>
              <se:SvgParameter name="fill">#000000</se:SvgParameter>
            </se:Fill>
            <se:VendorOption name="maxDisplacement">1</se:VendorOption>
          </se:TextSymbolizer>
        </se:Rule>
      </se:FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

Vista:

alt text

Ejemplo simbología SLD para ráster

<?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>Two color gradient</Name>
    <UserStyle>
      <Title>SLD Cook Book: Two color gradient</Title>
      <FeatureTypeStyle>
        <Rule>
          <RasterSymbolizer>
            <ColorMap>
              <ColorMapEntry color="#008000" quantity="70" />
              <ColorMapEntry color="#663333" quantity="256" />
            </ColorMap>
          </RasterSymbolizer>
        </Rule>
      </FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

Each entry in the represents one entry or anchor in the gradient. Line 5 sets the lower value of 70 via the quantity parameter, which is styled a dark green (#008000). Line 6 sets the upper value of 256 via the quantity parameter again, which is styled a dark brown (#663333). All data values in between these two quantities will be linearly interpolated: a value of 163 (the midpoint between 70 and 256) will be colored as the midpoint between the two colors (in this case approximately #335717, a muddy green).

Implementaciones de SLD

Geoserver

SLD Cookbook https://docs.geoserver.org/stable/en/user/styling/sld/cookbook/

Mapserver

SLD https://mapserver.org/ogc/sld.html

Arcgis Server

<sld:StyledLayerDescriptor version="1.0.0" xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd">
 <!--
  ESRI_StatesCitiesRivers_USA @
  http://sampleserver1.arcgisonline.com/arcgis/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/WMSServer?
 -->
 <sld:NamedLayer>
  <!--
   layer "2" is the "cities" point layer in the WMS service
  -->
  <sld:Name>2</sld:Name>
  <sld:UserStyle>
   <!--
    style should be applied on layer "2", reference the style by it's name "pointSymbolizer"
   -->
   <sld:Name>pointSymbolizer</sld:Name>
   <sld:Title>pointSymbolizer</sld:Title>
   <sld:FeatureTypeStyle>
    <sld:Rule>
     <sld:PointSymbolizer>
      <sld:Graphic>
       <sld:Mark>
        <!-- uses a circle to mark a city -->
        <sld:WellKnownName>circle</sld:WellKnownName>
        <!-- fill circle with color #666666 -->
        <sld:Fill>
         <sld:CssParameter name="fill">#666666</sld:CssParameter>
         <sld:CssParameter name="fill-opacity">1</sld:CssParameter>
        </sld:Fill>
        <!-- circle boundary with color #666666 -->
        <sld:Stroke>
         <sld:CssParameter name="stroke">#666666</sld:CssParameter>
         <sld:CssParameter name="stroke-opacity">1</sld:CssParameter>
         <sld:CssParameter name="stroke-width">1</sld:CssParameter>
        </sld:Stroke>
       </sld:Mark>
       <!-- circle opacity 1.0 -->
       <sld:Opacity>1</sld:Opacity>
       <!-- circle size "3" -->
       <sld:Size>3</sld:Size>
       <sld:Rotation>0</sld:Rotation>
      </sld:Graphic>
     </sld:PointSymbolizer>
    </sld:Rule>
   </sld:FeatureTypeStyle>
  </sld:UserStyle>
 </sld:NamedLayer>
</sld:StyledLayerDescriptor>

 Simbología en Geoserver

SLD

Generando SLD's con QGIS

SLD Avanzado

Otros lenguajes para construcción de simbología para Geoserver

YSLD

YSLD is a YAML based language (Qué es YAML? https://fercontreras.com/conoce-que-es-un-yaml-e18e9d21ade4 )

Ejemplo geometría punto:

title: 'YSLD Cook Book: Simple Point'
feature-styles:
- name: name
  rules:
  - symbolizers:
    - point:
        size: 6
        symbols:
        - mark:
            shape: circle
            fill-color: '#FF0000'

CSS

Ejemplo geometría punto:

 * {
   mark: symbol(circle);
   mark-size: 6px;
   :mark {
     fill: red;
   }
 }

Ejemplo polígono con etiquetado:

 /* @title Manzana */
* {
    [@sd > 200] [@sd < 30k]   {
      stroke: #E5E8E8 ;
      stroke-width: 1;
      stroke-opacity:1;      
      fill: #F7F9F9 ; 
      fill-opacity: 0.4;
  }
}
[@sd > 1k ] [@sd < 3k] {
  stroke: black;
  stroke-width: 0.2;
  label:[strSubstring(codigo, 13, 17) ];
  label-anchor: 0.5 0.5;
  label-max-displacement: 10;
  label-allow-overruns: true;
  font-family: "DejaVu Sans";
  font-fill: black;
  font-style: normal;
  font-weight: normal;
  font-size: 10;
  halo-color: #ffffff;
  halo-radius: 1;
}

SLD equivalente para el polígono con etiquetado:

<?xml version="1.0" encoding="UTF-8"?><sld:StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:sld="http://www.opengis.net/sld" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" version="1.0.0">
  <sld:NamedLayer>
    <sld:Name>Default Styler</sld:Name>
    <sld:UserStyle>
      <sld:Name>Default Styler</sld:Name>
      <sld:FeatureTypeStyle>
        <sld:Rule>
          <sld:Title>Manzana</sld:Title>
          <sld:MinScaleDenominator>1000.0</sld:MinScaleDenominator>
          <sld:MaxScaleDenominator>3000.0</sld:MaxScaleDenominator>
          <sld:PolygonSymbolizer>
            <sld:Fill>
              <sld:CssParameter name="fill">#F7F9F9</sld:CssParameter>
              <sld:CssParameter name="fill-opacity">0.4</sld:CssParameter>
            </sld:Fill>
            <sld:Stroke>
              <sld:CssParameter name="stroke-width">0.2</sld:CssParameter>
            </sld:Stroke>
          </sld:PolygonSymbolizer>
          <sld:TextSymbolizer>
            <sld:Label>
              <ogc:Function name="strSubstring">
                <ogc:PropertyName>codigo</ogc:PropertyName>
                <ogc:Literal>13</ogc:Literal>
                <ogc:Literal>17</ogc:Literal>
              </ogc:Function>
            </sld:Label>
            <sld:Font>
              <sld:CssParameter name="font-family">DejaVu Sans</sld:CssParameter>
              <sld:CssParameter name="font-size">10</sld:CssParameter>
              <sld:CssParameter name="font-style">normal</sld:CssParameter>
              <sld:CssParameter name="font-weight">normal</sld:CssParameter>
            </sld:Font>
            <sld:LabelPlacement>
              <sld:PointPlacement>
                <sld:AnchorPoint>
                  <sld:AnchorPointX>0.5</sld:AnchorPointX>
                  <sld:AnchorPointY>0.5</sld:AnchorPointY>
                </sld:AnchorPoint>
              </sld:PointPlacement>
            </sld:LabelPlacement>
            <sld:Halo>
              <sld:Radius>1</sld:Radius>
              <sld:Fill>
                <sld:CssParameter name="fill">#ffffff</sld:CssParameter>
              </sld:Fill>
            </sld:Halo>
            <sld:Fill>
              <sld:CssParameter name="fill">#000000</sld:CssParameter>
            </sld:Fill>
            <sld:VendorOption name="maxDisplacement">10</sld:VendorOption>
            <sld:VendorOption name="allowOverruns">true</sld:VendorOption>
          </sld:TextSymbolizer>
        </sld:Rule>
        <sld:Rule>
          <sld:Title>Manzana</sld:Title>
          <sld:MinScaleDenominator>200.0</sld:MinScaleDenominator>
          <sld:MaxScaleDenominator>1000.0</sld:MaxScaleDenominator>
          <sld:PolygonSymbolizer>
            <sld:Fill>
              <sld:CssParameter name="fill">#F7F9F9</sld:CssParameter>
              <sld:CssParameter name="fill-opacity">0.4</sld:CssParameter>
            </sld:Fill>
            <sld:Stroke>
              <sld:CssParameter name="stroke">#E5E8E8</sld:CssParameter>
            </sld:Stroke>
          </sld:PolygonSymbolizer>
        </sld:Rule>
        <sld:Rule>
          <sld:Title>Manzana</sld:Title>
          <sld:MinScaleDenominator>3000.0</sld:MinScaleDenominator>
          <sld:MaxScaleDenominator>30000.0</sld:MaxScaleDenominator>
          <sld:PolygonSymbolizer>
            <sld:Fill>
              <sld:CssParameter name="fill">#F7F9F9</sld:CssParameter>
              <sld:CssParameter name="fill-opacity">0.4</sld:CssParameter>
            </sld:Fill>
            <sld:Stroke>
              <sld:CssParameter name="stroke">#E5E8E8</sld:CssParameter>
            </sld:Stroke>
          </sld:PolygonSymbolizer>
        </sld:Rule>
        <sld:VendorOption name="ruleEvaluation">first</sld:VendorOption>
      </sld:FeatureTypeStyle>
    </sld:UserStyle>
  </sld:NamedLayer>
</sld:StyledLayerDescriptor>

MBStyle

MBStyle is a JSON based language

{
  "version": 8,
  "name": "point-circle-test",
  "layers": [
    {
      "id": "point",
      "type": "circle",
      "paint": {
        "circle-radius": 3,
        "circle-color": "#FF0000",
        "circle-pitch-scale": "map"
      }
    }
  ]
}

Leyendas en geoserver

La generación de leyendas en geoserver se realiza a través de la operación GetLegendGraphic del estándar WMS

alt text

Contribuciones a la comunidad:

Avances "recientes" para simbología en la web: Vector tiles

alt text

alt text

alt text

Qué son los vector tiles?

Definición:

Vector tiles are an open standard under a Creative Commons Attribution 3.0 US License.

Vector tiles are a way to deliver geographic data in small chunks to a browser or other client application. Vector tiles are similar to raster tiles, but instead of raster images, the data returned is a vector representation of the features in the tile. --- OSM Vector Tiles

alt text

Vector tiles are transferred over the web in the form of packed geographic data in vector format split into squared tiles. --- Understanding vector tiles

Comparación proceso de generación Raster tiles vs Vector tiles

Generación y transporte de raster tiles :

alt text

Generación y transporte de vector tiles :

alt text

Simbología para vector tiles

La simbología de los vector tiles se representa en archivos de tipo json.

Dicha simbología es interpretada por el cliente a través de un api de javascript. Ejemplos:

Ejemplo de simbología para vector tiles: Mapbox Streets v8 https://docs.mapbox.com/vector-tiles/reference/mapbox-streets-v8/

{
  "version": 8,
  "name": "Mapbox Streets tileset v8",
  "sources": {
    "mapbox-streets": {
      "type": "vector",
      "url": "mapbox://mapbox.mapbox-streets-v8"
    }
  },
  "layers": [
    {
      "id": "admin",
      "source": "mapbox-streets",
      "source-layer": "admin",
      "type": "line",
      "paint": {
        "line-color": "#ffffff"
      }
    },
    {
      "id": "aeroway",
      "source": "mapbox-streets",
      "source-layer": "aeroway",
      "type": "line",
      "paint": {
        "line-color": "#ffffff"
      }
    },
    {
      "id": "airport_label",
      "source": "mapbox-streets",
      "source-layer": "airport_label",
      "type": "circle",
      "paint": {
        "circle-radius": 3,
        "circle-color": "rgba(238,78,139, 0.4)",
        "circle-stroke-color": "rgba(238,78,139, 1)",
        "circle-stroke-width": 1
      }
    },
    {
      "id": "building",
      "source": "mapbox-streets",
      "source-layer": "building",
      "type": "fill",
      "paint": {
        "fill-color": "rgba(66,100,251, 0.3)",
        "fill-outline-color": "rgba(66,100,251, 1)"
      }
    },
    {
      "id": "housenum_label",
      "source": "mapbox-streets",
      "source-layer": "housenum_label",
      "type": "circle",
      "paint": {
        "circle-radius": 3,
        "circle-color": "rgba(238,78,139, 0.4)",
        "circle-stroke-color": "rgba(238,78,139, 1)",
        "circle-stroke-width": 1
      }
    },
    {
      "id": "landuse_overlay",
      "source": "mapbox-streets",
      "source-layer": "landuse_overlay",
      "type": "fill",
      "paint": {
        "fill-color": "rgba(66,100,251, 0.3)",
        "fill-outline-color": "rgba(66,100,251, 1)"
      }
    },
    {
      "id": "landuse",
      "source": "mapbox-streets",
      "source-layer": "landuse",
      "type": "fill",
      "paint": {
        "fill-color": "rgba(66,100,251, 0.3)",
        "fill-outline-color": "rgba(66,100,251, 1)"
      }
    },
    {
      "id": "motorway_junction",
      "source": "mapbox-streets",
      "source-layer": "motorway_junction",
      "type": "circle",
      "paint": {
        "circle-radius": 3,
        "circle-color": "rgba(238,78,139, 0.4)",
        "circle-stroke-color": "rgba(238,78,139, 1)",
        "circle-stroke-width": 1
      }
    },
    {
      "id": "natural_label",
      "source": "mapbox-streets",
      "source-layer": "natural_label",
      "type": "circle",
      "paint": {
        "circle-radius": 3,
        "circle-color": "rgba(238,78,139, 0.4)",
        "circle-stroke-color": "rgba(238,78,139, 1)",
        "circle-stroke-width": 1
      }
    },
    {
      "id": "place_label",
      "source": "mapbox-streets",
      "source-layer": "place_label",
      "type": "circle",
      "paint": {
        "circle-radius": 3,
        "circle-color": "rgba(238,78,139, 0.4)",
        "circle-stroke-color": "rgba(238,78,139, 1)",
        "circle-stroke-width": 1
      }
    },
    {
      "id": "poi_label",
      "source": "mapbox-streets",
      "source-layer": "poi_label",
      "type": "circle",
      "paint": {
        "circle-radius": 3,
        "circle-color": "rgba(238,78,139, 0.4)",
        "circle-stroke-color": "rgba(238,78,139, 1)",
        "circle-stroke-width": 1
      }
    },
    {
      "id": "road",
      "source": "mapbox-streets",
      "source-layer": "road",
      "type": "line",
      "paint": {
        "line-color": "#ffffff"
      }
    },
    {
      "id": "structure",
      "source": "mapbox-streets",
      "source-layer": "structure",
      "type": "fill",
      "paint": {
        "fill-color": "rgba(66,100,251, 0.3)",
        "fill-outline-color": "rgba(66,100,251, 1)"
      }
    },
    {
      "id": "transit_stop_label",
      "source": "mapbox-streets",
      "source-layer": "transit_stop_label",
      "type": "circle",
      "paint": {
        "circle-radius": 3,
        "circle-color": "rgba(238,78,139, 0.4)",
        "circle-stroke-color": "rgba(238,78,139, 1)",
        "circle-stroke-width": 1
      }
    },
    {
      "id": "water",
      "source": "mapbox-streets",
      "source-layer": "water",
      "type": "fill",
      "paint": {
        "fill-color": "rgba(66,100,251, 0.3)",
        "fill-outline-color": "rgba(66,100,251, 1)"
      }
    },
    {
      "id": "waterway",
      "source": "mapbox-streets",
      "source-layer": "waterway",
      "type": "line",
      "paint": {
        "line-color": "#ffffff"
      }
    }
  ]
}

Existen herramientas que facilitan la generación de simbología para vector tiles. Ejemplos:

Existen servicios en la nube y servidores que facilitan la publicación de vector tiles. Ejemplos:

Diferencias entre teselas raster y vector

Documentación técnica sobre Vector Tiles

The Open Geospatial Consortium (OGC) has released a Call for Participation to solicit proposals for the OGC Vector Tiles Pilot Initiative. The Vector Tiles Pilot, sponsored by the US Army Geospatial Center and the UK Defence Science and Technology Laboratory (Dstl) will advance an OGC approach to encode and publish Vector Tiles, and will propose extensions for WFS, WMTS, and GeoPackage.

Conversión de Simbología ESRI a formatos abiertos

Otros

Ejercicio 1: Trabajando con postgis, qgis y geoserver

Datos:

Archivos:

  1. API_AG.LND.AGRI.ZS_DS2_en_csv_v2_937809.csv : Datos por país.
  2. Metadata_Country_API_AG.LND.AGRI.ZS_DS2_en_csv_v2_937809.csv : Metadata sobre países
  3. Metadata_Indicator_API_AG.LND.AGRI.ZS_DS2_en_csv_v2_937809.csv : Metadata del indicador. AG.LND.AGRI.ZS Agricultural land (% of land area)

Proceso:

  • Se cargaron los archivos CSV 1 y 2 en postgresql utilizando qgis.
    • jc_worldbank_metadata_country (Metadata_Country_API_AG.LND.AGRI.ZS_DS2_en_csv_v2_937809.csv )
    • jc_worldbank_ind_agri (Metadata_Indicator_API_AG.LND.AGRI.ZS_DS2_en_csv_v2_937809.csv )
  • Se cargó shp de World borders ( http://thematicmapping.org/downloads/ ) en Postgis. Nombre de tabla: jc_world_borders
  • Crear nueva tabla geográfica que contenga los datos de los indicadores para todos los países
-- remover espacios en nombres de atributos
ALTER TABLE public.jc_worldbank_metadata_country RENAME COLUMN "country code" TO country_code;
ALTER TABLE public.jc_worldbank_ind_agri RENAME COLUMN "country code" TO country_code;

-- crear tabla que contenga el indicador para el año 2016, la metadata del país y la geometría
create table jc_world_agriculture_2016 as 
select jwb.*, c.incomegroup , 
c.region as world_region, c.specialnotes , c.tablename as country_name, 
i."2016"::numeric  as year_2016 , i."indicator code" as indicator_code , i."indicator name" as indicator_name
from jc_world_borders as jwb inner join jc_worldbank_metadata_country as  c 
on jwb.iso3 = c.country_code 
inner join jc_worldbank_ind_agri as i 
on jwb.iso3 = i.country_code
where i."2016" <> ''

-- crear índice espacial 
CREATE INDEX sidx_jc_world_agriculture_2016_geom ON public.jc_world_agriculture_2016 USING gist (geom)

Crear mapa temático de coropletas utilizando qgis y exportar SLD

alt text

alt text

alt text

SLD generado:

<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:se="http://www.opengis.net/se" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ogc="http://www.opengis.net/ogc" xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd">
  <NamedLayer>
    <se:Name>jc_world_agriculture_2016</se:Name>
    <UserStyle>
      <se:Name>jc_world_agriculture_2016</se:Name>
      <se:FeatureTypeStyle>
        <se:Rule>
          <se:Name>1 - 17 </se:Name>
          <se:Description>
            <se:Title>1 - 17 </se:Title>
          </se:Description>
          <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
            <ogc:And>
              <ogc:PropertyIsGreaterThanOrEqualTo>
                <ogc:PropertyName>year_2016</ogc:PropertyName>
                <ogc:Literal>0.55769230769230804</ogc:Literal>
              </ogc:PropertyIsGreaterThanOrEqualTo>
              <ogc:PropertyIsLessThanOrEqualTo>
                <ogc:PropertyName>year_2016</ogc:PropertyName>
                <ogc:Literal>16.66666666666669983</ogc:Literal>
              </ogc:PropertyIsLessThanOrEqualTo>
            </ogc:And>
          </ogc:Filter>
          <se:PolygonSymbolizer>
            <se:Fill>
              <se:SvgParameter name="fill">#f7fcf5</se:SvgParameter>
            </se:Fill>
            <se:Stroke>
              <se:SvgParameter name="stroke">#232323</se:SvgParameter>
              <se:SvgParameter name="stroke-width">1</se:SvgParameter>
              <se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter>
            </se:Stroke>
          </se:PolygonSymbolizer>
        </se:Rule>
        <se:Rule>
          <se:Name>17 - 35 </se:Name>
          <se:Description>
            <se:Title>17 - 35 </se:Title>
          </se:Description>
          <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
            <ogc:And>
              <ogc:PropertyIsGreaterThan>
                <ogc:PropertyName>year_2016</ogc:PropertyName>
                <ogc:Literal>16.66666666666669983</ogc:Literal>
              </ogc:PropertyIsGreaterThan>
              <ogc:PropertyIsLessThanOrEqualTo>
                <ogc:PropertyName>year_2016</ogc:PropertyName>
                <ogc:Literal>34.78722422228379685</ogc:Literal>
              </ogc:PropertyIsLessThanOrEqualTo>
            </ogc:And>
          </ogc:Filter>
          <se:PolygonSymbolizer>
            <se:Fill>
              <se:SvgParameter name="fill">#caeac3</se:SvgParameter>
            </se:Fill>
            <se:Stroke>
              <se:SvgParameter name="stroke">#232323</se:SvgParameter>
              <se:SvgParameter name="stroke-width">1</se:SvgParameter>
              <se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter>
            </se:Stroke>
          </se:PolygonSymbolizer>
        </se:Rule>
        <se:Rule>
          <se:Name>35 - 51 </se:Name>
          <se:Description>
            <se:Title>35 - 51 </se:Title>
          </se:Description>
          <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
            <ogc:And>
              <ogc:PropertyIsGreaterThan>
                <ogc:PropertyName>year_2016</ogc:PropertyName>
                <ogc:Literal>34.78722422228379685</ogc:Literal>
              </ogc:PropertyIsGreaterThan>
              <ogc:PropertyIsLessThanOrEqualTo>
                <ogc:PropertyName>year_2016</ogc:PropertyName>
                <ogc:Literal>50.7291674613952992</ogc:Literal>
              </ogc:PropertyIsLessThanOrEqualTo>
            </ogc:And>
          </ogc:Filter>
          <se:PolygonSymbolizer>
            <se:Fill>
              <se:SvgParameter name="fill">#7bc87c</se:SvgParameter>
            </se:Fill>
            <se:Stroke>
              <se:SvgParameter name="stroke">#232323</se:SvgParameter>
              <se:SvgParameter name="stroke-width">1</se:SvgParameter>
              <se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter>
            </se:Stroke>
          </se:PolygonSymbolizer>
        </se:Rule>
        <se:Rule>
          <se:Name>51 - 65 </se:Name>
          <se:Description>
            <se:Title>51 - 65 </se:Title>
          </se:Description>
          <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
            <ogc:And>
              <ogc:PropertyIsGreaterThan>
                <ogc:PropertyName>year_2016</ogc:PropertyName>
                <ogc:Literal>50.7291674613952992</ogc:Literal>
              </ogc:PropertyIsGreaterThan>
              <ogc:PropertyIsLessThanOrEqualTo>
                <ogc:PropertyName>year_2016</ogc:PropertyName>
                <ogc:Literal>64.83650875386200596</ogc:Literal>
              </ogc:PropertyIsLessThanOrEqualTo>
            </ogc:And>
          </ogc:Filter>
          <se:PolygonSymbolizer>
            <se:Fill>
              <se:SvgParameter name="fill">#2a924a</se:SvgParameter>
            </se:Fill>
            <se:Stroke>
              <se:SvgParameter name="stroke">#232323</se:SvgParameter>
              <se:SvgParameter name="stroke-width">1</se:SvgParameter>
              <se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter>
            </se:Stroke>
          </se:PolygonSymbolizer>
        </se:Rule>
        <se:Rule>
          <se:Name>65 - 83 </se:Name>
          <se:Description>
            <se:Title>65 - 83 </se:Title>
          </se:Description>
          <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
            <ogc:And>
              <ogc:PropertyIsGreaterThan>
                <ogc:PropertyName>year_2016</ogc:PropertyName>
                <ogc:Literal>64.83650875386200596</ogc:Literal>
              </ogc:PropertyIsGreaterThan>
              <ogc:PropertyIsLessThanOrEqualTo>
                <ogc:PropertyName>year_2016</ogc:PropertyName>
                <ogc:Literal>82.55970523011650641</ogc:Literal>
              </ogc:PropertyIsLessThanOrEqualTo>
            </ogc:And>
          </ogc:Filter>
          <se:PolygonSymbolizer>
            <se:Fill>
              <se:SvgParameter name="fill">#00441b</se:SvgParameter>
            </se:Fill>
            <se:Stroke>
              <se:SvgParameter name="stroke">#232323</se:SvgParameter>
              <se:SvgParameter name="stroke-width">1</se:SvgParameter>
              <se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter>
            </se:Stroke>
          </se:PolygonSymbolizer>
        </se:Rule>
      </se:FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

Crear capa en geoserver y asignarle la simbología

alt text

alt text

Previsualización openlayers generada por geoserver:

alt text

Url: http://34.83.176.208:18080/geoserver/clase_2020_01/wms?service=WMS&version=1.1.0&request=GetMap&layers=clase_2020_01%3Ajc_world_agriculture_2016&bbox=-180.0%2C-55.9197273254395%2C180.0%2C83.6235961914062&width=768&height=330&srs=EPSG%3A4326&format=application/openlayers

alt text

Ejercicio 2: Publicando una vista en geoserver

Crear una vista que contenga solo los países colindantes de Rumania

create view jc_view_world_agriculture_adjacent as 
with ru as (
select * from jc_world_agriculture_2016 as jcw 
where jcw.iso3 = 'ROU' 
)
select f.* 
from jc_world_agriculture_2016 as f , ru 
where  st_touches(f.geom, ru.geom)

Url preview http://34.83.176.208:18080/geoserver/clase_2020_01/wms?service=WMS&version=1.1.0&request=GetMap&layers=clase_2020_01%3Ajc_view_world_agriculture_adjacent&bbox=16.111805%2C41.24305%2C30.133228%2C48.57666&width=768&height=401&srs=EPSG%3A4326&format=application/openlayers

alt text