thematic maps in GRASS

Playing with GRASS vector displays

####Trying with a vector map of Spain and Portugal admin boundaries:
# column attributes
v.info -c map=SpainPort

INTEGER|cat
INTEGER|ObjectID
CHARACTER|FIPS_ADMIN
CHARACTER|GMI_ADMIN
CHARACTER|ADMIN_NAME
CHARACTER|FIPS_CNTRY
CHARACTER|GMI_CNTRY
CHARACTER|CNTRY_NAME
INTEGER|POP_ADMIN
CHARACTER|TYPE_ENG
CHARACTER|TYPE_LOC
DOUBLE PRECISION|SQKM
DOUBLE PRECISION|SQMI
INTEGER|COLORMAP
INTEGER|LABEL_FLAG

# extract last 2 rows of the attrbute table to see what the above fields really look like
db.select | tail -n 2
2584|2583|NZ|NZL-OTG|Otago|NZ|NZL|New Zealand|-99999|County|County|33597.33|12971.93|6|0
2585|2584|NZ72|NZL-STH|Southland|NZ|NZL|New Zealand|34612|County|County|31711.77|12243.91|11|0

#display the map
#the problem here is that the column to be displayed as color needs to be numeric
#and i dont know how to control the intervals..quite annoying
# here i tried to use the COLORMAP field, which varies from 1 to 12…but it still needs work..

d.vect.thematic -l map=SpainPort column=COLORMAP color=yellow-cyan nint=12
d.legend map=SpainPort

##Attribute table joins : lowseries.csv to GRASS vector map countyCA
v.info -c countyCA

INTEGER|cat
CHARACTER|NAME
INTEGER|NUM

head lowseries.csv | head -n 2

COUNTY,2010,2015,2020,2025,2030,2035,2040,2045,2050,2055,2060,2065,2070,2075,2080,2085,2090,2100
Alameda,3,5,6,5,4,1,-1,-4,-7,-12,-16,-20,-24,-27,-29,-31,-32,-32

# So join on COUNTY field from the csv file to NAME field from vector map
##PROBLEM v.db.join does not work on dbf and i dont really know how to use pgsql

v.db.join countyCA col=NAME otab=lowseries.csv ocol=COUNTY
ERROR: JOIN is not supported for tables stored in DBF format.

# try importing a vector that already has the columns of interest
v.in.ogr dsn=CACountyLL84.shp output=CountyPop type=boundary

WHAT WORKED

v.info -c CountyPop
Displaying column types/names for database connection of layer 1:

INTEGER|cat
CHARACTER|NAME
INTEGER|NUM
CHARACTER|COUNTY
DOUBLE PRECISION|countynum
DOUBLE PRECISION|p2000
DOUBLE PRECISION|pc2010
DOUBLE PRECISION|pc2015
DOUBLE PRECISION|pc2020
DOUBLE PRECISION|pc2025
DOUBLE PRECISION|pc2030
d.thematic.area map=CountyPop column=pc2100 breaks=20,40,60 colors=cyan,brown,orange,red
California population

California population

NOTES
—-d.thematic.area
how to assign a constant color scheme  to each map (that spans the min and max of all columns); i guess i was looking for something as simple as setting color rules like with raster data.

If you want constant class breaks, i.e. the same class number and amplitudes linked to the same colors, then you can just manually provide breaks and colors in d.thematic.area.

n – how to refer to each attribute column by column number in a loop (d.vect.thematic and d.thematic.area  seem to need column name as attribute)

(assuming you are in a *nix environment with a shell):

for col in `v.info -c MapName`; do d.thematic.area …. column=$col; done
(note the backticks around the v.info command))

Leave a Comment

Day one

Hello!

Think of this as my mental scratch pad for analytical tools in the earth sciences, mostly open-source. Mostly this will just be a work area for accumulating all my scripting and analysis in one place. Was getting messed up trying to keep track of all the work i’ve done for various projects..

In the process of me figuring things out, perhaps it will help others in the same boat.

Here’s a blurb about me:

I’m a hydrologist and environmental modeler with experience in water resources, forest conservation and micro-hydropower for rural development. At present I work  with the US Centre of the Stockholm Enviornment Institute (SEI) in Davis, California. I’m currently working on three main topics:

  • the impacts of climate change on California’s water supply,
  • urban water management with utilities in the US, India and East Africa,
  • information technology tools for communicating complex data to the largest possible audience.

My expertise includes forest ecosystem sciences, distributed hydrological modeling, and the use of several open-source and commercial geographic information systems. Recent work before joining SEI includes modeling of a 100-year monthly dataset of reference evapotranspiration for all of India; studying the impacts of land-use change on water resources and forest ecosystems; and modeling stream flow and runoff source areas in headwaters of the New York City watersheds.

I received my Ph.D. in Soil, Crop and Atmospheric Sciences from Cornell University, Ithaca in 2007.

My interests these days centre more around communication and outreach, especially at the intersection of art and science as a vehicle for doing so. I would also like to pursue work focusing on participatory planning as part of the decision making process.

Here’s a link to my resume.

Leave a Comment

« Newer Posts