Using Geoserver to display active data in a shapefile feature #652
-
I am developing a Tethys app that displays crop yield estimates by administrative districts in East Africa. I am using a shapefile that contains the estimates for each district for the last 20 years. I have loaded the shapefile into a GeoServer and have made a few test layers by creating an SLD for each of the years where the ogc:PropertyName is the year, which is also |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
@mlandsfeld it is definitely possible to modify/manage GeoServer on the fly/programmatically. GeoServer has a REST API that can be used to manage all the data in GeoServer including workspaces, stores, layers, and styles. The official way to interact with GeoServer in Tethys is through the SpatialDatasetServices API. Part of the API is the GeoServer SpatialDatasetEngine, which provides a Python wrapper around the GeoServer REST API. Here are links to the pertinent documentation: To add new Shapefiles to the GeoServer using GeoServer SpatialDatasetEngine you can use the For Styles, I'd recommend you look at creating a dynamic style that leverages GeoServer's variable substitution, which will allow you to do things like change the colors or breakpoints through the URL parameters of the layer request. See: Variable Substitution. NOTE: The Spatial Dataset Services API has been designed to work with the version of GeoServer provided by the Docker image you can install with Tethys (I believe it is version 2.08 at the time of writing). It probably won't work on newer versions of GeoServer. However, there are other Python packages for working with the GeoServer REST API that would work equally well: Of course, you can also use the GeoServer REST API directly using something like the Python requests module. |
Beta Was this translation helpful? Give feedback.
@mlandsfeld it is definitely possible to modify/manage GeoServer on the fly/programmatically. GeoServer has a REST API that can be used to manage all the data in GeoServer including workspaces, stores, layers, and styles. The official way to interact with GeoServer in Tethys is through the SpatialDatasetServices API. Part of the API is the GeoServer SpatialDatasetEngine, which provides a Python wrapper around the GeoServer REST API. Here are links to the pertinent documentation:
To add new Shapefiles to the GeoServer using GeoServer SpatialDatasetEngine you can use the
create_shapefile_resource()
method as illustrated i…