Wednesday, May 17, 2017

Code snippet: Identify to which polygon a point belong to?

Be The First To Comment
Code sample to find point inside a polygon in shape file using GDAL/OGR 2.x and C#.


using OSGeo.OGR;
using OSGeo.OSR;
using OSGeo.GDAL;
1:  public void FindPolygonBelongsToPoint()   
2:      {  
3:        try   
4:        {  
5:          var shapePath = @"C:\Locations_WGS84.shp";  
6:          Ogr.RegisterAll();  
7:          OSGeo.OGR.Driver shapeDriver = Ogr.GetDriverByName("ESRI Shapefile");  
8:          DataSource shape = shapeDriver.Open(shapePath, 0);  
9:          Layer layer = shape.GetLayerByIndex(0);  
10:    
11:          Feature polygonFeature = layer.GetNextFeature();  
12:    
13:          long featureCountInLayer = layer.GetFeatureCount(1);  
14:          for (int i = 1; i <= featureCountInLayer; i++) {  
15:    
16:            Geometry polygonGeom = polygonFeature.GetGeometryRef();  
17:    
18:            string coordinates = "POINT (-100.726 38.995)";  
19:    
20:            SpatialReference spatialRef = layer.GetSpatialRef();  
21:            Geometry point = Ogr.CreateGeometryFromWkt(ref coordinates, spatialRef);  
22:    
23:            bool isInside = point.Within(polygonGeom);  
24:    
25:            if (isInside)  
26:            {  
27:              var val = polygonFeature.GetFieldAsString(4);  
28:              Console.WriteLine("Found one");  
29:            }  
30:    
31:            polygonFeature = layer.GetNextFeature();            
32:          }         
33:            
34:        }  
35:        catch (Exception ex)   
36:        {  
37:    
38:          Console.WriteLine(ex.Message);  
39:        }          
40:        
41:      }  

Tuesday, February 11, 2014

We will miss the "father of GIS"

Be The First To Comment
Dr. Roger Tomlinson has passed away. Tomlinson is generally recognized as the "father of GIS.” He is the visionary geographer who conceived and developed the first GIS for use by the Canada Land Inventory in the early 1960s.  This and continuing contributions led the Canadian government to give him its highest civilian award, the Order of Canada, in 2001.  Text for that award reads, “he pioneered its uses worldwide to collect, manage, and manipulate geographical data, changing the face of geography as a discipline.”

Tomlinson tells the story of how this came to be.  In the early 1960s he was working as a photo interpreter for Spartan Air Services in Canada.  They had a contract to identify the best location for a tree plantation in Kenya.  They turned to their young geographer Tomlinson and asked him to develop a methodology.  He tried various manual methods for overlaying various environmental, cultural, and economic variables, but all were too costly.  He turned to computers and found the solution.  Subsequently he sold this approach to the Canada Land Inventory that had the responsibility of using data to assist the government in its land use planning activities.  His GIS approach reduced the task from three years and eight million Canadian dollars to several weeks and two million dollars.
 
He went on to serve the community in many ways.  He chaired the International Geographical Union’s GIS Commission for 12 years, where he pioneered the concepts of worldwide geographical data availability. He is a past president of the Canadian Association of Geographers a recipient of its rare Canadian Award for Service to the Profession.
 
Other awards followed including the James R. Anderson Medal of Honor for Applied Geography (1995) and the Robert T. Aangeenbrug Distinguished Career Award (2005) from the American Association of Geographers.  He was the first recipient of the Aangeenbrug award and also the first recipient of ESRI’s Lifetime Achievement Award (1997). National Geographic gave him its rare Alexander Graham Bell Award for exceptional contributions to geographic research (2010). He is an Honorary Fellow of the Royal Geographical Society and the recipient of multiple honorary doctorates – in addition to his own PhD from University College London.  

Sunday, January 13, 2013

Popular GIS Books

Be The First To Comment
Books Pro Cons
It provides solid guide to how geospatial analysis work, particularly with respect to GIS. The book emphasizes conceptual workflows and with basic math which is helpful for creating own code and also getting an understanding of what's happening under the hood in contemporary GIS. It is better to have an update because lots of changes in GIS software over last five years.
This book is for typical GIS user aspiring to design good maps. It is illustrating GIS map software and throughout with map samples in color which is especially useful for those who has little prior training or experience in map making. This is acceptable book for beginners but very little information of advanced users. It hardly touches on advanced cartographic representations.
This book explains the computational geometry and algorithms concisely and very readable. It emphasis on describing algorithms and data structures theoretically. It presents pseudo code with lots of figures that is very easy to understand and follow.

It's also worth reading for all computer scientists and mathematicians who are working on geometry.

