NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

I am having troubles with the encoding of the osm data in R. Here is a reproducible example using the osmar package:

osmData <- osmar::get_osm(osmar::center_bbox(23.334360, 42.693180, 100, 100))
osmData$nodes$tags[80:100, ] #the output is not UTF-8

I have also downloaded a planet file from https://download.geofabrik.de/europe/. The filename is "bulgaria-latest.osm.bz2".

After unzipping it, installing osmosis, and reading the file with osmar::get_osm(source = osmsource_osmosis(fileName)) I still have the same issue. The cyrilics letters are not readable.

I am using a 64bit Windows 10 with R version 3.3.3. My default encoding is Bulgarian, but I have also tried English encoding in R with no help.

Any ideas how can I counter this?

asked 21 Jul '17, 09:10

deann88's gravatar image

deann88
51112
accept rate: 100%

I suspect this is an issue you need to raise with the osmar package owner or R forums rather than here.

(21 Jul '17, 13:18) SK53 ♦
1

I have raised it to several places where people have worked with OSM as @scai pointed out. It is not package specific issue as I have tried it and it works in ubuntu. It is something connected with Windows locale and I am looking for a solution.

(21 Jul '17, 13:22) deann88
1

It's likely the issue is in the R console you are using. You could isolate whether it has anything to do with OSM and/or osmar by creating a simple test file and loading it with read.table.

Something like

col1, col2
Стадион, Левски

should be sufficient.

(21 Jul '17, 15:35) maxerickson

Ok, Answering my own question:

I ran the above code in linux and understood that the issue was with the windows locale. The workaround I found was to use iconv with from and to parameters set to "UTF-8".

iconv(osmData$nodes$tags[80:100,3][11], from="UTF-8", to="UTF-8")

This works and could be applied to all columns.

permanent link

answered 24 Jul '17, 08:54

deann88's gravatar image

deann88
51112
accept rate: 100%

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×10
×8
×2

question asked: 21 Jul '17, 09:10

question was seen: 3,318 times

last updated: 24 Jul '17, 08:54

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum