0

I have published a NetCDF file (received on 2018-01-02, hourly data over the following 7 days) to GeoServer as WMS with Time enabled.

I was able to preview the layer with OpenLayers with the "time" attribute attached to the URL to the GetMap command.

http://{GEOSERVER_DOMAIN}:8080/geoserver/fdi/wms?service=WMS&time=2018-01-02T01:00:00.0Z&version=1.1.0&request=GetMap&layers=fdi:GFDI_SFC&styles=&bbox=140.8879867553711,-39.76999832100885,151.05409088134766,-33.929998627233346&width=768&height=441&srs=EPSG:4326&format=application/openlayers#toggle

The project I am working on requires the NetCDF file to be updated on GeoServer on a daily basis.

When I was doing some testing with the 2017-12-28 data (3 days older), I was not able to preview the image for 2017-12-28T01:00:00.0Z

http://{GEOSERVER_DOMAIN}:8080/geoserver/fdi/wms?service=WMS&time=2017-12-28T01:00:00.0Z&version=1.1.0&request=GetMap&layers=fdi:GFDI_SFC&styles=&bbox=140.8879867553711,-39.76999832100885,151.05409088134766,-33.929998627233346&width=768&height=441&srs=EPSG:4326&format=application/openlayers#toggle

I was not able to preview data for any date and time earlier than 2018-01-02T01:00:00.0Z.

I have turned off Tile Caching and did disable and enable the NetCDF data store.

Is there anything else I need to look at/adjust to get this working? Is this a good practice to update the data source on a regular basis on GeoServer.

Edit - time dimension from the GetCapabilities request

<Dimension name="time" default="2017-12-27T18:00:00Z" units="ISO8601">
2017-12-27T18:00:00.000Z/2017-12-27T18:00:00.000Z/PT1S,2017-12-27T19:00:00.000Z/2017-12-27T19:00:00.000Z/PT1S,2017-12-27T20:00:00.000Z/2017-12-27T20:00:00.000Z/PT1S,2017-12-27T21:00:00.000Z/2017-12-27T21:00:00.000Z/PT1S,2017-12-27T22:00:00.000Z/2017-12-27T22:00:00.000Z/PT1S,2017-12-27T23:00:00.000Z/2017-12-27T23:00:00.000Z/PT1S,2017-12-28T00:00:00.000Z/2017-12-28T00:00:00.000Z/PT1S,2017-12-28T01:00:00.000Z/2017-12-28T01:00:00.000Z/PT1S,2017-12-28T02:00:00.000Z/2017-12-28T02:00:00.000Z/PT1S,2017-12-28T03:00:00.000Z/2017-12-28T03:00:00.000Z/PT1S,2017-12-28T04:00:00.000Z/2017-12-28T04:00:00.000Z/PT1S,
... ...
</Dimension>
6
  • can you add the time period list from the getcapabilities request to the question please
    – Ian Turton
    Commented Jan 2, 2018 at 8:50
  • It is not bad practice to have a data source that regularly updates.
    – nmtoken
    Commented Jan 2, 2018 at 8:58
  • How did you update the file? Commented Jan 2, 2018 at 10:16
  • @AndreaAime. I copied the new NetCDF file to the data source folder and replaced the old one (they both have the same file name): file:workspaces/fdi/data/IDV71122_VIC_GFDI_SFC.nc. Then I disabled the data store and re-enabled it to update the time list for the Time dimension.
    – alextc
    Commented Jan 2, 2018 at 11:19
  • does requesting 2017-12-28T02:00:00.000Z/2017-12-28T02:00:00.000Z work?
    – Ian Turton
    Commented Jan 2, 2018 at 11:27

2 Answers 2

3

Just replacing the NetCDF file on disk, behind GeoServer's back, will not work in general for a couple of reasons:

  • Some information about the file is kept in memory, the new file might have a different set
  • To speed up access to the file contents a set of index files is kept on disk, which will become outdated vs the new file. The indexes are kept in a hiddent (starting with a ".") directory on the side of the NetCDF file.

Options:

  • Clean up the indexes along with the file and then force GeoServer to flush its cached information by summitting a reset command (e..g, from the UI, the "clear" button in the status page, or using the REST API)
  • Use the REST API to remove and re-create the file and associated layers
2
  • Thanks Andrea! Simply clearing the caching on the status page did not help. The way I got it working is disabling the NetCDF data store, deleting the directory (starting with a "." followed by the store name and unique identifier) alongside the NetCDF file, replacing the NetCDF file, and then re-enabling the data store.
    – alextc
    Commented Jan 2, 2018 at 22:55
  • I found that overwriting the NetCDF file, and then disabling/re-enabling the store did the trick. Commented Nov 12, 2019 at 20:01
0

Here is a script I made to refresh NetCDF coveragestores. It downloads the list of existing coveragestores, parses it using jq (a JSON commandline utility), downloads each one, and re-uploads each one.

srcdir="$(dirname "$0")"
source $srcdir/variables.sh
curl -u $username:$password $geoserver_base_url/geoserver/rest/workspaces/$workspace/coveragestores.json | jq '.coverageStores.coverageStore|.[]|map(.)|.[]'| while read name; read url
do
    name=`echo $name|sed 's!"!!g'`
    url=`echo $url |sed 's!"!!g'`
    coveragestore="${srcdir}/coveragestores/${name}.json"
    curl -u $username:$password $url > $coveragestore
    curl -u $username:$password -XPUT -H "Content-type: application/json" -d @$coveragestore $url
done

variables.sh just contains things like $username, $password, $workspace and $geoserver_base_url (pretty self-explanatory variables).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.