Thursday, April 30, 2009

In my previous post I showed how easy it is to use GeoMedia and GeoMedia Professional 6.1.5.x to publish features into Google Earth's KML format. This works for point, line, and polygon geometries. However, you may have noticed that GeoMedia text label features in your legend are not published to KML. An example of text label features is shown in the screen shot below.

In this post, I describe a method to enable your text labels to be published to KML from GeoMedia. The method can be summarized in two points - (1) convert the text label feature to a GeoMedia point feature, and (2) expose the text label string as an attribute field in the point feature.

The steps below outline the details to publish the GeoMedia text labels into KML.

In the Functional attributename field, enter a meaningful attribute name for the field to store the label string, e.g. theLabel.

Now form the Expression to extract the text string. Double click Geometry under Categories. Under Functions, double click on GRAPHICSTEXTSTRING. Under Attributes, double click the text label feature's geometry field name, e.g Input.Offset.

The Expression GRAPHICSTEXTSTRING(Input.Offset) is formed.

Click Add. Click Close.

The Functional Attributes dialog box appears.

In the Query name field, enter a meaningful name e.g. PointStateNameLabels. Toggle off Display functional attributes in data window.

Click OK.

The PointStateNameLabels point feature is displayed in the map window.

Select File > Publish > Configure KML Publishing.

The Configure KML Publishing dialog box appears.

Under Legend Entries, choose PointStateNameLabels.

In the Get placemark names from drop down list, select the exposed attribute field that contains the text string labels e.g. theLabel.

Click OK.

Select File > Publish > Publish Map.

The Publish Map dialog box appears.

Specify the output KML file name and click OK.

The KML file is published with the text labels and displayed in Google Earth.

Wednesday, April 22, 2009

Besides commercial software like GeoMedia, Global Mapper, FME, ArcGis, etc. there are also free open source tools that can be used to convert SVY21 easting/northing coordinates to geographical latitudes/longitude coordinates. A great open source software is PostGIS and in this posting I will show how to use it without any programming or customization to convert SVY21 coordinates in CSV (comma separated values) files to geographical coordinates.

Note: Prior to doing the conversion, the SVY21 projection parameters must be added to the PostGIS spatial reference system table as shown in the previous posting here.

The source CSV file is shown in the screen shot below. The file has only three columns - a running number, the easting coordinate and the northing coordinate.

Select Edit | Clear Window. Enter the following SQL command to create a geometry field that is associated with the SVY21 coordinate system.

SELECT AddGeometryColumn

( 'public', 'svy21coords', 'the_geom', 93414, 'POINT', 2 );

Note: 93414 is the SRID of the SVY21 coordinate system in the spatial_ref_sys table.

Press F5 to execute the command.

The geometry field is appended to the table.

Select Edit | Clear Window. Enter the following SQL command.

SELECT 'UPDATE svy21coords SET the_geom=GeomFromText(''POINT('||easting||' '||northing||')'',93414) WHERE id='||id||';' FROM svy21coords;

Press F5 to execute the query.

The query results are displayed in the bottom pane of the Query window.

Select all the query results by clicking the first row and shift-clicking the last row. Press CTRL-C to copy the selected results to the Windows Clipboard.

Click the top pane. Select Edit | Clear Window. Select Edit | Paste.

The results are pasted into the top pane of the query window. Note the double quotation marks on every line. "UPDATE svy21coords SET the_geom=GeomFromText('POINT(39815 35200)',93414) WHERE id=1;"
"UPDATE svy21coords SET the_geom=GeomFromText('POINT(39800 35200)',93414) WHERE id=2;"
"UPDATE svy21coords SET the_geom=GeomFromText('POINT(43200 35900)',93414) WHERE id=3;"

Select Edit | Find and Replace.

The Find and Replace dialog box appears.

In the Find what field, enter ". Click Replace All. Close the Find and Replace dialog box.

All the double quote marks are removed.UPDATE svy21coords1 SET the_geom=GeomFromText('POINT(39815 35200)',93414) WHERE id=1;
UPDATE svy21coords1 SET the_geom=GeomFromText('POINT(39800 35200)',93414) WHERE id=2;
UPDATE svy21coords1 SET the_geom=GeomFromText('POINT(43200 35900)',93414) WHERE id=3;

Press F5 to execute the SQL command.

The geometry field the_geom is updated with the SVY21 point coordinates.

Select Edit | Clear Window. Enter the following SQL command to transform the SVY21 geometries to geographical latitude/longitude and write the records to a temporary table CSVOUTPUT.

CREATE TABLE CSVOUTPUT AS SELECT id,easting,northing, x(ST_Transform(the_geom,4326)),y(ST_Transform(the_geom,4326)) from svy21coords Note: 4326 is the SRID of the geographical lat/lng coordinate system.

Press F5.

The SVY21 points are transformed into latitude/longitude and written to the output table.

Tuesday, April 21, 2009

SVY21 projection does not come with the default installation of my PostGIS 1.3.5 running on PostgreSQL 8.3. If you have geometries with SVY21 easting and northing coordinates and you need to do coordinate transformation e.g. between SVY21 and latitude/longitude in PostGIS, then you have to insert the SVY21 projection parameters into the spatial_ref_sys table in your database. The parameters are a pain to type in. Fortunately, there is a website http://spatialreference.org where you can simply copy the SQL INSERT statement and execute it in the PgAdmin GUI or the PSQL command prompt.

