This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

osm2pgsql_loading .oms_invalid data error

0

Hi all, I'm very new to OSM and postgreSQL ...I've been trying for some days to load .oms extracts onto PostgreSql through osm2pgsql..and I just can't get my around it. Need some help, plz...

C:\Users\Francesca>osm2pgsql -d Test -m -W C:\OSM\08---Emilia-Romagna.osm -S C:\
osm2pgsql-bin\default.style  -c -U postgres -H localhost -P 5433 -r osm
osm2pgsql version 0.92.0 (64 bit id space)
Password:
Using built-in tag processing pipeline
Using projection SRS 3857 (Spherical Mercator)
Setting up table: planet_osm_point
Setting up table: planet_osm_line
Setting up table: planet_osm_polygon
Setting up table: planet_osm_roads
Allocating memory for sparse node cache
Node-cache: cache=800MB, maxblocks=12800*65536, allocation method=1
Mid: Ram, scale=100
Reading in file: C:\OSM\08---Emilia-Romagna.osm
Using XML parser.
node cache: stored: 0(-nan(ind)%), storage efficiency: -nan(ind)% (dense blocks:
 0, sparse nodes: 0), hit rate: -nan(ind)%
Osm2pgsql failed due to ERROR: Open failed for 'C:\OSM\08---Emilia-Romagna.osm':
 Dati non validi.

I've tried to download .pbt file but I got other XML parsing error such as "invalid token"... What do I do wrong? Thanks

asked 24 Oct '17, 16:07

psqldaimon's gravatar image

psqldaimon
16113
accept rate: 0%

edited 24 Oct '17, 19:10

SimonPoole's gravatar image

SimonPoole ♦
44.7k13326701

Could you make the input file available somewhere or point to from where you got it?

(24 Oct '17, 19:11) SimonPoole ♦
1

Pls don't answer your own question :-)

There are 7 files listed, which one/format did you download?

(24 Oct '17, 19:22) SimonPoole ♦

:) I tried .oms and the .pbf (no cut)

(24 Oct '17, 19:31) psqldaimon

One Answer:

1

Visual inspection didn't indicate anything obviously wrong with the .osm file (at least the first and last couple of dozen elements, so it should have read at least a couple of nodes.

However I suspect the -r flag is wrong according to the documentation that should by -r xml for osm format files NOT -r osm (and for pbf you should be specifying -r pbf).

answered 24 Oct '17, 20:10

SimonPoole's gravatar image

SimonPoole ♦
44.7k13326701
accept rate: 18%

I put -r flag as xml and it worked as a charm... except that I got another error message:

Osm2pgsql failed due to ERROR: XML parsing error at line 17257713, column 1: unclosed token

Any suggestions? Thanks

(24 Oct '17, 22:10) psqldaimon
1

If you downloaded the files yesterday, the uncompressed file should be 5668669254 bytes large (your issue sounds like a corrupted file, I checked my copy and it was OK at and around the line in question)

(24 Oct '17, 23:50) SimonPoole ♦

Hi SimonPoole, I followed your hint and I realized that trying different unzipping softwares I was always getting different files! I picked the file with bytes number closer to the one you suggested...and HAlleluiaaaa, it worked! Thanks a lot

Problem solved. Many lessons learned (and many unzipping softwares to be binned)

(25 Oct '17, 11:03) psqldaimon

well normally when in doubt we would have compared checksums, but that would have required finding a windows variant of what is available on Linux.

(25 Oct '17, 11:09) SimonPoole ♦

Source code available on GitHub .