Working with Spatial Datasets and Geostatistics

5 downloads 614 Views 1MB Size Report
2.2.2 Indian map with ggmap . ... are approximately 131 packages for R programmers. ... I usually use rworldmap to plot world maps; ggmap to plot India.
Working with Spatial Datasets and Geostatistics Kamakshaiah Musunuru

Contents 1 Wording with spacial data sets 1.1 Preparing spacial dataset for India . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1 1

2 R for geographers or geologists 2.1 World maps . . . . . . . . . . . . . . . . 2.1.1 to invoke libraries of rworldmap 2.1.2 World map with googleVis . . . 2.2 Indian maps . . . . . . . . . . . . . . . . 2.2.1 Working with maps and mapdata 2.2.2 Indian map with ggmap . . . . .

. . . . . .

1 2 2 5 6 6 7

3 Geostatistics 3.0.3 meuse dataset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.0.4 The relationship between concentration and distance . . . . . . . . . . . . . .

8 9 12

1

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

Wording with spacial data sets

Spatial data sets depends on two inputs they are ( longitude) and ( latitude). The following places might help find these inputs for analysis. ˆ http://www.worldatlas.com/aatlas/imageg.htm - for region wise data ˆ http://www.latlong.net/ - for global & country level data ˆ http://www.mapsofworld.com/world-maps/world-map-with-latitude-and-longitude.html - for country level data.

1.1

Preparing spacial dataset for India

I prefer http://www.mapsofindia.com/lat_long/ for India. However, for this manual I shall follow http://www.latlong.net/ to retrieve city wise coordinates. You might visit http://www. latlong.net/category/cities-102-15.html for the list of citie with respective coordinates. Try to dowload the data with the help of Excel (external data).R has wounderful methods to scrape the data from the external sources like websites, but it is a bit messy and also tiring for those who are not familiar with basics of R. I suggest Excel for webscraping for it is strait and simple.

1

For more details on how to scrape data from website, you may visit https://support.office.com/ en-gb/article/Get-external-data-from-a-Web-page-708f2249-9569-4ff9-a8a4-7ee5f1b1cfba.

2

R for geographers or geologists

There are abundant of packages to plot maps and other basic geographic visuals in R. For more details you may visit http://cran.r-project.org/web/views/Spatial.html. As on today there are approximately 131 packages for R programmers. I shall use the below mentioned packages for visualization. ˆ rworldmap: enables mapping of country level and gridded user datasets. ˆ ggmap: ggmap allows for the easy visualization of spatial data and models on top of Google Maps, OpenStreetMaps, Stamen Maps, or CloudMade Maps using ggplot2. ˆ maps: Display of maps. Projection code and larger maps are in separate packages (mapproj and mapdata). It must be used with the other pakcage called mapdata. ˆ mapdata: Supplement to maps package, providing the larger and/or higher-resolution databases. 1

ˆ googleVis: R interface to Google Charts API, allowing users to create interactive charts based on data frames. Charts are displayed locally via the R HTTP help server. A modern browser with Internet connection is required and for some charts Flash. The data remains local and is not uploaded to Google.

I shall use the following packages for geostatistics. ˆ sp ˆ gstat

2.1

World maps

I usually use rworldmap to plot world maps; ggmap to plot India. In addition to ggmap I also try to explain with the help of a couple of other packages (maps, mapdata) The following is the procedure to plot world map 2 : 2.1.1

to invoke libraries of rworldmap

> library(rworldmap) > data(countryExData) > names(countryExData) 1 Please visit https://www.students.ncl.ac.uk/keith.newman/r/maps-in-r for better description on these packages 2 The programming code is obtained from http://journal.r-project.org/archive/2011-1/RJournal_2011-1_ South.pdf

2

[1] [3] [5] [7] [9] [11] [13] [15] [17] [19] [21] [23] [25] [27] [29] [31] [33] [35] [37] [39] [41] [43] [45] [47] [49] [51] [53] [55] [57] [59] [61] [63] [65] [67] [69] [71] [73] [75] [77] [79]

"ISO3V10" "EPI_regions" "Population2005" "landlock" "density" "ENVHEALTH" "ENVHEALTH.1" "WATER_E" "PRODUCTIVE_NATURAL_RESOURCES" "DALY_SC" "AIR_H" "WATER_E.1" "FOREST" "AGRICULTURE" "ACSAT_pt" "DALY_pt" "PM10_pt" "SO2_pt" "WATQI_pt" "WATQI_GEMS.station.data" "CRI_pt" "AZE_pt" "EEZTD_pt" "IRRSTR_pt" "AGSUB_pt" "PEST_pt" "CO2IND_pt" "ACSAT" "DALY" "PM10" "SO2" "WATQI" "WATSTR" "CRI" "AZE" "EEZTD" "IRRSTR" "AGSUB" "PEST" "CO2IND"

"Country" "GEO_subregion" "GDP_capita.MRYA" "landarea" "EPI" "ECOSYSTEM" "AIR_E" "BIODIVERSITY" "CLIMATE" "WATER_H" "AIR_E.1" "BIODIVERSITY.1" "FISH" "CLIMATE.1" "WATSUP_pt" "INDOOR_pt" "OZONE_H_pt" "OZONE_E_pt" "WATSTR_pt" "FORGRO_pt" "EFFCON_pt" "MPAEEZ_pt" "MTI_pt" "AGINT_pt" "BURNED_pt" "GHGCAP_pt" "CO2KWH_pt" "WATSUP" "INDOOR" "OZONE_H" "OZONE_E" "WATQI_GEMS.station.data.1" "FORGRO" "EFFCON" "MPAEEZ" "MTI" "AGINT" "BURNED" "GHGCAP" "CO2KWH"

From the above chunk; the command or statement names(countryExData) will let us know as how many columns (attributes) do exists in the data. From the output it is clear that there are 80 study variables in the data. for better view we may also use edit(countryExData), this will open the data in an Excel like spreadsheet in R.

3

Otherwise I also can use the following procedure to know the number of columns (vairables) of the data set (i.e. countryExData). > x dim(x) [1] 80

1

We can find the number of variables from the output as 80. Now follow the below mentioned procedure to plot this data on world map. > my.map