[R-sig-Geo] create a 3d shapefile ?
Agustin Lobo
alobolistas at gmail.com
Mon Mar 18 17:49:49 CET 2013
Actually a simple workaround is writing a csv and then using
gpsbabel to convert into gpx:
command <- "gpsbabel -w -i unicsv -f wpAlfacs13_2000lonlat.csv -o gpx
-F wpAlfacs13_2000lonlat.gpx"
system(command)
care must be taken with the names of the csv following the keywords
defined for unicsv by gpsbabel (I think,
http://www.gpsbabel.org/htmldoc-1.4.2/fmt_unicsv.html
is a bit obscure in this regard)
In my case:
names(wpAlfacs13_2000lonlat at data)
[1] "name" "lon" "lat" "alt" "fl"
field "fl" is lost but "lon" "lat" "alt" successfully create a 3d
waypoints gpx file and "name" propagates to the wp names.
Agus
On Mon, Mar 18, 2013 at 10:19 AM, Agustin Lobo <alobolistas at gmail.com> wrote:
> Actually my current need is writing aerial waypoints as gpx files with
> x,y,z to be used in the field with a gps program
> (ie. oruxmaps) for an android tablet.
> I do create the waypoints in R (as I plan the campaign with R), so my
> problem is not reading 3d shapefiles, but writing the 3d waypoints
> either to gpx directly
> or to shapefile and then convert to gpx with i.e. gpsbabel.
> My understanding is that rgdal/sp cirrently support reading 3d
> shapefiles but not actually writing 3d spatial points DF
>
> Agus
>
> On Mon, Mar 18, 2013 at 8:54 AM, Michael Sumner <mdsumner at gmail.com> wrote:
>> It's actually something I have long wanted to explore, but rgdal source is
>> still out of reach to me (just need to spend enough time). I think it would
>> be useful to read and write 3 and possibly 4-d objects, and apart from the
>> class validation and read/write this is possible for points and lines if
>> you generalize bbox. It would obviously break for a lot of downstream uses
>> of sp though.
>>
>> Reading from shapefiles with Z would be enough for a lot of things, perhaps
>> it's worth chasing that and making a special class that won't break
>> anything else (Roger Bivand explained this offlist some time ago, and I can
>> do that but it's the read I want to figure out myself). But, it has been a
>> long time since I compiled rgdal so even simple exploration is a way off
>> for me.
>>
>> Note that polygons in OGC are composed of linear rings and so unless your
>> polys are composed completely of individual triangle facets they are rarely
>> going to be of any use. Lines are much simpler but still pose complications
>> for validation in 2d (think of intersecting lines) compared to 3d or higher.
>>
>> As a workaround you can use gdal to extract the data to something more
>> generic, as here
>> https://stat.ethz.ch/pipermail/r-sig-geo/2009-November/006866.html
>>
>>
>> Cheers, Mike
>>
>>
>>
>> On Monday, March 18, 2013, Agustin Lobo wrote:
>>
>>> Thanks, this is what seemed to me, but the following phrase from the sp pdf
>>> "The classes document where the spatial location
>>> information resides, for 2D or 3D data"
>>>
>>> and some scattered info such as
>>>
>>> http://gis.stackexchange.com/questions/43342/how-to-use-z-coordinate-in-qgis
>>>
>>> http://grokbase.com/t/r/r-sig-geo/127s88jzc6/problem-extracting-z-value-from-line-shapefile
>>>
>>> make me think that some support for x,y,x coordinates actually exists
>>> in sp and perhaps writeOGR() could
>>> have taken advantage of it.
>>>
>>> I've got very good advice on how to create the 3d shapefiles using
>>> simple python scripting in the qgis list, I insert the link:
>>>
>>> http://osgeo-org.1560.n6.nabble.com/create-3d-shapefile-and-or-GPX-tp5040855p5040863.html
>>>
>>> Agus
>>>
>>> On Sat, Mar 16, 2013 at 2:00 PM, Michael Sumner <mdsumner at gmail.com>
>>> wrote:
>>> > It is not possible.
>>> >
>>> > Cheers, Mike
>>> >
>>> > On Saturday, March 16, 2013, Agustin Lobo wrote:
>>> >
>>> >> Is it possible to write point ESRI shapefiles with x,y,z
>>> >> coordinates using writeOGR()?
>>> >> According to what I've been able to find, it seems
>>> >> that spatial points can have 3 coordinates while
>>> >> spatial lines cannot. Nevertheless, coordinates() accepts
>>> >> 2 arguments (x,y) only. So actually, do not know how to define
>>> >> x,y,z coordinates for spatial points (data frame) objects.
>>> >> Is it possible?
>>> >>
>>> >> Thanks,
>>> >>
>>> >> Agus
>>> >>
>>> >> _______________________________________________
>>> >> R-sig-Geo mailing list
>>> >> R-sig-Geo at r-project.org <javascript:;>
>>> >> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>> >>
>>> >
>>> >
>>> > --
>>> > Michael Sumner
>>> > Hobart, Australia
>>> > e-mail: mdsumner at gmail.com
>>> >
>>> > [[alternative HTML version deleted]]
>>> >
>>> > _______________________________________________
>>> > R-sig-Geo mailing list
>>> > R-sig-Geo at r-project.org
>>> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>>
>>
>>
>> --
>> Michael Sumner
>> Hobart, Australia
>> e-mail: mdsumner at gmail.com
>>
>> [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
More information about the R-sig-Geo
mailing list