AWIPS Tips: Maps Database Constraints

AWIPS Tips

Welcome back to AWIPS Tips!

This week we are going to look at modifying the Cities Map resource by constraining the population based on information in the database. This work will be accomplished by modifying the specific bundle file using the Localization Perspective in CAVE.

In a previous blog post, we looked at how to add new shapefiles to the maps database and create a bundle file and menu option. The associated bundle file for most of the options in the Maps menu makes use of the PostGIS extension of the PostgresQL database which allows us to access specific attributes. This means we can include constraints on different attributes being queried from the database, so we can refine the plot to what we want. In this blog, we’ll give an example of how to modify the bundle file for the Cities map, so only cities with a population greater than 25,000 are plotted.

We will start by opening up the localization perspective through the menus with CAVE > Perspective > Localization. This should remove your D2D (map) perspective and now show a file navigation view on the left hand side.

Expand CAVE > Bundles > maps > Cities.xml

Right click on BASE and select Copy To > New File... Call the new file cities25.xml.

NOTE: As stated in a previous blog, you should never edit the BASE file.

Double click on the new cities25.xml file that you created. Click on the Source tab at the bottom of the editor window. In the mapName tag add:

> 25,000

Your code should look like this:

This step just adds a new menu entry to the Maps menu, we still need to add the constraints. In order to do this, we need to know what datatype population is in the maps database. Refer to our maps database appendix for the mapdata.city database. Here it shows that population is a character datatype, which means we’ll have to typecast to a numeric field.

After the mapName we’ll want to add in the constraint logic:

population not like '%Null%' and population::numeric > 25000

Restart CAVE, and now load Maps > Cities > 25,000. When you zoom in, you should only see cities with populations over 25,000.

Again, you can refer back to our maps database documentation to see what fields are available to constrain against and what datatype each field is.

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

Comments:

Post a Comment:
Comments are closed for this entry.
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
« February 2024
SunMonTueWedThuFriSat
    
2
3
4
6
8
9
10
11
13
15
16
17
18
19
20
22
23
24
25
26
27
28
29
  
       
Today