You are currently browsing the archives for the english category


Converting an Excel file with point coordinates from Gauss-Boaga to WGS84 and to KML file format

Let’s say we have a file like the following, coming from a local mapping agency. It is a Microsoft Excel/LibreOffice where we have two columns for the X and Y coordinates represented in the Gauss-Boaga coordinate system, plus several informational columns containing non-geographic data.

Here an hypotetical tabular data file:

POSXPOSYheighttype
1722813.0005102614.0004.0Lanterne
1722818.0005102572.0003.5Lanterne
1722825.2765102541.0783.5Sfere
1722838.0005102546.0003.5Sfere
1722851.8485102550.5243.5Sfere
1722814.7475102522.7394.0Sfere
1722809.2415102501.7894.0Sfere

We need to convert it to KML in order to visualize the data in Google Earth. Google Earth makes use of the WGS84 coordinate system, so we are going to use the excellent OGR/GDAL command line software both for the coordinate conversion process (Gauss-Boaga –> WGS84) and the data format conversion (CSV –> KML).

It is a multi step process:

  • Write the supporting files
    • Create a CSV out of the spreadsheet
    • Create the data access VRT file
    • Create the  Gauss-Boaga rototranslation file
  • Converting the files
    • from CSV to SHP (still Gauss-Boaga)
    • from  SHP Gauss-Boaga to SHP WGS84
    • from SHP (WGS84) to KML

Let’s start: we need to prepare some support files to help us convert the data. First of all we need to export the data from the spreadsheet software to a Comma Separated Values (CSV) file. Which will look like this:

POSX,POSY,height,type
1722813.000,5102614.000,4.0,Lanterne
1722818.000,5102572.000,3.5,Lanterne
1722825.276,5102541.078,3.5,Sfere
1722838.000,5102546.000,3.5,Sfere
1722851.848,5102550.524,3.5,Sfere
1722814.747,5102522.739,4.0,Sfere
1722809.241,5102501.789,4.0,Sfere

OGR supports a virtual format which allows specification via an XML file. If you convert your worksheet into a CSV, you can generate a VRT file to instruct GDAL on how to access the data. I’ve created my VRT file like the following, and saved it on the disk as example.vrt:

<OGRVRTDataSource>
    <OGRVRTLayer name="example">
        <SrcDataSource>/home/simone/Desktop/test_data/example.csv</SrcDataSource>
        <GeometryType>wkbPoint</GeometryType>
        <LayerSRS>WGS84</LayerSRS>
        <GeometryField encoding="PointFromColumns" x="POSX" y="POSY"/>
    </OGRVRTLayer>
</OGRVRTDataSource>

This line in example.vrtis the important one:

<GeometryField encoding="PointFromColumns" x="POSX" y="POSY"/>

it tells GDAL which culumn is what. Which column is the east-west and north-south coordinate. We are now ready to generate a SHP, still in Gauss-Boaga coordinates.

ogr2ogr -f "ESRI Shapefile" example.shp example.vrt

Now we can convert example.shp to WGS84, using this PROJ file (gauss-boaga.prj):

PROJCS["Monte Mario / Italy zone 1",
GEOGCS["Monte Mario",DATUM["Monte_Mario",
SPHEROID["International 1924",6378388,297,AUTHORITY["EPSG","7022"]],
TOWGS84[-104.1,-49.1,-9.9,0.971,-2.917,0.714,-11.68],
AUTHORITY["EPSG","6265"]],
PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],
UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],
AUTHORITY["EPSG","4265"]],
UNIT["metre",1,AUTHORITY["EPSG","9001"]],
PROJECTION["Transverse_Mercator"],
PARAMETER["latitude_of_origin",0],
PARAMETER["central_meridian",9],
PARAMETER["scale_factor",0.9996],
PARAMETER["false_easting",1500000],
PARAMETER["false_northing",0],
AUTHORITY["EPSG","3003"],
AXIS["X",EAST],AXIS["Y",NORTH]
]

and by executing the following code:

ogr2ogr -s_srs gauss-boaga.prj -t_srs EPSG:4326 example_wgs84.shp example.shp

We are ready for the final step: convert the SHP file to KML:

ogr2ogr -f "KML" wgs84_GE.kml wgs84_example.shp

wgs84_GE.kml is our final output file.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

NOTICE: Contact & Twitter

If you need to contact me, you can use the contact form, I usually answer quickly.

Please be aware that I post on this blog only seldom. My main channel of posting updates, lately, has been twitter.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

mapping illegal horse tracks with OpenStreetMap

