TransWikia.com

GeoServer - Render style of points based on URLs saved in a field of the table using YSLD

Geographic Information Systems Asked by P G on November 26, 2020

I am new to styling in GeoServer and was wondering if there is a way to style points in a table based on the external URLs defined in one of the fields in that table.

Let’s say I have a table in PostgreSQL with 100 points and a field (e.g. link) of that table has the URLs of the images that I want to use to style these points in GeoServer. One unique URL can be used across multiple points and the ‘link’ field will define what image to use for what point.

I cannot use filter rule because we want to keep the style dynamic in the sense that if a new point is added that has a new image URL, Geoserver should just style it based on the URL in the field rather than defining a new filter rule in the style for that new image.

EDIT:

Here is the code sample I tried but it shows the points as grey squares and not the actual image

name: Default Styler
title: A boring default style
abstract: A boring default style
feature-styles:
- name: name
  rules:
- name: Rule 1
  title: RedSquare
  abstract: A red fill with an 11 pixel size
  scale: [min, max]
  symbolizers:
  - point:
      size: 15
      symbols:
      - external:
          url: ${marker_url}
          format: image/png

Here is the example of the attributes of the points

|id|marker_name |  marker_url|

|1 |Cat         |  https://homepages.cae.wisc.edu/~ece533/images/cat.png      
|2 |Mountain    |  https://homepages.cae.wisc.edu/~ece533/images/mountain.png 
|3 |Watch       |  https://homepages.cae.wisc.edu/~ece533/images/watch.png

One Answer

This sounds like a simple point with graphic except instead of using a literal URL (as in the cookbook example) you would use a property.

title: 'YSLD Cook Book: Point as graphic'
feature-styles:
- name: name
  rules:
  - symbolizers:
    - point:
        size: 32
        symbols:
        - external:
            url: ${my_url_col}
            format: image/png

Answered by Ian Turton on November 26, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP