select
name as name,
makeLine(t.ptgeom, 0) as geom
from (
select
name as name,
DissolvePoints(Collect(ST_Reverse(geometry))) as ptgeom
from segments group by name )
as t
6 Feb 2015
QspatiaLite Use Case: Connecting Lines
With QSpatiaLIte you can connect disjoint lines quite easily. With the below SQL you can allow for a grouping variable, in this case the field 'name' within the layer 'segments', by which the group vertices are collected and connected as lines! With this approach the vertices are connected in the order in which they were digitized and existing gaps are closed.
5 Feb 2015
Usecase for KML-Parsing: Make New KML-File from File-Collection
In this usecase I had collected several KMLs from the internet but wanted to strip them down for only the relevant parts (the Linestrings inside the Placemark-nodes) and put them all inside one final File. In my script I create a new KML file and populate a folder-node inside it with Linestrings from the collection of KML-files which all reside in the same source directory. For this one needs to parse each file and grab the appropiate nodes and add them to the target kml file. In addition I alter some oroginal values, i.e. I use the file names of the single KML-files as Placemark names inside the new KML-file.
Here is the final file as seen after opening in Google Earth:
Here is the final file as seen after opening in Google Earth:
library(XML)
# new kml file... needs to be well-formed
z <-
'<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Folder>
<name>ROUTES</name>
</Folder>
</Document>
</kml>'
new_xmlDoc <- xmlInternalTreeParse(z, useInternalNodes = TRUE)
# important add all namespace definitions...
ns <- c(gx="http://www.google.com/kml/ext/2.2",
kml="http://www.opengis.net/kml/2.2",
atom="http://www.w3.org/2005/Atom")
ensureNamespace(new_xmlDoc, ns)
# get the root off the new file for latter processing
new_root <- xmlRoot(new_xmlDoc)
# loop over files from folder
# and insert Placemark content of each file as children nodes into
# the new file
setwd("C:/Users/Kay/Google Drive/SKI-BIKE/Gastein")
files <- dir(pattern="bergfex*")
for (f in files) {
# get placemark node of each file
doc <- xmlInternalTreeParse(f, useInternalNodes = TRUE)
root <- xmlRoot(doc)
plcm_node <- root[["Document"]][["Folder"]][["Folder"]][["Placemark"]]
# insert file name as Placemark name
xmlValue(plcm_node[["name"]]) <- sub('bergfextour_(.*)[.]kml', '\\1', f)
# add placemark node to new doc
addChildren(new_root[["Document"]][["Folder"]], plcm_node)
}
# save it...
saveXML(new_xmlDoc, "collapsed_ROUTES.kml")
17 Jan 2015
How to Integrate OpenStreetMap Nominatim Search into a Webpage or OpenLayers Map
Here' a concise example on how to integrate Nominatim search into a webpage:
http://jsfiddle.net/gimoya/yp8hmog7
And here's a live Openlayers example:
http://gimoya.bplaced.net/Openlayers/Bergfex/bergfex.html
http://jsfiddle.net/gimoya/yp8hmog7
And here's a live Openlayers example:
http://gimoya.bplaced.net/Openlayers/Bergfex/bergfex.html
Subscribe to:
Comments
(
Atom
)



