[R-sig-Geo] plotKML with multi-lingual output

Tomislav Hengl hengl at spatial-analyst.net
Fri Feb 7 13:11:10 CET 2014


I think that KML works only with UTF-8 encoding (http://gadm.org/node/400).

Try maybe setting the Sys.setlocale to:

Sys.setlocale(category='LC_CTYPE', locale='ru_RU.UTF-8')

Otherwise you can also try converting the Russian text to UTF-8 via 
http://stat.ethz.ch/R-manual/R-patched/library/base/html/utf8Conversion.html

HTH,

T. (Tom) Hengl
Url: http://www.wageningenur.nl/en/Persons/dr.-T-Tom-Hengl.htm
Network: http://profiles.google.com/tom.hengl
Publications: http://scholar.google.com/citations?user=2oYU7S8AAAAJ


On 7-2-2014 0:24, Anthony Fischbach wrote:
> I wish to produce a KML containing point and line features that have field
> names and field contents in both the Latin and Cyrillic alphabets.
> Below is a toy example showing the problem.
>
> require(plotKML)
> setwd('D:/Temp')  ## house keeping specify working directory
> data(bigfoot) ## Load a data frame with point features
> big<-bigfoot[1:3,]  ## take just the first 3 rows
> Sys.setlocale(category='LC_CTYPE', locale='Russian_Russia.1251')  ## Enable
> Cyrillic encoding
> big$Русское.название<-paste('йети', seq(1:3))  ## create a column using
> Cyrillic encoding
> coordinates(big)<-c('Lon','Lat') ## Cast as SpatialPointsDataFrame
> proj4string(big)<-CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")
> ## assign a coordinate reference system
> ## Take a quick look at it
> plot(big)
> text(big$Lon, big$Lat, big$Русское.название)
> ## I can see the points and the new Cyrillic names
>
> kml_open(file.name='Big.kml', folder.name = 'йети', kml_visibility=TRUE )
> 	## Build the point haulouts
> 	kml_layer.SpatialPoints(obj=big, points_names=big at data$Русское.название,
> 	colour='green',  LabelScale=0.8,
> shape='http://plotkml.r-forge.r-project.org/3Dballyellow.png',
> 	alpha=0.6, balloon=TRUE) ##
> 	## Build the line feature haulouts
> 	##kml_layer.Spatial
> kml_close(file.name='Big.kml')
> ## End Example Code
>
> Below is an excerpt of the resulting kml file.
> Please note the Cyrillic has been garbled.
>
>        <Placemark>
>          <name>йети 1</name>
>          <styleUrl>#pnt1</styleUrl>
>          <description></description>
>          <Point>
>            <extrude>1</extrude>
>            <altitudeMode>clampToGround</altitudeMode>
>            <coordinates>-142.90000,61.50000,0</coordinates>
>          </Point>
>        </Placemark>
>
>> sessionInfo()
> R version 3.0.2 (2013-09-25)
> Platform: i386-w64-mingw32/i386 (32-bit)
>
> locale:
> [1] LC_COLLATE=English_United States.1252  LC_CTYPE=Russian_Russia.1251
> LC_MONETARY=English_United States.1252
> [4] LC_NUMERIC=C                           LC_TIME=English_United
> States.1252
>
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
>
> other attached packages:
> [1] sp_1.0-14     plotKML_0.4-2
>
> loaded via a namespace (and not attached):
>   [1] aqp_1.6             class_7.3-9         classInt_0.1-21
> cluster_1.14.4      colorRamps_2.3      colorspace_1.2-4
>   [7] dichromat_2.0-0     dismo_0.9-3         e1071_1.6-2
> Formula_1.1-1       grid_3.0.1          gstat_1.0-18
> [13] Hmisc_3.14-0        intervals_0.14.0    labeling_0.2
> lattice_0.20-24     latticeExtra_0.6-26 munsell_0.4.2
> [19] pixmap_0.4-11       plotrix_3.5-3       plyr_1.8
> raster_2.2-12       RColorBrewer_1.0-5  reshape_0.8.4
> [25] rgdal_0.8-13        RSAGA_0.93-6        scales_0.2.3
> spacetime_1.0-9     splines_3.0.1       stringr_0.6.2
> [31] survival_2.37-7     tools_3.0.1         XML_3.98-1.1        xts_0.9-7
> zoo_1.7-10
>
>
>
>
> -----
> Tony Fischbach, Wildlife Biologist
> Walrus Research Program
> Alaska Science Center
> U.S. Geological Survey
> 4210 University Drive
> Anchorage, AK 99508-4650
>
> AFischbach at usgs.gov
> http://alaska.usgs.gov/science/biology/walrus
> --
> View this message in context: http://r-sig-geo.2731867.n2.nabble.com/plotKML-with-multi-lingual-output-tp7585705.html
> Sent from the R-sig-geo mailing list archive at Nabble.com.
>
> _______________________________________________
> 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