473,486 Members | 1,640 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How can I determine the closest point to a given latitude or longitude?

If I have an arc shapefile (polygons) that has centroid coordinates as fields, what type of python code can I use to determine which point is closest to a given latitude or longitude?

Should I export the centroid coordinates and county names and use an if/while statement? Or, can I actually make the calculation and analysis using the "import arcgisscripting" route?

Im having trouble figuring out how to test each location (aka row) versus a given longitude or latitude.
Nov 6 '10 #1
3 4708
dwblas
626 Recognized Expert Contributor
I'm not quite sure what you want to do from the question, but the automatic response is, can't you use trigonometry in some way?
Nov 7 '10 #2
bvdet
2,851 Recognized Expert Moderator Specialist
ArcGIS is a large program with many capabilities. Unfortunately, I know nothing about it. If I had a list(1) of latitude/longitude points, and I wanted to determine the closest point from a given latitude/longitude point, I would create a function to calculate the distance between two given points, iterate on the list and accumulate the calculated distances in another list(2). The list(2) index of the smallest distance would match the list(1) index of the closest point. The formula to make the distance calculation can be found here.
Nov 7 '10 #3
im trying to figure out how to run a while statement in the arc script that tests each row according to its x coordinate versus a given longitude. the hard part is translating a function, like the one below, into arc script:
Expand|Select|Wrap|Line Numbers
  1. x = (214, 521)
  2. q = [(200, 500),(250, 550),(300, 600)]
  3. t = []
  4. for item in q:    #print item
  5.     b = abs(item[1]-x[1])
  6.     t.append((avg, item))
  7.     print min(item)
  8.     print min(t)[1]
  9.     break
X would equal the given longitude
q would represent the list of attributes/values in the shapefile (e.g. [(County0, xCentroid0), (County1,xCentroid1)]
Nov 7 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1499
by: Jerry Asher | last post by:
I have a table of points, actually zip codes and their points. If a point is an X, Y pair, how do I extract X from a point? (And how do I create or insert a new point (X, Y)?) I am given a...
3
4664
by: some one | last post by:
Does anyone know the algorithm or a function out there that will compute the offset location given the following: inputs: 1) x,y coordinate of starting point 2) angle (bearing) 3) distance to...
9
3423
by: Sandy | last post by:
Hello - I need either a cheap tool or code & DB that calculates, eg. within 50-mile radius of a zip code. Anyone have any suggestions? -- Sandy
5
8089
by: CSN | last post by:
I looked through the docs and contrib, but didn't see anything related to storing and using latitude and longitude values. I have data in the form of 12° 34' N, 12° 34' W. Would any of the...
2
2509
by: kbperry | last post by:
I am not sure if this is the right place for this, but I thought it was worth a shot. What I want: Enter a From: street address and a To: street address, and then specify an interval (say...
6
3730
by: helpneeded | last post by:
Hi I am a novice using the <maptag. I have a question. I would really appreciate if you could answer me. I want to use the <maptag to dynamically update my map with coordinates. These...
5
8799
by: MathNewbie | last post by:
Hi, I'm trying to do get my head around some, probably basic, math calculations. I checked some .net math libs, but the only thing I learn from studying those is humility ;-). Anyway, i have...
1
3038
by: GC2006 | last post by:
i need to write a C++ program that determines if a given string is a palindrome. i just started C++ and im totaly lost now can anyone help me plzzzz????
45
2969
by: Rocky86 | last post by:
Hi brothers I am new here need help with the php programing using sql basically I am given a task to create a php code that is able to query the database on some free hosting web which I alreadx have...
5
10042
by: arial | last post by:
Hi all, I have a sql .bak file which i need to convert into xml file. can someone help with this? pointing out to some tutorial or some suggetion on how to start? Thak you,
0
7094
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6964
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7173
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5427
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4863
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3066
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1378
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
598
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.