How to run TopoJSON? - node.js

I need to convert a geojson file to topojson and possibly simplify the topojson file. I've managed to install Node.js and the topojson package. But I have no idea how to run topojson.
The wiki lists a bunch of command line options, but where do I run those commands? I've tried running them both in the command prompt and the node shell. Node, GDAL, ogr2ogr and TopoJSON are all new concepts for me, so I'm a bit confused and overwhelmed.
I'm running on Windows by the way.

topojson executable is now changed to geo2topo
Installation steps remain the same, just like topojson
To create a topo json file from geo json file, geo2topo -o topo-output.json geo-input.json
One way to obtain geo-input.json is from gdal which takes a shape file as input and outputs geojson. gdal can be installed via home brew using brew install gdal

this should work fine on windows too
install nodejs http://nodejs.org/
install npm https://npmjs.org/doc/README.html
run npm install -g topojson in your command prompt
use the command prompt to cd to the geojson file
run topojson -o myNewTopojsonFile.json myOldGeojsonFile.json
origin https://gis.stackexchange.com/questions/45138/convert-geojson-to-topojson

I had the same issue on Ubuntu 14.04.
I found that my node.js executable is called nodejs instead of node.
I opened the topojson script (usr/bin/topojson) and found that it was trying to run topojson with a node executable called node.
#!/usr/bin/env node
I edited this file so that it runs with nodejs instead
#!/usr/bin/env nodejs
and now it works fine for me.
Hope this helps someone else.

It has been changed to geo2topo
1) Run
sudo npm install -g geo2topo
2) check if it returns the path
which geo2topo
It should give the path /usr/bin/geo2topo
3) Use it to convert your geojson file
geo2topo -o output.json input.json

Related

How to run TopoJSON on Mac?

I need to bind a CSV file to topojson. I installed Node js with brew.
I can successfully run the command npm install -g topojson but when I put in which topojson, it doesn't return any file path.
I checked to confirm I have the command line tools installed and I do.
My command to bind the CSV returns -bash: topojson: command not found even though the npm install -g topojson command runs smoothly.
topojson package installs five executables: geo2topo, toposimplify, topomerge, topo2geo, topoquantize.
Getting command not found for trying to execute topojson is the normal response: indeed, such an executable does not exist.

Trying to install less on Ubuntu 16.04

As I wrote up there I'm trying to install less on Ubuntu. I'm using Xampp as localhost, but from what I've read seems that it doesn't matter. However, after I've installed node.js from nodejs.org, I went to lesscss.org and I followed the instructions.
When I type this command on the terminal
lessc styles.less
I get the following error
lessc: ENOENT: no such file or directory, open '/path/to/cwd/styles.less'
where the path corresponds to my actual path but there isn't any styles.less file of course. I also tried to create a blank one and retry but nothing. What should I do ?
You probably need to install less using npm install -g less. lessc should be available as /usr/bin/lessc.
Also, make sure /usr/bin is on your path by running echo $PATH.
EDIT
I just noticed you were able to run it. You need to create some .less files and run lessc <FILENAME>. The output will be printed out to the screen but you can specify a destination file as well, lessc <SOURCE> <DESTINATION>. See command line usage I recommend using a build tool such as gulp or webpack.
STEPS TO INSTALL LESS IN UBUNTU 16.04
Open Terminal.
Check availability of npm. Write "npm -v", here -v means version.
If there is npm by default in your system then it will show you the version of that npm. If there is no npm installed in your system then it will ask you to install the npm.
To install npm in your ubuntu. Write "sudo apt install npm".
Now you have to install the less library. So, to install less. Write 2 commands accordingly:-
(i) sudo apt install less
(ii) sudo apt install node-less

node -bash: /usr/sbin/node: No such file or directory

I am having this error with node. Running Debian 7 (Wheezy) a VPS.
I have this error if I for example run this command (in the directory of the .js)
node sell.js
or
screen node sell.js
They both don't work, because I am getting this error:
-bash: /usr/sbin/node: No such file or directory
Can somebody help me?
As in #Quentin's answer, the name of the executable may be incorrect. In many cases, what got installed was nodejs, not node. The line below creates a symbolic link that points to nodejs from where your system looks when you type node. It is a work-around - an alternative to simply typing nodejs
sudo ln -s /usr/bin/nodejs /usr/sbin/node
The Debian package for NodeJS is called nodejs and installed the executable /usr/bin/nodejs.
node is the wrong program, it is for ham radio operations, and your install of it appears to be broken anyway).
I ran the command:
sudo apt-get install nodejs-legacy
and nodejs worked again!
Maybe something wrong happened during your node's installing.
And system environment variable shows the command "node" referes to /usr/sbin/node .
Try download node linux binaries from official. Rename and put it in /usr/sbin after extracting the source. Of course you can put it in another folder as long as you update the system environment variables.

How can I get the slc command to work on Ubuntu?

I have installed Strongloop using npm install -g strongloop on my Ubuntu 14.04 server. The slc command does not work. It says
The program 'slc' is currently not installed. You can install it by typing:
sudo apt-get install heimdal-multidev
How can I get it to run the Strongloop CLI instead of looking for this package? I have added this to my PATH and it still doesn't work. Any ideas?
Other Strongloop commands, like sl-build work and strongloop is listed in npm list -g.
Ubuntu 14 with node.js 4.1.2
By default somehow slc is not created or not added to PATH.
I solved this problem by adding symlink:
sudo ln -s /usr/lib/node_modules/strongloop/bin/slc.js /usr/bin/slc
A soft link named slc should have been created at /usr/local/bin which will point to strongloop binary.
Please verify if the following exists.
/usr/local/lib/node_modules/strongloop/bin/slc
If no, then strongloop did not get installed successfully, otherwise verify the existence of the softlink slc at /usr/local/bin/.
/usr/local/bin/slc -> /usr/local/lib/node_modules/strongloop/bin/slc
If yes, then /usr/local/bin needs to be added to the $PATH, otherwise create the softlink and verify that /usr/local/binin $PATH.
Looks like the Node installation that optionally comes with a Digital Ocean Droplet installs to a different location that's not in $PATH. I'm pretty sure that was the issue. Anyways, I fixed it by spinning up a server without Node pre-installed and followed this guide. Just use npm install -g strongloop instead of strong-cli because the latter has been deprecated.
Ubuntu 14.04 with node.js 4.4.2 (LTS) :
The installation of strongloop was done without any errors but slc was not added to the PATH. I solved this problem by adding the symlink:
sudo ln -s /usr/local/lib/node_modules/strongloop/bin/slc.js /usr/bin/slc
Actually i am not sure my case matches with yours but i want to share my experience. i got the same message anyway.
I realized that i had changed prefix of global packets before. Then i checked prefix with the following command.
$ npm config get prefix
/home/myUser/.node_modules_global
Then i added the path to PATH variable (but .profile, .bash_profile files will be better) in active command line window and problem solved.

installing nodejs module doesnt give me the command

I am trying to run pixel-ping and running into trouble. I followed these instructions:
http://documentcloud.github.io/pixel-ping/
and it mentions that Installing Pixel Ping gives you the pixel-ping command. but when I type pixel-ping path/to/config.json it returns -bash: pixel-ping: command not found
I am not sure why it would say that any ideas would be greatly appreciated. I have both nodejs and npm installed I have other modules working perfectly. Am I doing something wrong ?
curl npmjs.org/install.sh | sudo sh
Install Pixel Ping via NPM:
sudo npm install -g pixel-ping
Restart shell
Also ensure
~/npm/bin is in the Path

Resources