如何使用geoserver-restconfig python包创建一个覆盖范围存储?

huangapple go评论62阅读模式
英文:

How to create a coverage store using the geoserver-restconfig python package?

问题

我的操作系统是Ubuntu 22.04.2 LTS,Python版本是3.10.6。我正在尝试使用geoserver-restconfig Python包在Geoserver中创建一个覆盖范围存储。以下是我的代码:

from geoserver.catalog import Catalog
cat = Catalog(service_url='http://localhost:8080/geoserver/rest',
              username='FAKE_USERNAME',
              password='FAKE_PASSWORD')

# 创建工作空间
cat.create_workspace(name='demo', uri='http://demo')

# 创建覆盖范围存储
path = 'indicators/coolingdd/rcp_2_6/ensemble/coolingdd_rcp26_multi-model-mean_-_-_20210101-20301230.tiff'
cat.create_coveragestore(name='NAME',
                         workspace='demo',
                         path=path,
                         type='GeoTIFF',
                         create_layer=True,
                         layer_name='TITLE',
                         upload_data=False)

不幸的是,我遇到了以下错误:

Traceback (most recent call last):
  File "/home/iliamous/PycharmProjects/winbank-esg-risk-gis-platform/scratch_work.py", line 767, in <module>
    cat.create_coveragestore(name='NAME',
  File "/home/iliamous/.local/lib/python3.10/site-packages/geoserver/catalog.py", line 617, in create_coveragestore
    raise FailedRequestError('Failed to create coverage/layer {} for : {}, {}'.format(layer_name, name,
geoserver.catalog.FailedRequestError: Failed to create coverage/layer TITLE for : NAME, 500

发生这种情况的原因是什么?

英文:

My os is Ubuntu 22.04.2 LTS and my python versions is 3.10.6. I am trying to create a coverage store in geoserver using the geoserver-restconfig python package. Here is my code:

from geoserver.catalog import Catalog
cat = Catalog(service_url=&#39;http://localhost:8080/geoserver/rest&#39;,
              username=&#39;FAKE_USERNAME&#39;,
              password=&#39;FAKE_PASSWORD&#39;)

# Create working space
cat.create_workspace(name=&#39;demo&#39;, uri=&#39;http://demo&#39;)

# Create coverage store
path = &#39;indicators/coolingdd/rcp_2_6/ensemble/coolingdd_rcp26_multi-model-mean_-_-_20210101-20301230.tiff&#39;
cat.create_coveragestore(name=&#39;NAME&#39;,
                         workspace=&#39;demo&#39;,
                         path=path,
                         type=&#39;GeoTIFF&#39;,
                         create_layer=True,
                         layer_name=&#39;TITLE&#39;,
                         upload_data=False)

The indicators directory is inside the directory where I am running my python script from. Unfortunately I am getting the following error:

Traceback (most recent call last):
  File &quot;/home/iliamous/PycharmProjects/winbank-esg-risk-gis-platform/scratch_work.py&quot;, line 767, in &lt;module&gt;
    cat.create_coveragestore(name=&#39;NAME&#39;,
  File &quot;/home/iliamous/.local/lib/python3.10/site-packages/geoserver/catalog.py&quot;, line 617, in create_coveragestore
    raise FailedRequestError(&#39;Failed to create coverage/layer {} for : {}, {}&#39;.format(layer_name, name,
geoserver.catalog.FailedRequestError: Failed to create coverage/layer TITLE for : NAME, 500

Why is this happening?


----------------------------Update---------------------------------

I have changed the logging level to developer from the global settings but I still receive the same error. This is what my global settings look like:
如何使用geoserver-restconfig python包创建一个覆盖范围存储?


--------------------------------Update-------------------------------

Here is the relevant part of the log files:

06 Mar 11:25:48 WARN   [gce.geotiff] - File /var/lib/tomcat9/webapps/geoserver/data/indicators/coolingdd/rcp_2_6/ensemble/coolingdd_rcp26_multi-model-mean_-_-_20210101-20301230.tiff does not exist.
org.geotools.data.DataSourceException: File /var/lib/tomcat9/webapps/geoserver/data/indicators/coolingdd/rcp_2_6/ensemble/coolingdd_rcp26_multi-model-mean_-_-_20210101-20301230.tiff does not exist.

My understanding was that the create_coveragestore function also uploaded the tiff file to the geoserver. Apparently, I have to upload the files inside the data directory and then use the function with the correct path from the data directory of geoserver to create the coverage store.

答案1

得分: 0

在将指标目录上传到 /var/lib/tomcat9/webapps/geoserver/data 目录后,一切都正常工作。显然,为路径参数创建 create_coveragestory 根目录是数据目录。

英文:

After uploading the indicators directory to /var/lib/tomcat9/webapps/geoserver/data directory everything works fine. Apparently, create_coveragestory root directory for the path parameter is the data directory.

huangapple
  • 本文由 发表于 2023年3月3日 21:27:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/75627677.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定