PostGIS 2.0 released

Posted on 19 April 2012 | No responses

Finally, PostGIS 2.0 is released! PostGIS is an extension for PostGreSQL allowing users to store spatial vector and raster data in databases.
PostGIS allows users to store, manipulate, convert and edit spatial data in the same fashion as other GIS. For free!
In addition, PostGIS requires SQL that makes all processes replicable in comparison with other GIS software.

PostGIS team press release:
PostGIS 2.0.0 Released

The PostGIS development team is super excited, can hardly believe that they are actually doing this, aren’t maybe even sure that they are ready to make this kind of commitment, not so young, and not when we have so much more living to do, but:

PostGIS 2.0.0 is complete and available for download.
Read more

New grid dataset for conflict research (and others?)

Posted on 19 April 2012 | No responses

I have recently published a new spatial dataset, the PRIO-GRID. Primarily the dataset is targeting researchers working with armed conflict. However, the data are also useful for other types of research involving spatial data.
The PRIO-Grid data set is a spatio-temporal grid structure constructed to aid the compilation, management and analysis of spatial data within a time-consistent framework. It consists of quadratic grid cells that jointly cover all terrestrial areas of the world. Each grid cell contains cell-specific information on armed conflicts, socio-economic conditions, ethnic groups, physical attributes, climatic conditions and more. Please see the codebook for a complete overview of all the variables included in the PRIO-GRID dataset.

For more information and download, see:
http://www.prio.no/CSCW/Datasets/PRIO-Grid/

Happy PostGIS day!

Posted on 17 November 2011 | No responses

Happy PostGIS day everyone!
Until about year ago, most of my work involved using proprietary GIS software, most of it ArcGIS. Today, almost 100 % of the work i do involve open-source software. Contributing much to this shift has without a doubt been PostGIS.
One of my main projects the last year have been the development of the PRIO-GRID project for the peace and conflict research arena. PRIO-GRID is a spatio-temporal grid structure constructed to aid the compilation, management, and analysis of spatial data within a time-consistent framework. It consists of quadratic grid cells that jointly cover all terrestrial areas of the world. Although PRIO-GRID was designed with peace and conflict research in mind, its potential applicability extends well beyond the study of civil war. What it really is about is to collect spatial data from diverse sources and combine these into a common unit of observation.

The first version of the PRIO-GRID was developed using ArcGIS. We quickly realized that for scientific purposes, ArcGIS did not cover the requirements we had for data replication, easy documentation of all processes we did and software capabilities. In mid 2010 we started discovering PostGIS, and quickly realized that we could create far more advanced queries that covered all of our needs. One example of this was when we wanted to calculate the distance from a set of centroids in the grid to the nearest neighbouring polygon belonging to a different country but still “touching” the departure point’s respective polygon.
In ArcGIS we would have to do this one polygon pair at the time.

In PostGIS we simply wrote this as:
SELECT a.gid, a.gwcode, a.gridyear, MIN(ST_Distance(a.centroid, b.geom))/1000 INTO borddist FROM gridcells a, countrypolygons b, countrypolygons c WHERE a.gwcode != b.gwcode AND a.gwcode = c.gwcode and ST_Intersects(b.geom, c.geom) GROUP BY a.gid, a.gwcode, a.gridyear;

All in all. What i really would like to say is that PostGIS have helped us save time, money and some potential grey hair.

Happy PostGIS day!

PostGIS How-to: NetCDF to PostGIS

Posted on 15 November 2011 | 5 responses

Disclaimer: I am not sure if this is the quickest way of importing NetCDF files to PostGIS, but it works, and for me that is the most important. If you have any other suggestions for improvements, please post them in the comment field!

In my work we need to combine a lot of spatial data from diverse sources. This includes socio-economic, physical and climatic data. Our latest requirement is to be able to import NetCDF files containing climate model data into our PostGIS database. NetCDF (Network Common Data Format) is a multidimensional spatio-temporal data structure with the usual x, y spatial coordinates and a z coordinate or value in addition to the t variable which represents time since some start date.
Our approach is to read the NetCDF in Python using the Scipy.io NetCDF module. This makes it possible to read the NetCDF file into Python and then output it to PostGIS using the psycopg2 module.
Read more

PostGIS How to: Calculate the average raster pixel value inside a polygon

Posted on 2 November 2011 | 1 response

In my daily work I use both vector and raster data and the combination of both. Often, I want to include raster data into our common vector grid. Hence, I often want averaged raster pixel values inside each of the grid cells in our vector grid.
To do this, we need to use both the vector and raster functionality in PostGIS.
In this example i want to calculate the average infant mortality rate pixel value inside each vector grid cell.
One query we use for this is:

