Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate MBTiles using WPS process in GeoServer?

How to generate MBTiles in GeoServer? Using OpenLayers for displaying a GeoServer layer. For example calling a WMS layer like this:

new OpenLayers.Layer.WMS("Kanpur", "http://localhost:8080/geoserver/wms", {
       LAYERS: 'sample_data_old:sample',
        STYLES: '',
        format: 'image/jpeg',
        tiled: false,
        transparent: true,
        tilesOrigin : map.maxExtent.left + ',' + map.maxExtent.bottom,
        visibility:false
    }, { 
        isBaseLayer: true 
    }  
);

How can I call WPS layer for creating MBTiles? Please refer this link for my question:

http://docs.geoserver.org/stable/en/user/community/mbtiles/output.html

like image 349
renjith Avatar asked Dec 09 '25 07:12

renjith


1 Answers

I reached this question while trying to achieve just the same output as @renjith

So, here's what I did to generate MBTiles using GeoServer 2.19.4

Steps:

  • Enable GDAL native libs on GeoServer by installing GDAL plugin, refer to this link: GeoServer-gdal
  • Enable WPS on GeoServer by installing WPS plugin, refer to this link: GeoServer-WPS
  • Enable MBTiles read/write on GeoServer by installing MBTiles source/plugin, refer to this link: GeoServer-MBTiles

Make sure to match plugins versions with your GeoServer instance version!

After successful installation of the above requirements, you should be able to generate MBTiles of your datasource.

Using WPS request to your server

<?xml version="1.0" encoding="UTF-8"?>
<wps:Execute version="1.0.0" service="WPS"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://www.opengis.net/wps/1.0.0"
    xmlns:wfs="http://www.opengis.net/wfs"
    xmlns:wps="http://www.opengis.net/wps/1.0.0"
    xmlns:ows="http://www.opengis.net/ows/1.1"
    xmlns:gml="http://www.opengis.net/gml"
    xmlns:ogc="http://www.opengis.net/ogc"
    xmlns:wcs="http://www.opengis.net/wcs/1.1.1"
    xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd">
    <ows:Identifier>gs:MBTiles</ows:Identifier>
    <wps:DataInputs>
        <wps:Input>
            <ows:Identifier>layers</ows:Identifier>
            <wps:Data>
                <wps:LiteralData>layerName</wps:LiteralData>
            </wps:Data>
        </wps:Input>
        <wps:Input>
            <ows:Identifier>format</ows:Identifier>
            <wps:Data>
                <wps:LiteralData>imageFormat</wps:LiteralData>
            </wps:Data>
        </wps:Input>
        <wps:Input>
            <ows:Identifier>boundingbox</ows:Identifier>
            <wps:Data>
                <wps:BoundingBoxData crs="layerCRS" dimensions="2">
                    <ows:LowerCorner>MinX MinY</ows:LowerCorner>
                    <ows:UpperCorner>MaxX MaxY</ows:UpperCorner>
                </wps:BoundingBoxData>
            </wps:Data>
        </wps:Input>
        <wps:Input>
            <ows:Identifier>filename</ows:Identifier>
            <wps:Data>
                <wps:LiteralData>fileName</wps:LiteralData>
            </wps:Data>
        </wps:Input>
        <wps:Input>
            <ows:Identifier>minZoom</ows:Identifier>
            <wps:Data>
                <wps:LiteralData>minZoom</wps:LiteralData>
            </wps:Data>
        </wps:Input>
        <wps:Input>
            <ows:Identifier>maxZoom</ows:Identifier>
            <wps:Data>
                <wps:LiteralData>maxZoom</wps:LiteralData>
            </wps:Data>
        </wps:Input>
    </wps:DataInputs>
    <wps:ResponseForm>
        <wps:RawDataOutput>
            <ows:Identifier>outputFormat</ows:Identifier>
        </wps:RawDataOutput>
    </wps:ResponseForm>
</wps:Execute>

Make sure to replace each input to match your needs!

  • layerName ==> workspace:layer
  • imageFormat ==> png or jpeg
  • MinX MinY ==> Space separated values
  • MaxX MaxY ==> Space separated values
  • fileName ==> Output file name
  • minZoom ==> Minimum zoom level inclusive
  • maxZoom ==> Maximum zoom level exclusive (If 20 is the value, only 19 zoom levels will be generated)
  • outputFormat ==> mbtiles

This request may require basic authentication if map services are protected, and will return a URL of available generated file to be downloaded!

like image 147
ca5p3r Avatar answered Dec 11 '25 11:12

ca5p3r



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!