One of the most interesting things about OSM is the fact that it allows you to “map the reality”, map the ground-truth, not what the State-run maps tells you it’s there, but what is actually there.

Recently, on 10. January, an illegal horse racing, in a sort of clandestine racetrack was blocked by the military police in Pachino, Syracuse (Sicily, Italy). The blitz has, so far, allowed to identify more than 20 horse owners, jockeys and 3 veterinarians. The land placed in the open countryside, less than 2km from the sea, where the race was stopped, was a clandestine race-course, complete with boxes for the horses.

Just after discovering the news, I went hunting for that track on aerial images. We have been lucky enough to have been granted access to some 25cm resolution images, these images were made by the Regione Sicilia, after some more research I ended up discovering that the racetrack is located in Contrada Granelli, and not nearby the inhabited part of the Pachino town, so in the end, I was able to find it on the map, and tag it accordingly.

<way id=”49641876″>
<tag k=”clandestine” v=”yes”/>
<tag k=”leisure” v=”track”/>
<tag k=”name” v=”Granelli”/>
<tag k=”sport” v=”horse_racing”/>
</way>

Here is the result:

horse track: 36.707651, 15.022774

Surely this is not as important as what my friend Mikel is doing in Kibera, but still a declaration of indipendence from the canonical mapmakers.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

OpenStreetMap Haiti Statistics

For a poster I’m working on for the Geomatics for Crisis Management conference, I did run some simple stats on the Haiti Planet extracts. After the recent Earthquake, and after the donation of free/libre aerial imagery there has been an increase in user contributions.

These are the total number of users in the Haiti planet extract as of today (the 29th), and dating back to the 14th. For comparison purpose I’ve added the data for 30th dec 2009. It can clearly be seen that the biggest spike was on 16th, reason being on the 15th the first high quality images were made available for retracing. Then, same thing, same reason, on the 22nd.

first column: date of the extract
second: unique users contributing to the Haiti map
third: Megabytes of the uncompressed extract file (useful for gathering a rough idea of “detail”)

Date# usersSize (MB)
2009-12-303844
2010-01-147149
2010-01-159651
2010-01-1618360
2010-01-1724577
2010-01-1828693
2010-01-19300106
2010-01-20327117
2010-01-21365126
2010-01-22494188
2010-01-23515197
2010-01-24573211
2010-01-25585219
2010-01-26642229
2010-01-27649234
2010-01-28655238
2010-01-29663239
Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

geo search using Lucene + SOLR + OpenStreetMap

An interesting article on finding geo data (OpenStreetMap) using common-use search software as SOLR a java frontend to Lucene. Apache Lucene is a Java™-based, high performance search library. Apache Solr is a search server that uses Lucene to provide search, faceting, and many more capabilities over HTTP. Both are licensed under the commercial-friendly Apache Software License. Both Lucene and Solr also offer the ability to restrict the space being searched by applying one or more filters, which are key to spatial search. Range queries and range filters are among the essential mechanisms for restricting the space.

http://www.ibm.com/developerworks/opensource/library/j-spatial/index.html

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Old Map of Pavia

This is an historical map of my city, Pavia, Italy, scanned from out copyright source. The file is large enough to be printed on a 50 by 75 sheet of paper.
Historical map of Pavia

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

cubed art

Italian Spiderman from cubeecraft.com

To my non-artistic eyes this smart artist creates folding cubes that you need to donwload –> print –> cut –> fold with no need for glue. An amazing piece of art.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Japanese Addressing

Stolen from Steve’s OpenGeodata blog post:

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

digiKam 1.0 with OSM

Release 1.0 of digiKam the open source software for professionally managing pictures just came out. It will work under Linux and Windows and this coming release boasts several enhancements including support for geotagging images using OpenStreetMap carthography. All it takes is selecting some images from your library and locate them to the right spot on planet Earth using the Map Widget.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

cheap startup office

Rubato al napo, come arredare un nuovo ufficio in maniera accogliente e geeky.

http://dontrepreneur.com/2009/12/14/how-to-create-a-great-startup-office-space-while-being-abusrdly-cheap/

First let me tell you I furnished my entire office for about $4,500 complete with four workspaces, including chairs, desk lamps, wastebins and office supplies. A lounge area complete with futon couch, area rug and end table. Lamps, rugs and some strategically placed whiteboards. Throw in a microwave, printer, a wireless router, TV stand, 32 inch HD television and Xbox 360 entertainment system. Finally, I almost forgot a refrigerator, storage ottomans, extra chairs, three bookcases and some very nice standing lamps. All for $4,500—purchased and set up in 7 days.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)