SELECT gid, CAST(AVG(((foo.geomval).val)) AS decimal(9,3)) as avgimr FROM (SELECT p.gid, ST_Intersection(r.rast, p.cell) AS geomval FROM imrgrid2p5m r, priogrid_land p WHERE ST_Intersects(p.cell, r.rast)) AS foo WHERE (foo.geomval).val >=0 GROUP BY gid ORDER BY gid;

To explain, we select the vector grid cell’s gid, and the average of (foo.geomval).val FROM the Intersection of the infant mortality raster and the vector grid. Hence, the geomval is a list of each pixels intersection with the vector grid cell. This geomval contain both the actual geometry of this intersection and the value of the pixel. The we apply a where clause of where the cell and raster intersects since the raster is tiled. We also do not want to include negative values (missings) since infant mortality rate is not negative. Then we group the query by the grid cell’s gid since we are aggregating the average pixel value.

PostGIS raster values become integer when Polygonizing

Posted on 1 November 2011 | No responses

Lately I have been trying to find out why my raster decimal values are truncated to integer when polygonizing.
After some research I found out that this is a known bug (http://trac.osgeo.org/postgis/ticket/650), and the problem lies in the GDALPolygonize function. This function is used in PostGIS to convert raster to vector, and since this function do not support decimal values, the values are truncated to integers. Particularly problematic if you are working with a raster with pixel values between min 0 and max 1.
The solution is to use GDAL 1.9dev Subversion from trunk. Hence, you have to compile GDAL 1.9dev yourself, and then recompile PostGIS 2.0.0SVN to include GDAL 1.9dev.

Then, when querying raster to vector with values, you get the correct result.
The below query tests this by querying the average pixel values within a quadratic polygon of 0.5 x 0.5 decimal degree’s.

SELECT gid, AVG((foo.geomval).val)
FROM (SELECT p.gid, ST_Intersection(ST_SetSRID(p.cell,4326), ST_SetSRID(r.rast,4326), 1) AS geomval FROM mountain r, priogrid_land p
WHERE ST_Intersects(ST_SetSRID(p.cell,4326), ST_SetSRID(r.rast,4326),1)) AS foo
WHERE gid = 183230 AND (foo.geomval).val >= 0
GROUP BY gid
ORDER BY gid;


Result
gid;avg
183230;0.404999998294645

PostGIS Back-up and restore

Posted on 4 October 2011 | No responses

Ever wondered on what is the most appropriate way of backing up and restoring your precious PostGIS database? Or have you experienced errors when restoring your old database backup file?
The solution is, put simple: Do not store your data in the public schema in PostGreSQL!
Paul Ramsey explains more in detail on his blog:
http://blog.cleverelephant.ca/2010/09/postgis-back-up-restore.html

Soon back on track

Posted on 18 May 2010 | No responses

Wait Wait
Hey all visitors. Sorry for not updating the blog for a while. I have been very busy working on my thesis.
Updates are coming in a week!

Bounding Containers

Posted on 4 March 2010 | No responses

I had to make some minimum bounding circles from a set of points in ArcGIS. After some searching i came across a very useful script by Dan Patterson. Actually it comes as a set of scripts in a toolbox. Ready to be imported into ArcGIS 9.3.
The toolbox has scripts for generating convex hull, minimum area bounding rectangle, minimum area circle and extent polygons.
You find it here.

Natural Earth – Free Raster and Vector Data

Posted on 17 February 2010 | 1 response


Somewhat unfamiliar to me is the Natural Earth project, providing free raster and vector data of administrative borders, disputed areas, populated places, urban polygons and water boundaries in addition to much more.
Great for updated maps. For historical shapefiles. Check my post on the cShapes dataset.

From their website:
“We developed Natural Earth as a convenient resource for making custom maps. Unlike other map data intended for scientific analysis or military mapping, Natural Earth is designed to meet the needs of production cartographers using a variety of software applications. Maximum flexibility is a goal.”

Go to Natural Earth Website

Reference: http://hansvandermaarel.wordpress.com/

older posts »

Recent Posts

Tag Cloud

Animation ArcGIS ArcGIS 9.4 ArcGIS 10 ArcGIS X Basemap Border Changes CIESIN Conference Conflict Crisis mapping Elevation Maps ESRI ETL FME Free Maps Geographic Information Systems Geoprocessing GIS GIS blog Gis intersect GISintersect.com GIS News GME Hawths Tools Historical Maps New Data Open Street Map Peace Political Maps Python R Reference Maps Road data Safe Software Science SEDAC Spatial Spatial Analysis Special Issue State borders street Transformers Video WMS

Meta

GISintersect.com – GIS Blog is proudly powered by WordPress and the SubtleFlux theme.

Copyright © GISintersect.com – GIS Blog



Google Analytics integration offered by Wordpress Google Analytics Plugin