Difference between revisions of "Opasnet map"

From Testiwiki
Jump to: navigation, search
(Laskenta)
(Kuopio buildings with Google pin map)
Line 37: Line 37:
  
 
==== Kuopio buildings with Google pin map ====
 
==== Kuopio buildings with Google pin map ====
 +
 +
{{attack|#|In function google.point_kml, parameter name is not used for anything!|--[[User:Jouni|Jouni]] ([[User talk:Jouni|talk]]) 08:42, 26 December 2013 (EET)}}
 +
 +
{{defend|#|What we need is a function that eats SpatialPointDataFrames and gives KML files with the data points in different formats (pins, coloured marks etc.|--[[User:Jouni|Jouni]] ([[User talk:Jouni|talk]]) 08:42, 26 December 2013 (EET)}}
  
 
<rcode name='kuorakonmaps'>
 
<rcode name='kuorakonmaps'>
Line 47: Line 51:
 
library(OpasnetUtilsExt)
 
library(OpasnetUtilsExt)
  
objects.latest("Op_en6007", code_name = "answer") # [[OpasnetUtils/Drafts]]; we need MyPointsKML and ova2spat.
+
shp<-readOGR('PG:host=localhost user=postgres dbname=spatial_db','kuopio_house') # Read building data
 
 
shp<-readOGR('PG:host=localhost user=postgres dbname=spatial_db','kuopio_house')
 
  
 
shp <- shp[1:100 , ] # Save only 100 buildings for demonstration
 
shp <- shp[1:100 , ] # Save only 100 buildings for demonstration
Line 55: Line 57:
 
plotvar <- shp@data$ika
 
plotvar <- shp@data$ika
 
nclr <- 8
 
nclr <- 8
plotclr <- brewer.pal(nclr,"BuPu")
+
plotclr <- brewer.pal(nclr, "BuPu")
class <- classIntervals(plotvar,nclr,style="quantile")
+
class <- classIntervals(plotvar, nclr, style = "quantile")
colcode <- findColours(class,plotclr)
 
  
 
epsg4326String <- CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")
 
epsg4326String <- CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")
Line 63: Line 64:
 
shp2 <- spTransform(shp, epsg4326String)
 
shp2 <- spTransform(shp, epsg4326String)
  
kmlname <- "Kuopio house data"
+
dat <- google.point_kml(
kmldescription <- "Random stuff about here"
+
shp2,
icon <- "http://maps.google.com/mapfiles/kml/pal2/icon18.png"
+
kmlname = "Kuopio house data",
name <- paste("ika value: ", shp2$ika)
+
kmldescription = "Random stuff about here",
description <- paste("<b>Value:</b>",shp2$ika,"<br><b>Description:</b>",shp2$kayttotark)
+
name = paste("ika value: ", shp2$ika),
 
+
description = paste("Age:", shp2$ika, "<br>Description:", shp2$kayttotark),
dat <- MyPointKML(shp2, kmlname, kmldescription, name, description, icon, colcode)
+
icon = "http://maps.google.com/mapfiles/kml/pal2/icon18.png",
 +
col = findColours(class,plotclr)
 +
)
  
 
google.show_kml_data_on_maps(dat)
 
google.show_kml_data_on_maps(dat)
  
 
</rcode>
 
</rcode>
 
  
 
==== GoogleMaps Sorvi MML ====
 
==== GoogleMaps Sorvi MML ====

Revision as of 06:42, 26 December 2013



Question

How should GIS data be handled and visualised in Opasnet?

Answer

  • Original GIS data is stored in a PostgreSQL database.
  • Data is accessed by R using the RGDAL package and ?? connection.
  • Data in manipulated in R.
  • Ovariables are converted to SpatialPointsDataFrame objects using ova2spat function.
  • Data is displayed by producing a KML file with ?? package.
    • The KML file is created with MyPointKML function, if pins are shown.
    • The KML file is saved at the R-tools server.
    • Google Maps is used to show the KML file on a web page.

Currently, ova2spat and MyPointKML functions are located in OpasnetUtils/Drafts. Therefore, you need this command:

objects.latest("Op_en6007", code_name = "answer") # OpasnetUtils/Drafts. We need MyPointsKML and ova2spat.

This is the projection that the National Land Survey Finland uses: [1].

Key guidance:


Rationale

Calculations

Kuopio buildings with Google pin map

#: In function google.point_kml, parameter name is not used for anything! --Jouni (talk) 08:42, 26 December 2013 (EET)

#: What we need is a function that eats SpatialPointDataFrames and gives KML files with the data points in different formats (pins, coloured marks etc. --Jouni (talk) 08:42, 26 December 2013 (EET)

+ Show code

GoogleMaps Sorvi MML

#: Something wrong with sorvi. --Jouni (talk) 12:54, 23 December 2013 (EET)

+ Show code

Google with shapefiles

+ Show code

Google show data from url on map

+ Show code

Google circles

+ Show code

Rasters on Google maps

+ Show code

Static GoogleMaps

+ Show code

See also

Keywords

References


Related files

<mfanonymousfilelist></mfanonymousfilelist>