AWIPS Tips: Adding Shapefiles to the Maps Menu with EDEX

AWIPS Tips

Welcome back to AWIPS Tips!

If you are running your own EDEX and have a shapefile that you use consistently, instead of having to manually import it in CAVE, we’ll show you how to import it into the maps database and then add it to the Maps menu. As an example we will be adding the NWS Region shapefile to EDEX. A number of NWS shapefiles can be found here. First on your EDEX server as the awips user, change directories into your site's shapefile directory where ‘XXX’ is the site specified in your /awips2/edex/bin/setup.env file.

cd /awips2/edex/data/utility/common_static/site/XXX/shapefiles/

Create a directory that you would like the shapefile to be named and then change directories into it. In this case we will name it “NWSRegions”.

NOTE: The directory name does not have to match the filename, but do not use spaces or symbols in the name. This will be the name of the corresponding table in the maps database.

mkdir NWSRegions
cd NWSRegions

Next download the zipped shapefile via command line. On your EDEX machine you can do this with the command:

wget https://www.weather.gov/source/gis/Shapefiles/Misc/rw04oc12.zip

Extract the contents by unzipping the shapefile:

unzip rw04oc12.zip

You can delete the parent zip file if you’d like. You should now have files with the following extensions (plus a few others possibly):

  • dbf
  • shp
  • shx

Now that we have the shapefile, we need to insert it into the maps database. There is a script on your EDEX machine that will need to be run with the following arguments: the path to the specific shapefile and the new database table name.

/awips2/database/sqlScripts/share/sql/maps/importShapeFile.sh /awips2/edex/data/utility/common_static/site/OAX/shapefiles/NWSRegions/re04oc12.shp nwsregions

NOTE: Again, don’t use any symbols, spaces, or capital letters in the database name.

Typical output looks like:

Importing re04oc12.shp into mapdata.nwsregions ...
NOTICE: table "nwsregions" does not exist, skipping
Field lon is an FTDouble with width 19 and precision 5
Field lat is an FTDouble with width 19 and precision 5
Shapefile type: Polygon
Postgis type: MULTIPOLYGON[2]
addgeometrycolumn
----------------------------------------------------------------- mapdata.nwsregions.the_geom SRID:4326 TYPE:MULTIPOLYGON DIMS:2
(1 row)

Creating simplified geometry level 0.064 ...
Creating simplified geometry level 0.016 ...
Creating simplified geometry level 0.004 ...
Creating simplified geometry level 0.001 ...
vacuumdb: vacuuming database "maps"
INFO: vacuuming "mapdata.nwsregions"
INFO: "nwsregions": found 30 removable, 6 nonremovable row versions in 1 pages
DETAIL: 0 dead row versions cannot be removed yet.
CPU 0.04s/0.09u sec elapsed 0.14 sec.
INFO: analyzing "mapdata.nwsregions"
INFO: "nwsregions": scanned 1 of 1 pages, containing 6 live rows and 0 dead rows; 6 rows in sample, 6 estimated total rows

Now that the shapefile has been added to the maps database, we need to modify the maps menu to add it as a selection in CAVE. This is done via a map bundle xml file.

If the maps directory doesn’t exist, create it:

mkdir /awips2/edex/data/utility/common_static/base/bundles/maps

Create and open a new file, named nwsregions.xml using your favorite text editor:

vi nwsregions.xml

Copy the text from this file into the file you just opened (wget will work also)

NOTE: For other examples, the two lines you will want to edit are lines 15 and 16:

<table>mapdata.nwsregions</table>
<mapName>NWS Regions</mapName> Where the table name matches the name you used when running the importShapefile script and the mapName is whatever text you want to show up in the Maps menu. You can also change the default color (line 9). Save the file, close your CAVE session if open, remove caveData, and then re-open CAVE and you should see your new map listed in the Maps menu (the menu items are in alphabetical order)! Thanks for joining us to learn more about EDEX. Check back in two weeks for the next blog post! _To view archived blogs, visit the AWIPS Tips blog tag, and get notified of the latest updates from the AWIPS team by signing up for the AWIPS mailing list. Questions or suggestions for the team on future topics? Let us know at support-awips@unidata.ucar.edu_

This blog was posted in reference to v18.2.1-6 of NSF Unidata AWIPS

Comments:

Post a Comment:
  • HTML Syntax: Allowed
News@Unidata
News and information from the Unidata Program Center
News@Unidata
News and information from the Unidata Program Center

Welcome

FAQs

Developers’ blog

Take a poll!

What if we had an ongoing user poll in here?

Browse By Topic
Browse by Topic
« April 2024
SunMonTueWedThuFriSat
 
5
6
7
8
9
10
11
12
13
14
15
19
20
21
22
23
24
25
26
27
28
29
30
    
       
Today