Quantcast
Viewing all articles
Browse latest Browse all 1015

First step on GIS with R

By tomizono

The PM 2.5 checker written by R has been working nicely for me. I put a shortcut icon of this small script on my desktop PC, to check the air pollution when I run. The Ibaraki Prefecture Agency has been increasing watching points for PM 2.5 concentration from China. A problem is that I cannot picture to myself all the observation locations exactly.

Fig. 1a. March 2013

Image may be NSFW.
Clik here to view.
Fig. 1b. January 2016

Fig. 1b. January 2016

Now, time to use the power of GIS.

1. Shape file

City boundary data is published by Japanese government agency at http://www.gsi.go.jp/kankyochiri/gm_jpn.html and http://www.gsi.go.jp/kankyochiri/gm_japan_e.html (English).

  1. Download gm-jpn-all_u_2_1.zip (8MB) , which is the current (2015, v.2.1) file with all layers.
  2. Unzip to ~/var/gis/gm-jpn-all_u_2_1, or somewhere you like.
  3. The city boundary shape file is polbnda_jpn.shp.

Let’s see if this map data works or not.

Here I use CRAN package maptools.

library(maptools)
cities.japan 

A map of Japan is drawn. It's working.

Image may be NSFW.
Clik here to view.
Fig. 2. City boundaries in Japan

Fig. 2. City boundaries in Japan

I don't need the entire Japan but Ibaraki Ken local area only.

cities.ibaraki 

It's perfect! The specification of data can be found at http://www.iscgm.org/gm/spec.html.

Image may be NSFW.
Clik here to view.
Fig. 2. City boundaries in Ibaraki

Fig. 2. City boundaries in Ibaraki

This map is plotted with Longitude on X-axis and with Latitude on Y-axis. The range can be shown by @bbox.

> cities.ibaraki@bbox
min       max
x 139.6879 140.85190
y  35.7396  36.94547

These values are useful to overwrite multiple layers on the same plot. Let's see the following plot fits exactly on the previous one.

plot(cities.ibaraki, add=T, 
     xlim=cities.ibaraki@bbox['x',], 
     ylim=cities.ibaraki@bbox['y',], 
     border=rgb(1,0,0,0.2), lwd=8)

Plot method is expanded for the class SpatialPolygons, and specific parameters can be found at the help page of SpatialPolygons-class.

Finally, I'm ready to ...read more

Source:: r-bloggers.com


Viewing all articles
Browse latest Browse all 1015

Trending Articles