英文:
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='http://localhost:8080/geoserver/rest',
username='FAKE_USERNAME',
password='FAKE_PASSWORD')
# Create working space
cat.create_workspace(name='demo', uri='http://demo')
# Create coverage store
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)
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 "/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
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:
--------------------------------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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论