Difference between revisions of "EWX"

From CHG-Wiki
Jump to navigationJump to search
m (Minor formatting changes.)
Line 1: Line 1:
  
= Adding a data layer to the EWX GeoServer =
+
== Adding a data layer to the EWX GeoServer ==
==Copy data files==
+
===Copy data files===
Put GeoTiff files in C:\EWX\data\xxx
+
Put GeoTiff files in C:\EWX\data\xxx on [[chg2]].
  
==Add dataset tag==
+
===Add dataset tag===
 
Add, or copy and paste, a <dataset> tag in the C:\EWX\geoserver-2.1.1\data_dir\updater\datasets.xml file for the new dataset.
 
Add, or copy and paste, a <dataset> tag in the C:\EWX\geoserver-2.1.1\data_dir\updater\datasets.xml file for the new dataset.
: Note: it is convenient to use the Programmer's Notepad with this file and control-click the first <datasets> tag closed and then click it open (without the control key) to open it back up with all other tags closed.
+
'''Note:''' It is convenient to use 'Programmer's Notepad' with this file - control-click the first <datasets> tag closed and then click it open (without the control key) to open it back up with all other tags closed.
  
==Set variables in dataset tag==
+
===Set variables in dataset tag===
 
Set the variables in the dataset tag:
 
Set the variables in the dataset tag:
:reloadAll: "true" or "false" depending if you want to reload the workspace and recalculate all the statistics.
+
*'''reloadAll:''' "true" or "false" depending if you want to reload the workspace and recalculate all the statistics.
:id: This is used as a referenced used with the window tag id attribute. See <window> tag below. This is also used as a prepend for the database spatial statistics table name.
+
*'''id:''' This is used as a referenced used with the window tag id attribute. See <window> tag below. This is also used as a prepend for the database spatial statistics table name.
:'''Important''' This name can not contain the special characters "_" or "-".
+
*'''Important:''' This name can not contain the special characters "_" or "-".
:directoryPath: The location of the data files.
+
*'''directoryPath:''' The location of the data files.
:name: The name used in the dataset listing in the left column of EWX.
+
*'''name:''' The name used in the dataset listing in the left column of EWX.
:shortName: Not sure where this is used for.
+
*'''shortName:''' Not sure where this is used for.
:dataType: "RASTER" or "VECTOR"
+
*'''dataType:''' "RASTER" or "VECTOR"
:fileType: "GeoTIFF" or "Shapefile"
+
*'''fileType:''' "GeoTIFF" or "Shapefile"
:workspace: Name of the workspace folder in C:\EWX\geoserver-2.1.1\data_dir\workspaces that will be created.
+
*'''workspace:''' Name of the workspace folder in C:\EWX\geoserver-2.1.1\data_dir\workspaces that will be created.
::This name also defines the start of the name of the GeoTIFF file that is used to calculate geo-statistics.  
+
**This name also defines the start of the name of the GeoTIFF file that is used to calculate geo-statistics.  
::'''Important''' This name can not contain the special characters "_" or "-". EWX will truncate the name at the first special character and use that to find the GeoTIFF file for spatial statistics.
+
**'''Important''' This name can not contain the special characters "_" or "-". EWX will truncate the name at the first special character and use that to find the GeoTIFF file for spatial statistics.
::This word also is used to define the start of the database table.
+
**This word also is used to define the start of the database table.
:fileNameSuffix: "tiff" or "tif"
+
*fileNameSuffix: "tiff" or "tif"
:showInTree: "true" or "false" to show dataset in left column of EWX. Default is true.
+
*'''showInTree:''' "true" or "false" to show dataset in left column of EWX. Default is true.
  
==Add a region tag==
+
===Add a region tag===
 
If this is a new region, add a <region> tag in datasets.xml
 
If this is a new region, add a <region> tag in datasets.xml
 
Copy and past from existing region tag and change id, name and coordinates.
 
Copy and past from existing region tag and change id, name and coordinates.
Line 44: Line 44:
 
:</region>
 
:</region>
  
==Add a window tag==
+
===Add a window tag===
 
Add a <window> tag for the new dataset
 
Add a <window> tag for the new dataset
 
:id: This attribute should be a combination of the region and dataset-ref attributes (see below) separated by a hyphen.
 
