Search This Blog

Thursday, September 8, 2011

Raster access speeds… and size limits

 

I need to be able to handle large raster images, and to be able to find values from cells very quickly.

There are many ways to do this…. here’s a look at a few:

Method Handles GeoCoords Max Size Read Access Speed
DOTSPATIAL
Raster
Yes Medium (9k x 9k) 2.6 million per second
C# dictionary No Small (5k x 5k) 50 million per second
EMGU IMGs No Large (30k x 30k) 3.2 million per second
C# BMP (.net) No Medium (9k x 9k) 1 million per second
C# FastBMP No Medium (9k x 9k) 33 million per second
Rasterlite Yes Large (internal tiling) (to do)
GDAL Yes Large (to do)
R (grids) (to do) (to do) (to do)
XNA texture No Small   (4k x 4k) (to do)

Tuesday, September 6, 2011

DotSpatial

So I’m checking out DotSpatial for use in a project.. and the first thing on my list is to check it can convert coordinate systems easily from WGS84 <> OSGB36.

Seems the current version’s inbuilt definition of OSGB36 isn’t correct.. and when using it with the Reproject method gives out some strange results. It’s also listed as failing the unit test currently.

However you can specify the details yourself.. and then it seems to work just fine… so here’s the code for taking a coordinate as OSGB36 and transforming it to WGS84…

PointD pd = new PointD();
pd.X = 326097.07;
pd.Y = 673630.932;

double [] pts_xy = new double[2];
pts_xy[0] = pd.X;
pts_xy[1] = pd.Y;

double [] pts_z = new double[1];
pts_z[0] = 0;

var pStart = new ProjectionInfo("+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +towgs84=446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894 +units=m +no_defs");
var pEnd = KnownCoordinateSystems.Geographic.World.WGS1984;
 
Reproject.ReprojectPoints(pts_xy, pts_z, pStart, pEnd, 0, 1);
System.Console.WriteLine(pts_xy[0] + " " + pts_xy[1]);

Thursday, August 18, 2011

WGS84 to OSGB36

A transformation between WGS84 and OSBB36 requires a datum transformation. A 7 parameter transformation should give results accurate to about +/- 5m…

ArcGIS supports a number of 3 para, and 7 para transforms. CS2CS using Proj may also be used as follows :

cs2cs +proj=latlong +ellps=WGS84 +towgs84=0,0,0 +nodefs +to +proj=tmerc
+lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy
+towgs84=446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894 +units=m
+no_defs

(thanks to Paul from http://osgeo-org.1803224.n2.nabble.com/OSGB36-td2062542.html for settings)

However for a centimetre accurate transformation an NTv2 grid is required. The OS provide an online coordinate transformation service here (a site for bulk conversions is also available)

http://gps.ordnancesurvey.co.uk/etrs89geo_natgrid.asp

It’s also possible to download the grid in NTv2 format from here:

http://www.ordnancesurvey.co.uk/oswebsite/gps/osnetfreeservices/furtherinfo/ostn02_ntv2.html

or directly from this link http://www.ordnancesurvey.co.uk/oswebsite/gps/docs/OSTN02_NTv2_DataFiles.zip

Test for a point in Edinburgh (Scotland)

WGS84 –3.185, 55.95
OS Online NTv2 Conversion > 326097.07,673630.932 [taken to be correct conversion]
ESRI (3 par option_1) > 326097.86,673625.357
ESRI (3 par option_5) > 326095.042,673619.452
ESRI(petroleum option)> 326096.974,673630.405
CS2CS (not using NTv2)> 326096.98,673630.4

So it would appear that ESRI’s petroleum option and CS2CS (as above without NTv2) and the OS Online conversion tool all agree to within 1 metre, while the 3 parameter version are out by at least 5m. The options relate to which parts of the country the re-projection has been set up for… this test would suggest option_1 works better for Scotland.

Friday, August 12, 2011

SpaceBook Project

So we’ve arrived in Edinburgh and I’ve started working with the SB team… William’s away and kindly allowing me to use his office for the moment.

Useful Data sources (thanks to Guy):

MasterMap – building outlines from OS (downloaded thru EDINA)
LiDAR and 3D building (from DSM-DTM) polygons from http://landmap.ac.uk/

edin 3d from landmap

(The 3D buildings from Landmap SHP source)

 



GRASS – new viewshed function (ie not r.los)

r.viewshed (addon) – using faster algo (sweep method)

Install method for Windows summary – download GRASS source (all).. add r.viewshed source folders… change the MAKEFILE to incl r.viewshed – compile GRASS as per this page:


http://trac.osgeo.org/grass/wiki/CompileOnWindows

Using msys

/mswindows/osgeo4w/package.sh
the package error log goes into this folder:
\\OSGeo4W\usr\src\grass641\mswindows\osgeo4w as package.log

Thursday, June 23, 2011

Manually signing an Android App

1) Open CMD and then go to c:\Program Files\Java\jdk1.6.0_25\bin

