Difference between revisions of "Opasnet map"
From Testiwiki
(→Static GoogleMaps) |
(→See also) |
||
(8 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
[[Category:Opasnet]] | [[Category:Opasnet]] | ||
[[Category:Code under inspection]] | [[Category:Code under inspection]] | ||
− | {{ | + | [[Category:R tool]] |
+ | [[Category:Modelling]] | ||
+ | {{method|moderator=Jouni|stub=Yes}} | ||
== Question == | == Question == | ||
Line 33: | Line 35: | ||
== Rationale == | == Rationale == | ||
+ | |||
+ | ===Wiki maps=== | ||
+ | |||
+ | {{#display_map: 62.91826544557644,28.69525909423828~ ~Valuma-alue; 62.92647012476198,28.637065887451172 | ||
+ | |rectangles=62.94068612542196,28.726844787597656:62.92373548704899,28.702983856201172~Luikonlahden kaivos~ ~ ~ ~ ~#F2E1E1 | ||
+ | |zoom=10 | ||
+ | |centre=62.91826544557644,28.69525909423828 | ||
+ | }} | ||
+ | |||
+ | |||
+ | |||
+ | {{#display_map: | ||
+ | 62.928986, 28.706245; | ||
+ | 62.937734, 28.712769 | ||
+ | }} | ||
+ | |||
+ | [http://semantic-mediawiki.org/wiki/Special:MapEditor Map editor and instructions] | ||
=== Calculations === | === Calculations === | ||
==== 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 70: | ||
library(OpasnetUtilsExt) | library(OpasnetUtilsExt) | ||
− | + | 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 76: | ||
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") |
− | |||
epsg4326String <- CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs") | epsg4326String <- CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs") | ||
Line 63: | Line 83: | ||
shp2 <- spTransform(shp, epsg4326String) | shp2 <- spTransform(shp, epsg4326String) | ||
− | + | dat <- google.point_kml( | |
− | kmldescription | + | shp2, |
− | + | kmlname = "Kuopio house data", | |
− | name | + | kmldescription = "Random stuff about here", |
− | description | + | name = paste("ika value: ", shp2$ika), |
− | + | description = paste("Age:", shp2$ika, "<br>Description:", shp2$kayttotark), | |
− | + | 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 ==== | ||
− | |||
− | |||
<rcode name='gmapspsqltest3'> | <rcode name='gmapspsqltest3'> | ||
Line 86: | Line 105: | ||
library(sorvi) | library(sorvi) | ||
library(rgdal) | library(rgdal) | ||
+ | library(maptools) | ||
− | + | shp <- LoadData("kuntarajat.maa.shp") | |
− | |||
− | shp <- | ||
#epsg3857String <- CRS("+proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=6378137 +b=6378137 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs") | #epsg3857String <- CRS("+proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=6378137 +b=6378137 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs") | ||
Line 96: | Line 114: | ||
shp2<-spTransform(shp,epsg4326String) | shp2<-spTransform(shp,epsg4326String) | ||
− | out<-sapply(slot(shp2,"polygons"),function(x | + | out<-sapply(slot(shp2,"polygons"),function(x) |
{kmlPolygon( | {kmlPolygon( | ||
x, | x, | ||
Line 207: | Line 225: | ||
</rcode> | </rcode> | ||
− | === | + | ====Rasters on Google maps==== |
− | + | <rcode graphics=1> | |
− | |||
− | <rcode | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
library(OpasnetUtils) | library(OpasnetUtils) | ||
− | |||
− | |||
library(OpasnetUtilsExt) | library(OpasnetUtilsExt) | ||
library(rgdal) | library(rgdal) | ||
Line 228: | Line 236: | ||
library(raster) | library(raster) | ||
+ | altiste <- "Ni" | ||
pitoisuus <- new("ovariable", | pitoisuus <- new("ovariable", | ||
Line 311: | Line 320: | ||
27.999601 | 27.999601 | ||
)) | )) | ||
+ | |||
+ | oprint(locs) | ||
data <- merge(data, locs) | data <- merge(data, locs) | ||
Line 411: | Line 422: | ||
* [https://gist.github.com/2292662 Plotting sp-objects to Google Maps with different CRSs] | * [https://gist.github.com/2292662 Plotting sp-objects to Google Maps with different CRSs] | ||
+ | * [http://semantic-mediawiki.org/wiki/Special:MapEditor Map editor] | ||
+ | * [http://www.findlatitudeandlongitude.com/batch-geocode/ Batch geocoding]: give addresses, the website will provide geolocations. Works for a few hundred addresses. | ||
==Keywords== | ==Keywords== |
Latest revision as of 11:29, 1 November 2016
This page is a method.
The page identifier is Op_en5490 |
---|
Moderator:Jouni (see all) |
This page is a stub. You may improve it into a full page, and then a rating bar will appear here. |
Upload data
|
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:
- OpasnetUtils/Drafts contains many functions needed.
- Help:Drawing graphs contains guidance for making non-map graphs.
- rgdal package for R
- sp package for R: contains descriptions about the key spatial objects.
- Changing the coordinate system of Spatial objects
Rationale
Wiki maps
Loading map...
Loading map...
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)
GoogleMaps Sorvi MML
Google with shapefiles
Google show data from url on map
Google circles
Rasters on Google maps
Static GoogleMaps
See also
- Plotting sp-objects to Google Maps with different CRSs
- Map editor
- Batch geocoding: give addresses, the website will provide geolocations. Works for a few hundred addresses.
Keywords
References
Related files
<mfanonymousfilelist></mfanonymousfilelist>