:id: This attribute should be a combination of the region and dataset-ref attributes (see below) separated by a hyphen.
Line 56: Line 56:
 
::::<related-layer dataset-ref="global_g2008" file-ref="global_g2008_0" name="Countries" initially-visible="true" />
 
::::<related-layer dataset-ref="global_g2008" file-ref="global_g2008_0" name="Countries" initially-visible="true" />
  
==Copy statistics TIFF files==
+
===Copy statistics TIFF files===
 
Add a tif file and associated files to the GAUL data directory. C:\EWX\data\GAUL
 
Add a tif file and associated files to the GAUL data directory. C:\EWX\data\GAUL
 
Associate files are: tfw, tif.aux.xml, tif.vat.dbf, xml files.
 
Associate files are: tfw, tif.aux.xml, tif.vat.dbf, xml files.
Line 64: Line 64:
 
The new name is a combination of the dataset id, region and shapefile defining the sub-regions.
 
The new name is a combination of the dataset id, region and shapefile defining the sub-regions.
  
cp chirps_global_cropzones.tfw        chirpsclim_global_cropzones.tfw
+
cp chirps_global_cropzones.tfw        chirpsclim_global_cropzones.tfw
cp chirps_global_cropzones.tif        chirpsclim_global_cropzones.tif
+
cp chirps_global_cropzones.tif        chirpsclim_global_cropzones.tif
cp chirps_global_cropzones.tif.aux.xml chirpsclim_global_cropzones.tif.aux.xml
+
cp chirps_global_cropzones.tif.aux.xml chirpsclim_global_cropzones.tif.aux.xml
cp chirps_global_cropzones.tif.vat.dbf chirpsclim_global_cropzones.tif.vat.dbf
+
cp chirps_global_cropzones.tif.vat.dbf chirpsclim_global_cropzones.tif.vat.dbf
cp chirps_global_cropzones.tif.xml    chirpsclim_global_cropzones.tif.xml
+
cp chirps_global_cropzones.tif.xml    chirpsclim_global_cropzones.tif.xml
  
==Create TIFF for statistics in ArcMap==
+
===Create TIFF for statistics in ArcMap===
  
If the previous method can not be employed then this is the proceedure to follow...  
+
If the previous method can not be employed then this is the procedure to follow...  
 
good luck!
 
good luck!
  
 
Copy the shape files and a raster file to your ArcMap workspace:
 
Copy the shape files and a raster file to your ArcMap workspace:
:copy C:\EWX\data\GAUL\Africa\g_2008_1.*  C:\Users\marty\Documents\ArcGIS\CHIRPS_EAC
+
copy C:\EWX\data\GAUL\Africa\g_2008_1.*  C:\Users\marty\Documents\ArcGIS\CHIRPS_EAC
:copy C:\EWX\data\CHIRP_EAC\monthly\data.1982.01.tiff
+
copy C:\EWX\data\CHIRP_EAC\monthly\data.1982.01.tiff
  
In ArcMap add one of the dataset's raster files and the cooresponding vector shape file.
+
In ArcMap, add one of the dataset's raster files and the corresponding vector shape file:
:File>Add Data, CHIRPS_EAC\g_2008_1.shp
+
File>Add Data, CHIRPS_EAC\g_2008_1.shp
:File>Add Data, CHIRPS_EAC\data.1982.01.tiff
+
File>Add Data, CHIRPS_EAC\data.1982.01.tiff
 
 
 
Open Catalog>Toolboxes>System toolboxes>Conversion Tools>ToRaster>Feature to Raster
 
Open Catalog>Toolboxes>System toolboxes>Conversion Tools>ToRaster>Feature to Raster
:Input Features
+
Input Features
::g2008_0
+
  g2008_0
:Value field
+
Value field
::FEW_ID
+
  FEW_ID
:Output Raster Dataset
+
Output Raster Dataset
::C:\EWX\data\GAUL\Global\chirpseac_g2008_1_int.tif
+
  C:\EWX\data\GAUL\Global\chirpseac_g2008_1_int.tif
::Note: Add _int to the name as this is the default data type. You can copy out as a float later.
+
'''Note:''' Add _int to the name as this is the default data type. You can copy out as a float later.
:Cell assisgnment type
+
Cell assignment type
::CELL_CENTER
+
  CELL_CENTER