2) Setting up the keystore
keytool -genkey -v -keystore c:\android\mks -alias myapp123 -keyalg RSA –keysize 2048 -validity 10000
enter a password (and again)
enter your name details (optional)
enter y to keep and progress…
re-renter your password

3) Export unsigned APK from Eclipse then sign it…
Export by Right Click > Android Tools
jarsigner -verbose -keystore c:\android\mks d:\myapp.apk myapp123

4) check it’s signed OK by using jarsigner verify
jarsigner –verify –verbose d:\myapp.apk

5) Zip align your code…
Go to Andriod-sdk-windows-tools

(It always uses an int value of 4 for byte ordering - this isn't API level etc)

zipalign -v 4 your_project_name-unaligned.apk   your_project_name.apk

eg zipalign -v 4 d:\GeoSensorLogger.apk  d:\GeoSensorLogger_signed.apk

Put the apk file on your phone.. or marketplace…

Tuesday, May 24, 2011

Tuesday, May 17, 2011

Eclipse IDE tips for Android Development

Perspectives (top right of screen)


JAVA
DEBUG
DDMS – device info, processes, fake GPS (GPX,KML etc), fake tel info

         - file explorer, memory allocation, threads,
            logcat (logging output)

 

_______________________

Window> Andriod SDK AVD manager – setup emulators

_______________________

CTRL+SHIFT+T = open type (eg MyClass)
CTRL + SHIFT + R = open resource (eg main.xml)
CTRL+O – overview of methods in class.. can search with wildcards * too

SHIFT+ALT+R – rename a type and all xrefs to it
CTRL+SHIFT+O = organise the imports (eg add / remove android.os.Bundle)

Also if you add:

Button b;

then hit CTRL+SHIFT+O it’ll add import android.widget.Button;

Setting up Android Development tools on Windows

Ok so here’s the quick how to:

1) Download and install Eclipse from here

http://www.eclipse.org/downloads/

Choose the Eclipse IDE for Java Developers 32 bit version
(64 bit version has issues with Android plugins at time of writing)

Just download.. unzip and put into a new folder on your PC.. say Program Files..

 

2) Download and install the Java JDK from here:

http://www.oracle.com/technetwork/java/javase/downloads/index.html

(again 32 bit option - x86)

Go with default install location is fine here..

 

3) Install the Android SDK from here:

http://developer.android.com/sdk/index.html

Choose the Windows Installer version as it is a lot easier in this case, as it pulls down various plug in options later in the steps.

If you get an error saying the JDK couldn’t be found then press the BACK button on the install dialogue box.. then push NEXT again.. this time it finds it.. weird install bug.

Change the install path!!! Take out the spaces otherwise you’ll get problems later on.. so make it start with c:\android\

Accept all the options and wait for download/install…

4) Next we need to configure the Eclipse ADT plug in…

Load Eclipse then go to the Help menu.. Choose Install new software

In the Work With box enter>>

https://dl-ssl.google.com/android/eclipse

Give it the Name:   Android
Click OK and wait…

(If you have problems check this link which has details on a ZIP download alternative >> http://developer.android.com/sdk/eclipse-adt.html  )

Select all, accept licences.. set it going an wait for it to complete.

Restart Eclipse…

Now go to Window > Preference
Choose Andriod > Specify your Android install location (eg C:\Android\AndroidSDK…)