-
Notifications
You must be signed in to change notification settings - Fork 1
Getting started
Emmanuel Blondel edited this page Feb 13, 2014
·
6 revisions
The package installation requires at least R 2.15 and installing the devtools package
install.packages("devtools")
Once the devtools package loaded, you can use the install_github as follows:
require("devtools")
install_github("RFigisGeo", "openfigis")
This example shows how to read data from WFS, perform an intersection and export features.
- Read data from WFS
features1 <- readWFS("http://www.fao.org/figis/geoserver/species/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=species:SPECIES_DIST_OCC")
features2 <- readWFS("http://www.fao.org/figis/geoserver/fifao/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=fifao:FAO_MAJOR")
- use custom CRS for area computation
require(sp)
eckert4CRS<-CRS("+proj=eck4 +lon_0=Central Meridian+x_0=False Easting+y_0=False Northing")
- perform intersection (keeping attributes)
intersect <- getIntersection(features1, features2, areaCRS = eckert4CRS)
- export features to zipped shapefile
exportFeatures(intersect, outputFormat="SHAPE-ZIP") #to a zipped shapefile
exportFeatures(intersect, outputFormat="GML") #to a GML
- read statistical data (In this example, we used FAO fishery capture data in SDMX format, and read the data in R with the [rsdmx] (https://github.com/opensdmx/rsdmx) package)
require(rsdmx)
sdmx <- readSDMX("http://data.fao.org/sdmx/repository/data/CAPTURE/all/FAO/?startPeriod=2006&endPeriod=2006")
stats <- as.data.frame(sdmx)
- read intersection data (FAO AREAS vs. EEZs)
intersections <- readWFS("http://www.fao.org/figis/geoserver/GeoRelationship/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=GeoRelationship:FAO_AREAS_x_EEZ_HIGHSEAS")
- proceed to an areal data reallocation (from FAO MAJOR areas, to EEZs)
require(RFigisGeo)
#reallocate the time series (data disaggregation)
spread <- reallocate(x = stats, y = intersections, area.x = "FAO_MAJOR_AREA", area.y = "FAO_AREAS",
by.x = NULL, by.y = NULL, data = "obsValue", warea = "INT_AREA", wprob = NULL)
#analyse one subset & check calculation
test <- spread[spread$SPECIES == "CAA" & spread$UN_COUNTRY=="352" & spread$obsTime == 2006,]
sum(test$spread) == unique(test$obsValue)