Tag Archives: gis

GMap.NET component : Moving Marker

WTH is GMap.NET?

Simply put: it’s an open source .net component that can show online mapping service (such as Google Map, Bing Map, OpenStreetMap) in your .NET app.
Download the binary here: http://greatmaps.codeplex.com/
Extract it. You’ll get the .net 2.0 and .net 4.0 version, since I’m using VS 2015, we’ll use the .net 4.0 version.

What will we do now is about how to move a marker inside the map (for tracking/visualizing object movement, etc). We’ll just move the marker randomly in this tutorial.

  • Create new VB Windows Form project
  • Add GMap.NET component into your project reference
GMap.NET component reference

GMap.NET component reference

  • Add GMap.NET component into your toolbar.
Add GMap.NET component step 1

Add GMap.NET component step 1

Add GMap.NET component step 2

Add GMap.NET component step 2

  • Now drag and drop the GMap.NET control into your Form, I name it myMap
  • We’ll also add another controls: 1 Button (name: btnMove), 1 Timer (name: tmr1), 1 Label (name: lblInfo)
List of components

List of components

I also add new bitmap resource into our project properties. This will be used as our marker symbol.

Resource for marker symbol

Resource for marker symbol

You can see the Form’s full source code at the bottom of this post. I’ll just point out some important parts:

  • Map initialization is on Form1_Load event code (zoom level, initial position, provider used, marker type, etc)
  • When you click on the btnMove, it’ll start generating new random position for our marker. The random change is happened in the timer event (tmr1_Tick)
  • The process to update the map visual is delegated into function update_map(), so it will run in different thread and the form still responsive
  • In this tutorial, we are using BingSatelliteMapProvider, you can use another provider such as GoogleMapProvider or OviSatelliteMapProvider. Just see MapProviders namespace to see all supported providers.

Running the app

Running the app

Here’s the full source code:

cygwin: failed to build ArduPilot because of isnan / isinf

Upon building SITL on Windows 10 via cygwin following this tutorial: Setting up SITL on Windows, I encountered build error in this step :

Something like these (the original error is very long):

So, it seems the libraries is trying to use isnan function but can’t find it.
The solution is quite simple (although I’m not sure if it’s the correct way, but hey.. my solution works!): we edit all .cpp and .h files inside ardupilot/libraries/ folder (and subfolders) and replace all isnan and isinf appearance into std::isnan and std::isinf, for example inside ardupilot/libraries/AP_AHRS/AP_AHRS.cpp line #271, replace:


to find files that references isnan and isinf, you can use find command (from within ardupilot/libraries/ folder) like this one:

find all .h and .cpp files that contain "isnan" reference

find all .h and .cpp files that contain “isnan” reference

and for isinf:

It’ll show you the files that need to be edited. (You might need to install nano to edit the files — just for convenience).

And done! You are good to go to build SITL in Windows!!

SITL running in windows 10 64bit

SITL running in windows 10 64bit

Exporting high resolution image from QGIS project



You want to export your QGIS project into high resolution image. QGIS desktop “Project” –> “Save as Image” only save/export the project into a low resolution image (i.e. your desktop resolution).



1. Finish your project in QGIS

Finish your GIS project in QGIS Desktop, choose which layers to be shown, what style should it use, etc.

2. Choose your extent that will be exported into image

For myself, I choose the full-extent, but you may choose the extent as you wish. You my use “Vector” –> “Coordinate Capture” to help copying the coordinates. You will need to write down the coordinates for [xMin, yMin] (top-left coordinate) and for [xMax, yMax] (bottom-right coordinate). Save and close your QGIS project.

3. Execute the export command via command line of QGIS

Open your command prompt/console (preferably as Administrator/root). Go to your QGIS binary folder, where you install QGIS +”bin” folder, for example C:\Program Files\QGIS Brighton\bin. Use this command template:

For example:

That command will open QGIS Desktop for a moment then close itself. The command will produce padangsari.png in c:\users\achmadz\documents\. Open the image, and you’ll see the image in high resolution (5000×5000 pixels).


[matlab] modifying/manipulating shapefile (.shp) contents

Before you start reading:

  1. You should check if “Mapping Toolbox” is installed in your MATLAB first. You can check it by typing “ver” command on your MATLAB “Command Window”.
  2. I’m using MATLAB r2014a to test the code
  3. I’m using this SHP file: Shapefile for Polewali Mandar

Adding new field/attribute to the shapefile
Actually, until now, I don’t know how to do it using MATLAB alone. As you know, a shapefile (.shp) doesn’t stand alone, there always be some other files with the same name but different extension. The one we need if we want to add a new attribute/field into the shapefile is the file with .DBF extension. Yup, it’s just DBASEIII+ file. Usually I use LibreOffice Calc to open the .DBF file and then adding the new field as new column and save it back as .DBF file. See screenshot:

Adding new attribute/field via LibreOffice Calc

Adding new attribute/field via LibreOffice Calc

As you can see, I add new attribute, i.e. ‘KELAS’ which is character type field (‘C’) and has 11 in length.
You can always use specialized GIS apps to do this (such as QGIS) but I don’t have it on my working PC, so I just grab whatever I have. 😀

Opening a shapefile
as simple as this:

Deleting/removing attribute from shapefile
Use these code sequences:

Finding object inside shapefile based on it’s attribute value
something like these:

Edit and save back the attribute value
An example:

Viewing the shapefile interactively
Use the built-in interactive viewer:

It will open a new MapView window where you can import the shapefile from workspace variable or via opening the file directly.

MAPLAB's mapview

MAPLAB’s mapview

Calling/Using Google Maps API reverse geocoder from PHP

Still talking about web GIS here..

Reverse geocoder is a way of converting GPS coordinate (latitude, longitude) into human readable address.

Instead of JavaScript, we also can call reverse geocoder feature from Google Maps API via PHP. This is useful if you are somehow need to get user position in human readable format not only as latitude and longitude pair. You can then save this return value to database or just looking for a place name that has address similar to the returned value (addresses).

This is working example code in PHP:

Example result:

As you can see, Google Maps give you several level of human readable address. You may interested in “formatted_address” of results object. It is the human readable address that you can show directly to user. A way of calling it (example):

Other interesting object is address_components, you can, for example, get visitor’s state/province by looping of types array under each address_components object.