:Priority field
+
Priority field
::NONE
+
  NONE
:Cellsize
+
Cellsize
::0.050000001, note: this should be autofilled when you select the file in Environments/Processing Extent (see below) but it isn't.  
+
  0.050000001, '''Note:''' this should be autofilled when you select the file in Environments/Processing Extent (see below) but it isn't.  
::It is when you select Feature to Raster so a workaround is to open that and copy the numbers.
+
  It is when you select Feature to Raster so a workaround is to open that and copy the numbers.
 
 
 
Open Environments.../
 
Open Environments.../
:Output Coordinate System
+
Output Coordinate System
::Same as layer "data.1982.01.tiff"
+
  Same as layer "data.1982.01.tiff"
 
 
:Processing Extent and chose raster file.
+
Processing Extent and chose raster file.
::Extent
+
  Extent
:::Same as layer data.1982.01.tiff
+
    Same as layer data.1982.01.tiff
::Snap Raster
+
  Snap Raster
:::data.1982.01.tiff
+
    data.1982.01.tiff
 
 
:Raster Storage
+
Raster Storage
::unselect Build pyramids
+
  unselect Build pyramids
::unselect Calculate Statistics
+
  unselect Calculate Statistics
:Compression
+
Compression
::NONE
+
  NONE
:OK
+
OK
:OK
+
OK
 
 
This should be enough but the tif is not parsible by EWX so it hast to be copied out as a 32 bit float image.
+
This should be enough but the tif is not parsable by EWX so it hast to be copied out as a 32 bit float image.
 
Open ArcToolbox>Data Management Tools>Raster>Raster Dataset>Copy Raster.
 
Open ArcToolbox>Data Management Tools>Raster>Raster Dataset>Copy Raster.
:Input Raster
+
Input Raster
::chirpseac_g2008_1_int
+
  chirpseac_g2008_1_int
:Output Raster Dataset
+
Output Raster Dataset
::C:\EWX\data\GAUL\Global\chirpseac_g2008_1.tif
+
  C:\EWX\data\GAUL\Global\chirpseac_g2008_1.tif
:Pixel Type
+
Pixel Type
::32_BIT_FLOAT
+
  32_BIT_FLOAT
 
Then remove the integer tif and place a copy of the tif files into the GAUL directory.
 
Then remove the integer tif and place a copy of the tif files into the GAUL directory.
  