This is good text/reference book for graduate course.
Focused on geometric computation and algorithm, very complicated for beginners, who does not have prior computer programming knowledge.

The various algorithms and concepts often used in this book are triangulation, indexing, calculating intersection, shortest paths etc.
The book illustrates the most common cartographic deceptions, and provides some excellent color guides. If you want to learn how to make influential maps for a cause, this is the book!. The reader can learn what to look for and how to avoid the inadvertent or unintentional 'lies'. Worth the effort! Basically, the book as an introduction to the science of cartography and targeted for prospective cartographer or decision making authority.
The book details the use of freely available open source mapping software and tools such as MapServer, GDAL, OpenEV, and PostGIS to create web gis and web maps.

Mostly focused on UMN Mapserver for web mapping and building web gis.
Not much technical discussion on how GPS databases work, how to decode GIS information.
The book is fairly shallow. It will give you a couple of basic examples of how to use some pieces of software, but for anything more complicated, you have to look elsewhere.

Thursday, January 10, 2013

pyKML - a Python library for generating and parsing KML

Be The First To Comment


pyKML is an open source Python library for generating, parsing, and modifying KML, the geo-spatial data language used by Google Earth, Google Maps and a number of other GIS platforms.

pyKML helps working with large and complex KML documents by leveraging the use of basic programming constructs (looping, branching, etc.). In this regard pyKML is similar to libkml, Google’s open source C++ library, but takes advantage of the highly readable syntax of the Python programming language and the processing capabilities of the popular lxml Python library.


pyKML v0.1.0 documentation :  http://packages.python.org/pykml/



Thursday, October 13, 2011

DIVA GIS

Be The First To Comment
Today, I was working on Shapefiles from Australia and Nepal for my biodiversity research. I found DIVA GIS is useful for the scientist and students who can't afford ESRI's ArcGIS suite. DIVA-GIS is particularly useful for mapping and analyzing biodiversity data, such as the distribution of species, or other 'point-distributions'. It reads and write standard data formats such as ESRI shapefiles, so interoperability is not a problem. DIVA-GIS runs on Windows and (with minor effort) on Mac OSX.

Wednesday, July 13, 2011

Google Earth Engine API : An ambitious Project

Be The First To Comment
A highly ambitious project by Google, Google Earth Engine, will be launch by  the end of 2011. This project is using high resolution images from more than 30 earth observing satellites such as Landsat, MODIS, IKONOS, QuicBird etc to build global archive of atmospheric corrected data sets. According to Earth Engine team, these archives will be"available online with tools for scientists, independent researchers, and nations to mine this massive warehouse of data to detect changes, map trends and quantify differences on the earth's surface" in a cloud computing platform. 


Currently, this project is in testing phase with limited  access to few groups of partner including CLASlite and IMAZON.  Let us wait and see how far they can go !!!

Wednesday, May 25, 2011

Choropleth mapping techniques for Web2.0

Be The First To Comment
For my recent project, I have to display county wise time series data of disease pattern in web map for the conterminous United States for 20 years. In addition, I have to use Google maps as base layer and should overlay images on the top of it.  The concept sounds easy, and it was also similar with choropleth or thematic mapping. However, it should be in the Web 2.0.

I tried to figure out what are the possible ways to achieve this, I tried and few of them. Here I am going to share the pros and cons of these methods in a real quick and dirty style.

Choropleth with GFT
1) Google Fusion Tables

Pros:
Easy, No understanding of computer programming needed. Upload small or large data sets from spreadsheets or CSV files. Visualize your data on maps, timelines and charts. Pick who can access your data; hide parts of your data if needed. Merge data from multiple tables.

Cons:
Not much flexible and you can’t tweaks easily according to your needs. 

Choropleth with Cartographer.JS and Google API
2) Cartographer.js and Google API

Pros: It generates choropleth maps directly from database or other standard data handlers. Fast for small area mapping.

Cons:
Understanding of JavaScript is needed. It supports only US (County and State level data). I got performance is worst if we map entire 50 states. I recommend it to use to map few states only. Although cartographer.js's documentation claims browser friendly, it is horrible with IE, works so so with Firefox and chrome. 

Friday, May 6, 2011

Geospatial Analysis to Find Bin Laden's Hideout

Be The First To Comment
Think, how powerful in geospatial technology? Finding Bin Laden using GIS?..........Are you kidding me? .......Take a look on this article from Good politics share the UCLA students' research on finding Bin Laden's possible hideouts using geographical theories and  GIS software.

The students were work under Prof. Thomas Gillespie and John Agnew, UCLA, were published their findings in MIT International Review(Pdf).
 

© 2011 GIS and Remote Sensing Tools, Tips and more .. ToS | Privacy Policy | Sitemap

About Me