Arsip

Archive for the ‘Tips’ Category

R: Read GeoJSON as ppp (Point Pattern) dataset

It’s not obvious (or is it just me?) to read a GeoJSON file as point pattern (ppp) in spatstat. I tried several libraries and spent hours before I got it working. The installation itself is not straight forward, for some reason. But, finally, I made it. Here the code, to save your time (or my time in the future):

# install.packages("geojsonio") # Install the required package
library(geojsonio)
path <- "/home/ismailsunni/dev/r/spatial-analysis/eq-project/eq.geojson"
eq <- geojson_read(path, what='sp') # Read GeoJSON as SpatialPointsDataFrame
eq <- as.ppp.SpatialPointsDataFrame(eq) # Convert to ppp
# eq <- as(eq, "ppp") # Or you can use this one, if the above line doesn't work.
view raw geojson.r hosted with ❤ by GitHub

Hope it helps 🙂

Kategori:GIS, R, Tips Tag:, ,

Fixing Geomatica Crashes

17 Februari 2019 1 komentar

Lately, I need to work on Geomatica software. It’s interesting software, but unfortunately, we need to pay to use it. I admit, it’s powerful but has quite bad UI. Anyway, I haven’t played much with it. I also only use the 30 days trial version

One of the thing that I need to do is image classification for remote sensing. I have a raster data, that I need to classify. Unfortunately, every time I tried to create a data training (creating some polygon to mark it as a class), the Geomatica is always hanging then crash. It starts crashing when I try to pan or zoom the layer.

Geomatica

My friends (who also got the same problem) recommended me to pan slowly, do not zoom too much, or disable the other layer. Unfortunately, it does not help much. It’s frustrating actually since I need to have about 20 data training for each class.

Strangely, it was working fine in my friend’s laptop although her laptop doesn’t have a high spec as mine (mine is XPS 9360, it has SSD, i7 proc, and 16GB RAM). Finally, I got an idea that perhaps the screen resolution of my laptop is too high for it.

The initial resolution is 3200×1800. I changed it to 1600×900. Finally, it works fine. I didn’t try with other resolution though.

It’s not comfortable to work with less resolution actually. The image is not as sharp as before. So, I need to revert to the initial resolution to make me happy again.

Hope it helps 🙂

Kategori:GIS, Tips Tag:, , ,

Removing GNOME Shell Extension

17 Januari 2019 2 komentar

After long time using Macbook Pro for about 3 years, I came back to use Ubuntu for my daily stuff. I found this interesting GNOME shell extension. For me, it’s like a plugin that we can install to get new functionality. There are some useful extension like OpenWeather or Caffeine.

As a new user, I want to try many extensions, and see which one that is useful for me. I ended up installing more than 10 of them. I found some of them are not useful for me, and some of them even broken. So, I wanted to uninstall them.

I use this URL to uninstall my extensions: https://extensions.gnome.org/local/. But, for some reasons, it doesn’t work. I tried to uninstall an extension, but it comes back after I restart my machine. Some extensions even messed up my top bar (?). It’s kind of annoying.

GNOME Extensions

After some time, I googled my problem, and it seems (as always), it’s not only me. I found this thread. It’s better to uninstall it by removing the folder of the extension from ~/.local/share/gnome-shell/extensions then restart by doing Alt+F2 and write restart.

Unfortunately, not all extension are in that directory. It turns out, some of them are installed system wide, thus you need to go to /usr/share/gnome-shell/extensions/, and restart like step before.

Here you go, you can remove your unused extension forever.

Kategori:Tips Tag:, ,

Development Environment Setup, A Story

One of the parts that I don’t really like when starting/joining a new project, is setting up my development environment (dev env). Sometimes, it takes a long time. Once, at my first job, the first three days were spent to set up my dev env. It was creating a plugin for a desktop application. Well, I think again, it was more on my first real experience using non-Windows OS. It was Ubuntu. 😀

I also had an experience with setting up a development environment for a web project that uses Virtual Machine. It was very exhausting. VM is very heavy for my computer. I don’t really recommend it. I use it since I needed to use specific dependency version that not compatible with my OS (mine was Ubuntu 14, it needs Ubuntu 16). Ouch.

Virtual Machine is not my favorite for sure. It’s very heavy, you need to install many things.

Then there is this cool guy, docker. A smaller version of Virtual Machine. It’s very light. You can spin up more than one easily. With a docker compose, you can orchestrate your whole system easily. It’s really helpful. You can have the same environment like in production. No longer “but, it works on my machine“.

I am still using it.

Another thing to set up is your IDE. For example in my favorite IDE, PyCharm, you can set your custom python env, running env, and so on. Sometimes, you miss one step, and it’s not working like in your friend’s laptop.

My friend had this idea, to use Ansible to setup PyCharm. It’s a little bit hacky, but it works. It hacks the PyCharm configuration (which is an XML file). By using Ansible also, he customizes the docker compose override file to match with our computer env. It works really great. Only by updating some variables in all.yml, run it, you can have the same setup as your friend.

Another thing is Rancher. Docker is great, but you need to remember all the commands. I don’t really like it. My company uses it to deploy on the server, for production and staging. I think it’s a great product also. No need typing command, no need to log in to the server. It has nice UI to manage your system. It’s recommended to use also.

So, my current choices are Docker, Ansible, and Rancher. It can be changed for sure. I recommend these tools for your work.

Btw, for a small project, I also use virtual env for python development. It’s easier to setup when I just need to have clean python environment. I also recommend it. But for a bigger project that have many parts, I don’t really recommend it, although I have ever done it :).

Thanks for reading, and please share if you have tips for setting up dev env.

P.S.: Looking back, it’s very funny to remember that I need to spend 3 days for dev env setup. Well, I couldn’t even exit from Vim.

Installing PyCharm 2.7 on Ubuntu

11 Februari 2013 1 komentar

One of the best IDE for Python is PyCharm and I use it currently. The newest version is 2.7. I want to upgrade my PyCharm from 2.6.3 to 2.7. It’s actually an easy step to do it. But, somehow I forgot how to do it on Ubuntu. So, I create this post.

  1. Get your PyCharm from here.
  2. Extract it
  3. Run bin\pycharm.sh

Until this step, you can already use your PyCharm. But, for easiness, it’s would be better to create PyCharm launcher. These are the steps:

  1. Run PyCharm from command line, just like the 3rd step above
  2. Go to Tools–>Create Desktop Entry
  3. Click Ok
  4. Quit your PyCharm session

And, taraaa… You can launch PyCharm from desktop launcher.

If you want to install it on Windows, it will be much easier. Just install it like another application’s installation.

 

Update

If you don’t have any project, you can go to Configure–>Create Desktop Entry

Those steps above also apply for Intellij IDEA