how to read json from web http request of url via python urllib

Read more →

minimum insertions to form a palindrome

Brute-force approach Here I present a few approaches to deduce “minimum insertions” required to convert a string into a palindrome. The basic brute force approach is quite simple, given a string with length L, start comparing, the first character from left and the last character while scanning inwards. Here is a basic test for a palindrome. L = len(s) for i in range(L): if s[i] != s[L - i - 1]: return False,i,L-i -1 return True,0,0 The above code returns True if the string is a palindrome or returns False with mismatching indices.
Read more →

merge sort in python

Many useful algorithms are recursive in structure: to solve a given problem, they call themselves recursively one or more times to deal with closely related subproblems. These algorithms typically follow a divide-and-conquer approach: they break the problem into several subproblems that are similar to the original problem but smaller in size, solve the subproblems recursively, and then combine these solutions to create a solution to the original problem. The divide-and-conquer paradigm involves three steps at each level of the recursion:
Read more →

Using Geotiff as datasource via gdal

Recently, I have been working on algorithms which needs elevation data as well as Land Cover data, with world coverage. Google has an excellent elevation API however free usage comes with a limit. While searching, I came across a dataset in geotiff format for landcover as well as a processed version of world elevation. Elevation data comes in various resolution (250m,500m,1km), landcover is 500m . So how do we read it ?
Read more →

How to create fishnets or geospatial grids

There are many use cases in GIS world, where the information has to be aggregated, an easy way to achieve this is via gridding or binning, where the area of interest is divided into small sections called grids or bins. These sections are mostly of rectangular form (which can be easily converted into geotiffs), but in some cases even circles or hexagons are also used. You can read a good tutorial from mapbox using Qgis with a mmqgis plugin here.
Read more →