geographika

imageThe MapFish print module used by both MapFish and GeoExt generates PDF maps that can be saved to clients machines. Over time you can acquire hundreds of different PDFs, but unfortunately Windows XP does not generate thumbnail previews to help find them again later.

The script below solves this problem by generating a PNG image of all the PDFs in a folder. The image to the left shows the results of the script when run on a series of UN Mission Maps.

This relies on two programs to be installed. ImageMagick – a free image conversion software package, and GhostScript another free program that can be used to access, read, and create PDF files. You may have to reboot your machine after installing these programs for the script to run successfully.

The script uses a convert utility program which comes with ImageMagick. Continue reading »

image

A common requirement in GIS is to be able to find the number of points in a polygon to answer a question such as “how many towns are in this county.”

With the spatial operations in SQL Server this can be calculated dynamically, however for large spatial datasets it can often take several minutes to run the query. If a user is running the query through a web interface they will either give up, or the connection will time out.

It can be useful to assign all features to a parent polygon in the database so these calculations are almost instant. To do this run the following SQL:

Continue reading »

Proxy ServerDue to the same origin policy any data from a remote server cannot be (easily) added to a web application on your own server. This issue also applies to WFS (Web Feature Services) and OpenLayers. There is a Python script that can be used to get round this issue, but I preferred to have a native .NET equivalent.

On the OpenLayers Mailing List Diego Guidi pointed to an opensource .NET proxy. A proxy makes a request to a remote URL, reads the response, and then sends it to the client so it appears all data comes from the same server.

The .NET proxy is written by Paul Johnston, and can be found at http://code.google.com/p/iisproxy/. I made a few minor changes as follows:

  • increased the byte size for reading responses to resolve this issue
  • added support for PUT requests
  • temporarily removed GZIP compression due to invalid responses and a possible bug in .NET

The proxy can be used for any requests and is not limited to just OpenLayers. My source files can be found at http://bitbucket.org/geographika/openlayers/src/bfeab6a9971a/iisproxy/

I’d recommend reading the original project’s README file which goes through compilation and installation, but I’ve added my own notes below. Continue reading »

image

I recently asked a question on GIS Stack Exchange on how to create a  buffer around a point that took into account the curvature of the earth. OpenLayers has support for geodesic measurements, but not creating geodesic polygons. Drawing a standard polygon on a Mercator projected map can produce features with very different measurements from their intended “on the ground” equivalents.

Paul Ramsey pointed out that “the scale errors for Mercator are very high indeed (infinite, in fact, at the poles) increasing as you head north/south from the true scale latitude.” In fact drawing a circle (in Ireland – 53 degrees North) with a 10km geometric radius produced a circle with an on the ground radius of 6km.  A huge margin of error over a very short distance (see a previous post on the same subject).

After a useful answer from Dan Shoutis, it appeared most of the work to implement geodesic circles was already available in the OpenLayers API. The OpenLayers’ geodesic functions are based on code adapted from Chris Veness work at http://www.movable-type.co.uk/scripts/latlong-vincenty-direct.html.

The code to create a regular (non-geodesic) polygon can be seen in the OpenLayers source here. There is a function added after the class OpenLayers.Geometry.Polygon.createRegularPolygon that can be used to “create a regular polygon around a radius. Useful for creating circles and the like.”

This function only required a couple of changes – notably using Longitude and Latitude and rather than X and Ys, to produce geodesic polygons. If you are using the Mercator projection then transformations requires proj4js support. Continue reading »

Nov 102010

image

The next post will be written by Adrià Mercader who has been working on configuring the MapFish print server to be used on IIS. This fits in perfectly with the recent Window / open source hybrid web-mapping solutions I have been working on.

Adrià is also the author of the WMS Inspector a FireFox plug-in that allows you to view and analyse WMS requests for a web-page. This was recently presented at FOSS4G in Barcelona, near Adrià’s hometown. He has recently moved to Newcastle in the UK, clearly for both better weather and football.

image Installing Python modules on 32 bit Windows is a fairly simple process once you get to know the vocabulary of packages (Python scripts and libraries), eggs (similar to a bundled zip file), and the Cheeseshop (the Python “app store” equivalent – now renamed the Python Package Index or PyPi).

Many popular packages in PyPi have custom Windows installers that take care of both Python files and any associated DLLs. For example Shapely and NumPy.

For other packages the easiest way to add them to your Python installation is to use Setup Tools. Download the Windows setup package corresponding to your version of Python from http://pypi.python.org/pypi/setuptools and double click to install.

This adds an easy_install.exe to your C:\Python\Scripts folder that can be used to quickly add packages.  You run easy_install from the Windows command line followed by the name of the package. It searches the online PyPi for the best match for your Python version, and then downloads and installs it.

Continue reading »

image OGR, created by Frank Warmerdam, is an open source library and set of command line utilities for reading and writing geospatial vector data using many different formats . It is the vector equivalent of GDAL which has similar functionality for rasters.

The name of the library is a vestige from when OGR used to stand for OpenGIS Simple Features Reference Implementation. However as OGR is not fully compliant with the OpenGIS Simple Feature specification the name was changed to OGR Simple Features Library (from the GDAL FAQ).

The latest additions to the OGR formats are the SQL Server 2008 geometry and geography. This enables spatial data in SQL Server 2008 to be reprojected, and converted to other formats (shapefiles, MapInfo, KML, GML, GeoJSON and any of the many other formats already supported by OGR) using freely available open source tools. Details on the associated OGR tools can be seen here.

The full MSSQLSpatial OGR driver notes and details are available online.

Continue reading »