Monday, April 20, 2009

FME can be used to reproject points from one coordinate system to another. In this example, I'm going to show how to convert easting/northing points in SVY21 coordinate system to geographical latitude/longitude points using the FME Workbench and FME's Reprojector and 2DPointAdder transformers. The following paragraphs describe the conversion steps from the source CSV (comma separated value) file to the destination CSV file. The source CSV file looks like the Excel screen shot shown below.

Run the FME Workbench and choose Comma Separated Value as shown below.

Click Next.

The Locate your source data page appears.

Click Browse.

The Select source Comma Separated Value files dialog box appears.

Browse and select the CSV file or enter the file name in the File name field. Click Open.

Friday, April 17, 2009

By default, FME does not include the SVY21 coordinate system definitions. If you plan to use FME to perform any coordinate reprojections, then you have to modify the LocalCoordSysDefs.fme or MyCoordSysDefs.fme and coordsys.db parameter files to include in the SVY21 definitions. Fortunately, this is very easy and it is simply a matter of putting in the correct values.

Using your favorite text editor, add in the following lines in the LocalCoordSysDefs.fme or MyCoordSysDefs.fme files. They can be found in the folder {FME install directory}\Reproject\.

# SVY21 Projection

#------------------------

COORDINATE_SYSTEM_DEF SVY21 \

DESC_NM "Singapore_Transverse_Mercator_WGS_1984" \

PROJ TM \

UNIT METER \

DT_NAME WGS84 \

PARM1 103.8333333333333333333333 \

SCL_RED 1.0 \

ORG_LAT 1.366666666666666666666667 \

X_OFF 28001.642 \

Y_OFF 38744.572 \

MAP_SCL 1.0

Then add in the following line to the coordsys.db file. This file can normally be found in the {FME install directory}.

SVY21|Singapore Transverse Mercator WGS84|Singapore|WGS84||TM|METER

After you have completed amending the parameter files, when you run the FME workbench or the FME Universal Translator to define the coordinate system, you would be able to see the SVY21 coordinate system in the dialog boxes (as shown below).

Monday, April 13, 2009

Continuing my exploration of using Global Mapper to convert SVY21 coordinates to geographic latitude and longitude coordinates, Global Mapper 10 has a batch convert function that does coordinate conversions of one or many input files. I tried it out on a sample comma separated values (CSV) file (a screenshot of it in Excel is shown below) and the function works well. It is easy to use without having to go through convoluted setup procedures and no programming is required; so end-users can definitely use something like this to do batch coordinate transformation.

Here's how to do the batch SVY21 coordinates to geographic latitude and longitude coordinates conversion (from CSV to CSV format).

In the File Names group, toggle on Use Source File Name. In the Append field, type in a file suffix name e.g. _conv.

In the Projection group box, click Change.

The Select Destination File Projection dialog box appears.

In the Projection drop down list, select Geographic (Latitude/Longitude). In the Datum drop down list, select WGS84. Click OK.

The Generic ASCII Text File Import Options dialog box appears.

In the Import Type group, toggle on Point Only. In the Coordinate Column Order group, enter 1 for Columns to Skip at Start of Line. In the Coordinate Delimiter group, toggle on Comma. Toggle on Column headers in first row of file.

The input file svy21coords.csv is converted from SVY21 to geographic latitude and longitude coordinates in the output file svy21coords_conv.cvs. A screenshot of the resultant file is shown below in Excel.

Thursday, April 9, 2009

There are a variety of ways to convert SVY21 coordinates to geographical latitude and longitude coordinates in Global Mapper. I have previously posted about using the Coordinate Convertor and the Batch Convert/Reproject functions. I describe another way in this post. Global Mapper allows you to change the map display's coordinate system to any desired coordinate system; then whatever points you have displayed in Global Mapper will be exported out in that coordinate system. That essentially sums up the approach in this conversion method here.

For example, I have a CSV file containing the SVY21 coordinates as shown in the screenshot below. I want to convert the easting and northing coordinates to geographic latitude and longitude values. The steps are outlined below.

Run Global Mapper 10.

Select Tools > Configure.

The Configuration dialog box appears.

Click Projection.

In the Projection drop down list, select Geographic (Latitude/Longitude). In the Datum drop down list, select WGS84.

The Configuration dialog box may look like this.

Click OK.

Select File > Open Generic ASCII Text File.

Browse and select a file e.g. svy21coords.csv. Click Open.

The Generic ASCII Text File Import Options dialog box appears.

In the Import Type group, toggle on Point Only (All Features are Points).

In the Coordinate Column Order group, enter 1 for the Columns to Skip at Start of Line.

Toggle on Include attributes from lines with coordinate data. Toggle on Column headers in first row of file (points only).

The Generic ASCII Text File Import Options may look like this at this point.

Click OK.

This message box appears.

Click OK.

The Select Projection dialog box appears.

In the Projection drop down list, choose Transverse Mercator. In the Datum drop down list, select WGS84.