0

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
0

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
  • Thank you for responding. I tried using a property but it shows the points as grey squares and not the actual pngs. – P G Apr 2 at 16:19
  • We'd need to see the contents of your attribute and the log file showing the error – Ian Turton Apr 2 at 16:29
  • I have updated the question to include the code sample and the attribute table sample. I am very new to StackExchange so pardon me if I don't know how to add a table to the question. Also, I do not see any log file in GeoServer. Thanks! – P G Apr 2 at 18:30
  • data_dir/log/goeserver.log – Ian Turton Apr 3 at 7:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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