==Validate datasets.xml==
+
===Validate datasets.xml===
Run the datasets.xml file throught an online xml validator ([http://www.w3schools.com/xml/xml_validator.asp]) to be sure you didn't mess something up.
+
Run the datasets.xml file through an online xml validator (http://www.w3schools.com/xml/xml_validator.asp) to be sure you didn't mess something up.
  
 
==Clear GeoWebCache==
 
==Clear GeoWebCache==
Make sure the GeoWebCache directory is cleared for the dataset before restarting. There may be some cruft
+
Make sure the GeoWebCache directory is cleared for the dataset before restarting. There may be some cruft in there from previous attempts.  
in there from previous attempts.  
+
C:\EWX\geoserver-2.1.1\data_dir\gwc
:C:\EWX\geoserver-2.1.1\data_dir\gwc
 
  
==Restart EWX==
+
===Restart EWX===
:cd /cygdrive/c/EWX/apache-tomcat-6.0.33/bin; ./catalina.bat stop
+
cd /cygdrive/c/EWX/apache-tomcat-6.0.33/bin; ./catalina.bat stop
:cd /cygdrive/c/EWX/apache-tomcat-6.0.33/bin; ./catalina.bat start
+
cd /cygdrive/c/EWX/apache-tomcat-6.0.33/bin; ./catalina.bat start
  
 
+
== Adding a "style" to the EWX GeoServer ==
= Adding a "style" to the EWX GeoServer =
 
  
 
Styles modify the maps being displayed by the EWX server. The GeoServer v.2.1.1, which actually serves the maps, uses the Styled Layer Descriptor (SLD) markup language to do this. An intro to SLD can be found at:
 
Styles modify the maps being displayed by the EWX server. The GeoServer v.2.1.1, which actually serves the maps, uses the Styled Layer Descriptor (SLD) markup language to do this. An intro to SLD can be found at:
 
+
http://docs.geoserver.org/2.1.1/user/styling/sld-introduction.html
[http://docs.geoserver.org/2.1.1/user/styling/sld-introduction.html| http://docs.geoserver.org/2.1.1/user/styling/sld-introduction.html]
 
  
 
The styles are locate is this directory:
 
The styles are locate is this directory:
 
+
C:\EWX\geoserver-2.1.1\data_dir\styles
C:\EWX\geoserver-2.1.1\data_dir\styles
 
  
 
They consist of a .sld and a .xml file. The xml file is generated by the GeoServer upon submission of the sld file. A new SLD style file '''has''' to be submitted through the GeoServer admin interface located at:
 
They consist of a .sld and a .xml file. The xml file is generated by the GeoServer upon submission of the sld file. A new SLD style file '''has''' to be submitted through the GeoServer admin interface located at:
 +
http://chg2.geog.ucsb.edu:8080/geoserver/web
  
[http://chg2.geog.ucsb.edu:8080/geoserver/web| http://chg2.geog.ucsb.edu:8080/geoserver/web]
+
Log in as admin after you have received the password from Marty. Then click the "styles" link in the left hand pane and click "Add a new style". You can then copy and paste your SLD content into the editing window and use the "Validate" button to validate the markup code. You have to click the "Submit" button for the GeoServer to create the xml and sld files in the styles directory. You can then use the name you entered in the "Name" box in the datasets.xml file to connect a dataset to the new style. The datasets.xml file is located at:
 
 
Log in as admin after you have received the password from Marty. Then click the "styles" link in the left hand pane and then click on "Add a new style". You can then copy and paste your SLD content into the editing window and use the "Validate" button to validate the markup code. You have to click the "Submit" button for the GeoServer to create the xml and sld files in the styles directory. You can then use the name you entered in the "Name" box in the datasets.xml file to connect a dataset to the new style. The datasets.xml file is located at:
 
  
C:\EWX\geoserver-2.1.1\data_dir\updater
+
C:\EWX\geoserver-2.1.1\data_dir\updater
  
 
The name is entered as the ''style'' attribute to the ''statistic'' tag of the ''dataset'' tag.
 
The name is entered as the ''style'' attribute to the ''statistic'' tag of the ''dataset'' tag.
Line 169: Line 164:
 
** ./catalina.bat start
 
** ./catalina.bat start
  
 +
=== Tips ===
 +
Use the GeoServer admin interface to edit and modify your SLD file as it will color code your markup and you can submit and apply the modified version in the interface. You can then examine the results by going to and EWX window (http://chg2.geog.ucsb.edu:8080/EWX/index.html) and opening the dataset. If you are iterating through multiple changes, you will need to either remove the GeoWebCache files at:
  
----
+
C:\EWX\geoserver-2.1.1\data_dir\gwc
==== Tips ====
 
Use the GeoServer admin interface to edit and modify your SLD file as it will color code your markup and you can submit and apply the modified version in the interface. You can then examine the results by going to and EWX window ([http://chg2.geog.ucsb.edu:8080/EWX/index.html| http://chg2.geog.ucsb.edu:8080/EWX/index.html]) and opening the dataset. If you are iterating through multiple changes, you will need to either remove the GeoWebCache files at:
 
 
 
C:\EWX\geoserver-2.1.1\data_dir\gwc
 
  
 
or avoid viewing the same dataset and time period by progressing through the time series without selecting previously cached dates.
 
or avoid viewing the same dataset and time period by progressing through the time series without selecting previously cached dates.
Line 182: Line 175:
 
You can look for errors in the EWX log console (it appears when you start EWX) up or look in the log files at:
 
You can look for errors in the EWX log console (it appears when you start EWX) up or look in the log files at:
  
C:\EWX\apache-tomcat-6.0.33\logs\catalina.yyyy-mm-dd.log
+
C:\EWX\apache-tomcat-6.0.33\logs\catalina.yyyy-mm-dd.log
 
----
 
----

Revision as of 15:49, 4 September 2014

Adding a data layer to the EWX GeoServer

Copy data files

Put GeoTiff files in C:\EWX\data\xxx on chg2.

Add dataset tag

Add, or copy and paste, a <dataset> tag in the C:\EWX\geoserver-2.1.1\data_dir\updater\datasets.xml file for the new dataset. Note: It is convenient to use 'Programmer's Notepad' with this file - control-click the first <datasets> tag closed and then click it open (without the control key) to open it back up with all other tags closed.

Set variables in dataset tag

Set the variables in the dataset tag:

  • reloadAll: "true" or "false" depending if you want to reload the workspace and recalculate all the statistics.
  • id: This is used as a referenced used with the window tag id attribute. See <window> tag below. This is also used as a prepend for the database spatial statistics table name.
  • Important: This name can not contain the special characters "_" or "-".
  • directoryPath: The location of the data files.
  • name: The name used in the dataset listing in the left column of EWX.
  • shortName: Not sure where this is used for.
  • dataType: "RASTER" or "VECTOR"
  • fileType: "GeoTIFF" or "Shapefile"
  • workspace: Name of the workspace folder in C:\EWX\geoserver-2.1.1\data_dir\workspaces that will be created.
    • This name also defines the start of the name of the GeoTIFF file that is used to calculate geo-statistics.
    • Important This name can not contain the special characters "_" or "-". EWX will truncate the name at the first special character and use that to find the GeoTIFF file for spatial statistics.
    • This word also is used to define the start of the database table.
  • fileNameSuffix: "tiff" or "tif"
  • showInTree: "true" or "false" to show dataset in left column of EWX. Default is true.

Add a region tag

If this is a new region, add a <region> tag in datasets.xml Copy and past from existing region tag and change id, name and coordinates.

id: attribute to be referenced in window tag
name: label to use in EWX left hand pane
gridBounds: defines the min_lon, min_lat, max_lon, max_lat, respectively.
<region id="whem" name="Western Hemisphere">
<gridBounds>
<coords>
<double>-130.0</double>
<double>-50.0</double>
<double>-30.0</double>
<double>50.0</double>
</coords>
</gridBounds>
</region>

Add a window tag

Add a <window> tag for the new dataset

id: This attribute should be a combination of the region and dataset-ref attributes (see below) separated by a hyphen.
region: The region id tag to group this window under in EWX in the left hand pane.
dataset-ref: A reference to the dataset tag's id attribute to use.
label: The label to use in the EWX left hand pane.
related-layers: tag defining layers to display in and EWX data window "fly-out pane" activated by map's upper left corner "layers" icon.
<window id="global-chirpsclim" region-ref="global" dataset-ref="chirpsclim" label="CHIRPSclim">
<related-layers>
<related-layer dataset-ref="global_g2008" file-ref="global_g2008_0" name="Countries" initially-visible="true" />

Copy statistics TIFF files

Add a tif file and associated files to the GAUL data directory. C:\EWX\data\GAUL Associate files are: tfw, tif.aux.xml, tif.vat.dbf, xml files.

If this data layer has the same resolution, boundaries and target (cropzones, g2008_0, admin0) as another data layer, then the files can be copied and renamed for the new data layer. The new name is a combination of the dataset id, region and shapefile defining the sub-regions.

cp chirps_global_cropzones.tfw         chirpsclim_global_cropzones.tfw
cp chirps_global_cropzones.tif         chirpsclim_global_cropzones.tif
cp chirps_global_cropzones.tif.aux.xml chirpsclim_global_cropzones.tif.aux.xml
cp chirps_global_cropzones.tif.vat.dbf chirpsclim_global_cropzones.tif.vat.dbf
cp chirps_global_cropzones.tif.xml     chirpsclim_global_cropzones.tif.xml

Create TIFF for statistics in ArcMap

If the previous method can not be employed then this is the procedure to follow... good luck!

Copy the shape files and a raster file to your ArcMap workspace:

copy C:\EWX\data\GAUL\Africa\g_2008_1.*  C:\Users\marty\Documents\ArcGIS\CHIRPS_EAC
copy C:\EWX\data\CHIRP_EAC\monthly\data.1982.01.tiff

In ArcMap, add one of the dataset's raster files and the corresponding vector shape file:

File>Add Data, CHIRPS_EAC\g_2008_1.shp
File>Add Data, CHIRPS_EAC\data.1982.01.tiff

Open Catalog>Toolboxes>System toolboxes>Conversion Tools>ToRaster>Feature to Raster

Input Features
  g2008_0
Value field
  FEW_ID
Output Raster Dataset
  C:\EWX\data\GAUL\Global\chirpseac_g2008_1_int.tif

Note: Add _int to the name as this is the default data type. You can copy out as a float later.

Cell assignment type
  CELL_CENTER
Priority field
  NONE
Cellsize
  0.050000001, Note: this should be autofilled when you select the file in Environments/Processing Extent (see below) but it  isn't. 
  It is when you select Feature to Raster so a workaround is to open that and copy the numbers.

Open Environments.../

Output Coordinate System
  Same as layer "data.1982.01.tiff"
Processing Extent and chose raster file.
  Extent
   Same as layer data.1982.01.tiff
  Snap Raster
   data.1982.01.tiff
Raster Storage
  unselect Build pyramids
  unselect Calculate Statistics
Compression
  NONE
OK
OK

This should be enough but the tif is not parsable by EWX so it hast to be copied out as a 32 bit float image. Open ArcToolbox>Data Management Tools>Raster>Raster Dataset>Copy Raster.

Input Raster
  chirpseac_g2008_1_int
Output Raster Dataset
  C:\EWX\data\GAUL\Global\chirpseac_g2008_1.tif
Pixel Type
  32_BIT_FLOAT

Then remove the integer tif and place a copy of the tif files into the GAUL directory.

Validate datasets.xml

Run the datasets.xml file through an online xml validator (http://www.w3schools.com/xml/xml_validator.asp) to be sure you didn't mess something up.

Clear GeoWebCache

Make sure the GeoWebCache directory is cleared for the dataset before restarting. There may be some cruft in there from previous attempts.

C:\EWX\geoserver-2.1.1\data_dir\gwc

Restart EWX

cd /cygdrive/c/EWX/apache-tomcat-6.0.33/bin; ./catalina.bat stop
cd /cygdrive/c/EWX/apache-tomcat-6.0.33/bin; ./catalina.bat start

Adding a "style" to the EWX GeoServer

Styles modify the maps being displayed by the EWX server. The GeoServer v.2.1.1, which actually serves the maps, uses the Styled Layer Descriptor (SLD) markup language to do this. An intro to SLD can be found at:

http://docs.geoserver.org/2.1.1/user/styling/sld-introduction.html

The styles are locate is this directory:

C:\EWX\geoserver-2.1.1\data_dir\styles

They consist of a .sld and a .xml file. The xml file is generated by the GeoServer upon submission of the sld file. A new SLD style file has to be submitted through the GeoServer admin interface located at:

http://chg2.geog.ucsb.edu:8080/geoserver/web

Log in as admin after you have received the password from Marty. Then click the "styles" link in the left hand pane and click "Add a new style". You can then copy and paste your SLD content into the editing window and use the "Validate" button to validate the markup code. You have to click the "Submit" button for the GeoServer to create the xml and sld files in the styles directory. You can then use the name you entered in the "Name" box in the datasets.xml file to connect a dataset to the new style. The datasets.xml file is located at:

C:\EWX\geoserver-2.1.1\data_dir\updater

The name is entered as the style attribute to the statistic tag of the dataset tag.

If the style is being applied an existing dataset:

  • set the dataset reloadAll tag to true
  • remove the datasets workspace located at: C:\EWX\geoserver-2.1.1\data_dir\workspaces\…
  • stop and restart EWX in a cygwin terminal window on CHG2 with the following commands:
    • cd /cygdrive/c/EWX/apache-tomcat-6.0.33/bin
    • ./catalina.bat stop
    • cd /cygdrive/c/EWX/apache-tomcat-6.0.33/bin
    • ./catalina.bat start

Tips

Use the GeoServer admin interface to edit and modify your SLD file as it will color code your markup and you can submit and apply the modified version in the interface. You can then examine the results by going to and EWX window (http://chg2.geog.ucsb.edu:8080/EWX/index.html) and opening the dataset. If you are iterating through multiple changes, you will need to either remove the GeoWebCache files at:

C:\EWX\geoserver-2.1.1\data_dir\gwc

or avoid viewing the same dataset and time period by progressing through the time series without selecting previously cached dates.


You can look for errors in the EWX log console (it appears when you start EWX) up or look in the log files at:

C:\EWX\apache-tomcat-6.0.33\logs\catalina.yyyy-mm-dd.log