get city from geocoder results?

Got this working in the end using: var arrAddress = item.address_components; var itemRoute=””; var itemLocality=”; var itemCountry=”; var itemPc=””; var itemSnumber=””; // iterate through address_component array $.each(arrAddress, function (i, address_component) { console.log(‘address_component:’+i); if (address_component.types[0] == “route”){ console.log(i+”: route:”+address_component.long_name); itemRoute = address_component.long_name; } if (address_component.types[0] == “locality”){ console.log(“town:”+address_component.long_name); itemLocality = address_component.long_name; } if (address_component.types[0] == “country”){ … Read more

Check if a geopoint with latitude and longitude is within a shapefile

Another option is to use Shapely (a Python library based on GEOS, the engine for PostGIS) and Fiona (which is basically for reading/writing files): import fiona import shapely with fiona.open(“path/to/shapefile.shp”) as fiona_collection: # In this case, we’ll assume the shapefile only has one record/layer (e.g., the shapefile # is just for the borders of a … Read more

Converting latitude and longitude to decimal values

To parse your input use the following. function ParseDMS(input) { var parts = input.split(/[^\d\w]+/); var lat = ConvertDMSToDD(parts[0], parts[1], parts[2], parts[3]); var lng = ConvertDMSToDD(parts[4], parts[5], parts[6], parts[7]); } The following will convert your DMS to DD function ConvertDMSToDD(degrees, minutes, seconds, direction) { var dd = degrees + minutes/60 + seconds/(60*60); if (direction == “S” … Read more

Polygon area calculation using Latitude and Longitude generated from Cartesian space and a world file

I checked on internet for various polygon area formulas(or code) but did not find any one good or easy to implement. Now I have written the code snippet to calculate area of a polygon drawn on earth surface. The polygon can have n vertices with each vertex has having its own latitude longitude. Few Important … Read more