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.
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?
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.
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: -
x = (214, 521)
-
q = [(200, 500),(250, 550),(300, 600)]
-
t = []
-
for item in q: #print item
-
b = abs(item[1]-x[1])
-
t.append((avg, item))
-
print min(item)
-
print min(t)[1]
-
break
X would equal the given longitude
q would represent the list of attributes/values in the shapefile (e.g. [(County0, xCentroid0), (County1,xCentroid1)]
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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...
|
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
|
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...
|
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...
| |
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...
|
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...
|
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????
|
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...
|
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,
|
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,...
| |
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...
|
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...
|
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,...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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 ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |