すべてのプロダクト
Search
ドキュメントセンター

PolarDB:ラスターデータの公開

最終更新日:Jan 23, 2025

このトピックでは、GeoServerを使用してGanosBaseデータベースにラスタデータを公開する方法について説明します。

データソースの追加

説明

GeoServer webポータルは、GeoServerのバージョンによって異なります。 このトピックでは、GeoServer 2.23.2を使用します。

  1. GeoServer を実行します。 左側のナビゲーションウィンドウで、[ストア] をクリックします。

    image.png

  2. [ストア] ページで、[新しいストアの追加] をクリックします。image.png

  3. 表示されるダイアログボックスの [ラスターデータソース] セクションで、[GanosRaster(PG/PolarDB)] を選択します。image.png

  4. GanosBaseデータベースの接続パラメーターを設定します。

    パラメーター

    説明

    値の例

    ホスト

    データベースが存在するApsaraDB RDSインスタンスのIPアドレスまたはエンドポイント。

    xxxxxxx.pg.rds.aliyuncs.com

    ポート

    データベースのポート番号です。

    3432

    データベース

    データベースの名前。

    rasterdb

    ユーザー名

    データベースへのログインに使用されるアカウントのユーザー名。

    pguser

    パスワード

    アカウントのパスワードを入力します。

    123456

    スキーマ

    テーブルのスキーマ。

    デフォルト値 : public

    テーブル

    ラスターデータを格納するテーブルの名前です。

    raster_table

    列名

    テーブル内のラスター列の名前。

    raster_column

    フィルター

    ラスタデータをフィルタリングするために、SQL文のWHERE句で指定された条件。 複数のラスターが条件を満たす場合、最初のラスターが使用されます。

    id=1 or name='srtm'

    name

    GeoServerに表示されるラスターの名前。

    myraster

RESTful API の使用

  • データソースの作成

    • リクエスト URL : http://host:port/geoserver/rest/workspaces/{workspace}/coveragestores

    • メソッド : POST

    • パラメーターの説明:

      • workspace : 作成されたワークスペースの名前

      • datastore body : データストアに関する情報です。 typeパラメーターのデフォルト値を維持し、urlパラメーターをJSON形式のApsaraDB RDS for PostgreSQLまたはApsaraDB for PolarDBインスタンスの接続情報に設定します。 次のコードスニペットに例を示します。

        {
          "coverageStore": {
            "name": "<datasource_name>",
            "type": "GanosRaster(PG/PolarDB)",
            "enabled":"true",
            "workspace":"<wokrspace>",
            "url": "{\"column\":\"<raster_column>\",\"database\":\"<database_name>\",\"filter\":\"<raster_filter>\",\"host\":\"<pg_host>\",\"name\":\"<public_name>\",\"password\":\"<user_password>\",\"port\":<pg_port>,\"schema\":\"<schema_name>\",\"ssl\":false,\"table\":\"<raster_table_name>\",\"userName\":\"<user_name>\",\"valid\":true}"
          }
        }
    • 例:

      {
        "coverageStore": {
          "name": "srtm",
          "type": "GanosRaster(PG/PolarDB)",
          "enabled":"true",
          "workspace":"test",
          "url": "{\"column\":\"rast\",\"database\":\"test_db\",\"filter\":\"name='srtm'\",\"host\":\"pgm-xxxxxxxx.pg.rds.aliyuncs.com\",\"name\":\"srtm_image\",\"password\":\"xxxx\",\"port\":3432,\"schema\":\"public\",\"ssl\":true,\"table\":\"raster_table\",\"userName\":\"raster_user\",\"valid\":true}"
        }
      }
  • データソースを取得します。

    • リクエスト URL : http://host:port/geoserver/rest/workspaces/{workspace}/coveragestores

    • メソッド: GET

    • パラメーターの説明:

      • workspace : 作成されたワークスペースの名前

      • datastore body : データストアに関する情報です。 タイプパラメーターをGanosRaster(PG/PolarDB) に設定し、urlパラメーターをRDSインスタンスまたはPolarDBクラスターに関する接続情報にJSON形式で設定します。 次のコードスニペットに例を示します。

        {
          "dataStores": {
            "dataStore": [
              {
                "name": "txxxxx_shp_filter",
                "href": "http://11.xxx.xxx.xxx:8080/geoserver/rest/workspaces/tianxun/datastores/txxxxx_shp_filter.json"
              },
              {
                "name": "yxxxxx_shape1",
                "href": "http://11.xxx.xxx.xxx:8080/geoserver/rest/workspaces/tianxun/datastores/yxxxxx_shape1.json"
              },
              {
                "name": "yxxxxxn_shape2",
                "href": "http://11.xxx.xxx.xxx:8080/geoserver/rest/workspaces/tianxun/datastores/yxxxxxn_shape2.json"
              }
            ]
          }
        }
  • ラスターレイヤーを公開します。

    • リクエストURL: http:// host:port/geoserver/rest/workspaces/{workspace}/coveragestores/{store}/coverages

    • メソッド : POST

    • パラメーターの説明:

      • workspace : 作成されたワークスペースの名前

      • 次のコードスニペットは、POSTリクエスト本文の例を示しています。

        {
          "coverage": {
            "abstract": "Digital elevation model for the Spearfish region.\r\n\r\nsfdem is a Tagged Image File Format with Geographic information",
            "defaultInterpolationMethod": "nearest neighbor",
            "description": "Generated from sfdem",
            "dimensions": {
              "coverageDimension": [
                {
                  "description": "GridSampleDimension[-9.999999933815813E36,-9.999999933815813E36]",
                  "name": "GRAY_INDEX",
                  "range": {
                    "max": -9.999999933815813e+36,
                    "min": -9.999999933815813e+36
                  }
                }
              ]
            },
            "enabled": true,
            "grid": {
              "@dimension": "2",
              "crs": "EPSG:26713",
              "range": {
                "high": "634 477",
                "low": "0 0"
              },
              "transform": {
                "scaleX": 30,
                "scaleY": -30,
                "shearX": 0,
                "shearY": 0,
                "translateX": 589995,
                "translateY": 4927995
              }
            },
            "interpolationMethods": {
              "string": [
                "nearest neighbor",
                "bilinear",
                "bicubic"
              ]
            },
            "keywords": {
              "string": [
                "WCS",
                "sfdem",
                "sfdem",
                "type\\@language=fr\\;\\@vocabulary=test\\;"
              ]
            },
            "latLonBoundingBox": {
              "crs": "EPSG:4326",
              "maxx": -103.62940739432703,
              "maxy": 44.5016011535299,
              "minx": -103.87108701853181,
              "miny": 44.370187074132616
            },
            "metadata": {
              "entry": [
                {
                  "@key": "elevation",
                  "dimensionInfo": {
                    "enabled": false
                  }
                },
                {
                  "$": "10",
                  "@key": "cacheAgeMax"
                },
                {
                  "@key": "time",
                  "dimensionInfo": {
                    "defaultValue": "",
                    "enabled": false
                  }
                },
                {
                  "$": "true",
                  "@key": "cachingEnabled"
                },
                {
                  "$": "sfdem_sfdem",
                  "@key": "dirName"
                }
              ]
            },
            "name": "sfdem",
            "namespace": {
              "href": "http://localhost:8075/geoserver/restng/namespaces/sf.json",
              "name": "sf"
            },
            "nativeBoundingBox": {
              "crs": {
                "$": "EPSG:26713",
                "@class": "projected"
              },
              "maxx": 609000,
              "maxy": 4928010,
              "minx": 589980,
              "miny": 4913700
            },
            "nativeCRS": {
              "$": "PROJCS[\"NAD27 / UTM zone 13N\", \n  GEOGCS[\"NAD27\", \n    DATUM[\"North American Datum 1927\", \n      SPHEROID[\"Clarke 1866\", 6378206.4, 294.9786982138982, AUTHORITY[\"EPSG\",\"7008\"]], \n      TOWGS84[2.478, 149.752, 197.726, 0.526, -0.498, 0.501, 0.685], \n      AUTHORITY[\"EPSG\",\"6267\"]], \n    PRIMEM[\"Greenwich\", 0.0, AUTHORITY[\"EPSG\",\"8901\"]], \n    UNIT[\"degree\", 0.017453292519943295], \n    AXIS[\"Geodetic longitude\", EAST], \n    AXIS[\"Geodetic latitude\", NORTH], \n    AUTHORITY[\"EPSG\",\"4267\"]], \n  PROJECTION[\"Transverse_Mercator\", AUTHORITY[\"EPSG\",\"9807\"]], \n  PARAMETER[\"central_meridian\", -105.0], \n  PARAMETER[\"latitude_of_origin\", 0.0], \n  PARAMETER[\"scale_factor\", 0.9996], \n  PARAMETER[\"false_easting\", 500000.0], \n  PARAMETER[\"false_northing\", 0.0], \n  UNIT[\"m\", 1.0], \n  AXIS[\"Easting\", EAST], \n  AXIS[\"Northing\", NORTH], \n  AUTHORITY[\"EPSG\",\"26713\"]]",
              "@class": "projected"
            },
            "nativeFormat": "GeoTIFF",
            "nativeName": "sfdem",
            "requestSRS": {
              "string": [
                "EPSG:26713"
              ]
            },
            "responseSRS": {
              "string": [
                "EPSG:26713"
              ]
            },
            "srs": "EPSG:26713",
            "store": {
              "@class": "coverageStore",
              "href": "http://localhost:8075/geoserver/restng/workspaces/sf/coveragestores/sfdem.json",
              "name": "sf:sfdem"
            },
            "supportedFormats": {
              "string": [
                "ARCGRID",
                "IMAGEMOSAIC",
                "GTOPO30",
                "GEOTIFF",
                "GIF",
                "PNG",
                "JPEG",
                "TIFF"
              ]
            },
            "title": "Spearfish elevation"
          }
        }