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 4716 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,xCentr oid1)]
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 latitude, longitude pair and I would like to determine
the closest zipcode. I can do this using point_distance, but I wonder
if there is a faster way. If I can extract the separate x, y values
from a point, then I can define my own distance metric...
|
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 offset point
outputs:
1) x,y coordinate of destination
thanks
|
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 geometric data types work well for
this type of data? Or just convert them to decimals?
Are there any functions for converting lat/long
to/from decimals/DDMMSS NSEW?
|
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 every half mile). Then, I click a submit button, and
it gives me latitude and longitude points (in order) from the beginning
of my trip to the end of my trip in 1/2 mile increments.
| |
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 coordinates are in the form of geographic
coordinates (latitude, longitude). Can this be achieved ? How ? Please
help.
Regards
|
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 an array of points on a basic 2 dimensional axis. They
are all points of a sine shaped line. (not a perfect sine though, as
it's actually tide movement data that is roughly looking as a sine).
|
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 the database done right now I am trying to query the database and I have no idea how to do it I wanted to find the value between the Latitude top, latitude bottom and longtitude top and longtitude bottom if it is between it will return the...
|
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: 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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |