Planet PostgreSQL

Planet PostgreSQL -

Martin Davis: SVG Images from Postgres

PostGIS excels at storing, manipulating and analyzing geospatial data. At some point it's usually desired to convert raw spatial data into a two-dimensional representation to utilize the integrative capabilities of the human visual cortex. In other words, to see things on a map. PostGIS is a popular backend for mapping technology, so there are many options to choose from to create maps. Data can be rendered to a raster image using a web map server like GeoServer or MapServer; it can be converted to GeoJSON or vector tiles via servers such as pg_featureserv and pg_tileserv and then shipped to a Web browser for rendering by a library such as OpenLayers, MapLibre or Leaflet; or a GIS application such as QGIS can connect to the database and create richly-styled maps from spatial queries. What these options have in common is that they require external tools which need to be installed, configured and maintained in a separate environment. This can introduce unwanted complexity to a geospatial architecture. This post presents a simple way to generate maps entirely within the database, with no external infrastructure required. SVG for the win A great way to display vector data is to use the Scalable Vector Graphic (SVG) format. It provides rich functionality for displaying and styling geometric shapes. SVG is widely supported by web browsers and other tools. By including CSS and Javascript it's possible to add advanced styling, custom popups, dynamic behaviour and interaction with other web page elements. Introducing pg-svg Generating SVG "by hand" is difficult. It requires detailed knowledge of the SVG specification, and constructing a complex text format in SQL is highly error-prone. While PostGIS has had the function ST_AsSVG for years, it only produces the SVG path data attribute value. Much more is required to create a fully-styled SVG document. The PL/pgSQL library pg-svg solves this problem! It makes it easy to convert PostGIS data into styled SVG documents. The library provid[...]

PostGIS是一种存储、操作和分析地理空间数据的工具,可以在数据库中生成地图的简单方法,使用可缩放矢量图形(SVG)格式可以很好地显示矢量数据。本文提供了一个示例,展示如何使用pg-svg生成美国高峰地图。最终生成的SVG地图可以在任何Web浏览器中查看。

PostGIS SVG pg-svg postgres 地理空间数据 美国高峰地图

相关推荐 去reddit讨论

热榜 Top10

eolink
eolink
LigaAI
LigaAI
观测云
观测云
Dify.AI
Dify.AI

推荐或自荐