add background imagery tile based on GPS coordinates

655
3
01-08-2013 02:25 PM
JasonTrook
New Contributor II
Hi ArcPad Users,
Currently I'm creating ArcPad projects displaying only vector data and then a user has to manually add the correct NAIP imagery tile
based upon their location.  This is necessary because my survey areas are too large to do a bulk check out of my background
imagery (get low memory warnings on GPS device).  Has anyone written a script that, upon the click of a button, will add the correct background NAIP tile based on the GPS coordinates?  I'm thinking it could add the .tiff image from my SD card and remove all other
.tifs, if needed.  I have an index/fishnet that matches the .tif name so if GPS coordinates intersect feature 14 in the index then add
14.tif from SD card.  Just looking for a script I could modify or advice how to set this up. Thanks in advance for any help.
Jason
Tags (3)
0 Kudos
3 Replies
GarethWalters
Occasional Contributor III
Hi Jason,Great question, I have often wished for a simple raster catalog for ArcPad. You can definately do what you want to achieve.  I would suggest that you use the isPointIn. Take your gps reading check that it inside a polygon, then use the addlayerfromfile.Excuse me for putting some pseudo code but I am trying out the internet explorer on my xbox, so I am not fully equipped.vbScript:dim objCatalogset objCatalog = Map.Layers("polygonLayer")dim objPointset objPoint = Application.CreateAppObject("point")objPoint.X = GPS.XobjPoint.Y = GPS.Ydim objPolyNumif objCatalog.IsPointIn(objPoint) then objPolyNum = objCatalog.Records.Fields("name").value Map.AddLayerFromFile("c:temp" & objPolynum & ".tif")end ifWell, it will be something like that. I think I have the isPointIn correct.Let me know how you go. I this is a good start.Cheers,Gareth
0 Kudos
JasonTrook
New Contributor II
Hi Gareth,
Thank you for for your advice.  I tried your code (as well as lots of modifications to try and and get it to run) but I am still getting
the error: Object doesn't support this property or method: 'objCatalog.IsPointIn', Source Text Unavailable
Any ideas?
Thanks,
Jason

Sub AddImagery
Dim objCatalog
Set objCatalog = Map.Layers("nv_24kquads_TEST")
Dim objPoint
Set objPoint = Application.CreateAppObject("point")
objPoint.X = GPS.X
objPoint.Y = GPS.Y
Dim objPolyNum
If objCatalog.IsPointIn(objPoint) Then 
objPolyNum = objCatalog.Records.Fields("QUAD_NAME").value 
Map.AddLayerFromFile("C:\Data\ArcPad\NV_FieldForms\Databases" & objPolynum & ".tif")
End If
End Sub
0 Kudos
GarethWalters
Occasional Contributor III
Hi Jason,

Sorry for the delay. I see in your code that you actually need a couple of extra steps. The IsPointIn method works on a polygon layer but you need to have a polygon feature selected to run the test, otherwise you need to loop through and test the rule against every polygon.

In this instance I may have give you a bum steer as you are really need to use the GPS to find what is around you. In that case I would suggest you try the FindNearestXY method

//var objPoint = Map.Layers("Poles");
//var objPointRS = objPoint.Records;
//objPointRS.BookMark = Map.SelectionBookMark;


var objX = GPS.X; //objPointRS.Fields.Shape.X; 
var objY = GPS.Y; //objPointRS.Fields.Shape.Y;


var objPoly= Map.Layers("Parcel");
var objPolyRS = objPoly.Records;
var objPolyBookMark = objPolyRS.FindNearestXY(objX,objY,0)


if (objPolyBookMark != 0)
{
  //AddLayerFromFile routine
}


This way you will start at the GPS Position and find a polygon that is closest to it.

I hope this helps. Let me know how you get on.

Cheers,

Gareth

P.S. Here is cbScript version for you.

'Dim objPoint
'Set objPoint = Map.Layers("Poles")
'Dim objPointRS 
'Set objPointRS = objPoint.Records
'objPointRS.BookMark = Map.SelectionBookMark


Dim objX
objX = GPS.X 'objPointRS.Fields.Shape.X
Dim objY
objY = GPS.Y 'objPointRS.Fields.Shape.Y


Dim objPoly
Set objPoly = Map.Layers("Parcel")
Dim objPolyRS
Set objPolyRS = objPoly.Records
Dim objPolyBookMark
objPolyBookMark = objPolyRS.FindNearestXY(objX,objY,0)


if objPolyBookMark <> 0 then
  Console.print objPolyBookMark
  'AddLayerFromFile routine
end if
0 Kudos