What is ST in PostGIS?

From the manual: PostGIS has begun a transition from the existing naming convention to an SQL-MM-centric convention. As a result, most of the functions that you know and love have been renamed using the standard spatial type (ST) prefix. Previous functions are still available, though are not listed in this document where updated functions are … Read more

Determine timezone from latitude/longitude without using web services like Geonames.org

I had this problem a while back and did exactly what adam suggested: Download the database of cities from geonames.org convert it to a compact lat/lon -> timezone list use an R-Tree implementation to efficiently lookup the nearest city (or rather, its timezone) to a given coordinate IIRC it took less than 1 second to … Read more

Fast Haversine Approximation (Python/Pandas)

Here is a vectorized numpy version of the same function: import numpy as np def haversine_np(lon1, lat1, lon2, lat2): “”” Calculate the great circle distance between two points on the earth (specified in decimal degrees) All args must be of equal length. “”” lon1, lat1, lon2, lat2 = map(np.radians, [lon1, lat1, lon2, lat2]) dlon = … Read more

Convert a shapefile (.shp) to xml/json

What dassouki said. Get GDAL from http://www.kyngchaos.com/software:frameworks. Use it to convert a shapefile to GeoJSON like this: $ ogr2ogr -f “GeoJSON” output.json input.shp eg $ ogr2ogr -f “GeoJSON” /tmp/world.json world_borders.shp world_borders $ cat /tmp/world.json { “type”: “FeatureCollection”, “features”: [ { “type”: “Feature”, “properties”: { “CAT”: 1.000000, “FIPS_CNTRY”: “AA”, “CNTRY_NAME”: “Aruba”, “AREA”: 193.000000, “POP_CNTRY”: 71218.000000 }, … Read more

Best way to overlay an ESRI shapefile on google maps?

I like using (open source and gui friendly) Quantum GIS to convert the shapefile to kml. Google Maps API supports only a subset of the KML standard. One limitation is file size. To reduce your file size, you can Quantum GIS’s “simplify geometries” function. This “smooths” polygons. Then you can select your layer and do … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)