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

Hi

I wish to use osmtogeojson on a windows commandline to convert OSM data. I saw the usage section here (1) but unsure if that's relevant to windows. What does the $ signify? Do I need to perform the npm install?

(1): https://github.com/tyrasd/osmtogeojson

Edit: I've removed what I previously did as it would just confuse any future readers of this post.

After a lot of head scratching I've finally got it to work, but probably not as intended.

I downloaded & installed node.js Windows installer https://nodejs.org/en/ The file I required was installed at: C:\Program Files\nodejs\node.exe

I then downloaded & extracted the full zip file from https://github.com/tyrasd/osmtogeojson although for this operation only the osmtogeojson.js is required.

In the folder that contained my OSM data file (FHRS857en-GB.osm) I created a .cmd file which is a more recent incarnation of Windows batch files.

The .cmd file contains the line:

"C:\Program Files\nodejs\node.exe" "C:\GeoJson\osmtogeojson" FHRS857en-GB.osm > FHRS857en-GB.geojson

"C:\GeoJson\osmtogeojson" points to osmtogeojson.js. The path will need to be amended to suit where the .js file was placed.

The.cmd file can be run by double clicking on it in Windows Exporer or running it from a command line.


Supposedly the actual node.js file can be used to preform the same procedure, but I couldn't get it to work.

I'm new to npm & didn't really understand what it does. The usage example at https://github.com/tyrasd/osmtogeojson added to the confusion making it appear the npm command has to be run every time a conversion is performed. Unless you're a developer who wants to keep lots of projects filed neatly & kept up to date I don't see the need for it.

npm doesn't inform you where it's installing its files & creates configuration files that fail to locate the files they're trying to run, and giving the same name to different file types really doesn't help.

Thanks to aseerel4c26 & maxerickson for their help.

asked 14 Feb '16, 16:22

DaveF's gravatar image

DaveF
3.3k8498133
accept rate: 16%

edited 15 Feb '16, 12:53

1

You should use the command npm install -g osmtogeojson to install the command line program. npm does not expect you to download anything beforehand, so no need to specify a path for the install target (I guess depending on how you installed node and npm it may be necessary to specify the path to npm).

The line `'C:\Users_\AppData\Local\Temp\npm-5464-54bc4da9\unpack-056e3c18416e\package.json' is saying that whatever you downloaded does not contain npm package information. I guess based on the name you downloaded something related to http://tyrasd.github.io/osmtogeojson/, but that is another way of using the code, from a webpage, and won't necessarily have anything to do with npm.

(14 Feb '16, 17:48) maxerickson
1

One of the reasons to use npm to install packages is that it will automatically fetch and install any libraries that a script might use. In this case, the script doesn't need any additional libraries, so it is possible to rip the script out of a package and run it directly, but people using node.js will still expect to be able to easily install the script by running the command npm install -g osmtogeojson.

(15 Feb '16, 13:07) maxerickson

Hi, I'm the dev of osmtogeojson.

Did you manage to get it to run in the end? If so, can you please post the steps you performed to do so? I can probably add these instructions/information to the github repo for other Windows users.

(15 Feb '16, 14:11) tyr_asd
2

I've borrowed a Windows machine to check, the node installer installs itself and npm to the path, so a command like npm install -g osmtogeojson works just as expected, and osmtogeojson is immediately available once that completes. No additional fussing around needed.

(15 Feb '16, 14:22) maxerickson
1

... and there is a (slightly cryptic) Windows section in https://www.npmjs.com/package/npm

(15 Feb '16, 14:43) SomeoneElse ♦

Hi tyr_asd

I have got it to work, but I want to double check it's the best way to do it. As I said npm/node is new to me, so I maybe misunderstanding some of it main points.

Do you provide a package of overpass 'stuff' for npm to load? Can you dictate the file names? Having the .js & .cmd files both named 'osmtogeojson' is quite confusing when the command does specify the extension..

(15 Feb '16, 14:49) DaveF

Hey Dave. Yes, I chose these file names and now I see that it can be indeed irritating. On the other hand, I've expected that most users would install the CLI tool via via npm -g, so I thought it doesn't matter ;-)

When I come around to it, I'll put the different files in different directories (i.e. "executable" osmtogeojson into bin, compiled library osmtogeojson.js into dist,sources into src)…

(15 Feb '16, 15:37) tyr_asd
1

Thanks tyr_asd, that would clarify things. I would suggest putting a link to NPM Windows download page, but I'm sure they'd move it as soon as you did.

Yes SomeoneElse, cryptic is correct. There's few things NPM need to update on their site such as showing the correct folder it's installed to & linking to the easy to understand download page instead os the DOS style directory listing. It seems a bit ironic that a program to ensure packages are up to date has a convoluted procedure to update itself.

I'll add the procedure I followed shortly.

(16 Feb '16, 12:50) DaveF
showing 5 of 9 show 4 more comments

Likely the "$" there means the command prompt of a Unix-like system's command line interface (see https://en.wikipedia.org/wiki/Command-line_interface#Command_prompt ). And npm is the package manager for Node.js. From what I read, it seems that node.js also runs on Windows, so you should be able to use those commands too (after installing node.js, of course).

permanent link

answered 14 Feb '16, 16:39

aseerel4c26's gravatar image

aseerel4c26 ♦
32.6k18248554
accept rate: 18%

edited 14 Feb '16, 16:41

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:

×48
×4
×4

question asked: 14 Feb '16, 16:22

question was seen: 4,607 times

last updated: 16 Feb '16, 13:08

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