Maptitude - http://research.umbc.edu/~roswell/maptitude.html
Thanks a lot! I'll try it out tomorrow - very nice of your to pass that
along. Again, thanks!
Richard Hoskins
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
GMT -8
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Saturday, February 10, 2001 4:50 PM
To: Maptitude
Subject: Re: [Maptitude] redraw dbox-->utility dbox
Maptitude - http://research.umbc.edu/~roswell/maptitude.html
Richard.
I am attaching a macro that might help you do what you need to do. It is
not
inteded to deal with thousands of polygons, but it can be adapted to that
task
with some modifications.
Cheers
Armando Scalise
----------------------------------------------------------------
// this macro works on polygon layers finding all the polygons that are
adjacent to a selected one (the base polygon)
// It creates a text file (c:\\temp\\centroid_distances.txt) with the name
of
the selection set where the neighbor polygons are
// and a list of ID og neighobors and their distance to the base polygon.
// For this macro to run you will have to:
// 1 - Create a folder in disk c: called \temp
// 2 - Create a Selection Set called "Base Polygon" in the polygon layer
(case sensitive)
// 3 - Select the base polygon in the "Base Polygo" selection set
Macro "adjacent_polygons"
// get actual units
units = GetMapUnits("Plural")
// Get layer name, if null return error
v=Getview()
if v=null then do
ShowMessage("Select a layer")
return()
end
// Parameters for buffer creation
dir_path="c:\\temp\\" // a temp folder must exist
in
the C drive.
buffer_file="Adj_Buffer2" // this is the name of
the
.dbd file to be created
buffer_name="new_buffer" // this is the name of
the
buffer layer
set="Base Polygon" // The polygon should be
included in a selection set called "Base Polygon"
a_buffer_size = {1}
method="Value"
// only one element in the Base Polygon selection set is
allowed
if GetSetCount(set)>1 or GetSetCount(set)=0then do
ShowMessage("Error: None or more than one base
polygons
found.")
Return()
end
id1=GetFirstRecord(v+"|"+set,)
c1=GetCentroid(rh2id(id1))
// elimina buffer temporal si existe
layers=GetLayers()
for i=1 to layers[1].length do
if layers[1][i]=buffer_file then DropLayer(GetMap(),
layers[1][i])
end
//SetMapUnits to meters
SetMapUnits("Meters")
//Create the buffer
CreateBuffers(dir_path+buffer_file+".dbd", buffer_name,
{set}, method, {10} ,
{{"method",method},{"units","Meters"}, {"Database
Label",buffer_name}})
//laod te temporary buffer file
actual_lyr_name = AddLayer(GetMap(), buffer_file,
dir_path+buffer_file+".dbd", buffer_name)
// Select all polygons intereseted by the buffer
r=RunMacro ("Sele_por_buffer",
v,actual_lyr_name,&new_set)
RedrawMap()
// set the original measurement units back
SetMapUnits(units)
// Get the centroids for all polygons in the selection
set
adn compute the distance to the base polygon
rh=GetFirstRecord(v+"|"+new_set,)
// Save the distances in file
c:\\temp\\centroid_distances.txt
f=OpenFile(dir_path+"centroid_distances.txt","w")
WriteLine(f,"Distances from polygon ID "+id1+ " to
neighbors (Selection set "+new_set+")")
while rh<>null do
centroid=GetCentroid(rh2id(rh))
distance=GetDistance(centroid,c1)
WriteLine(f,r2s(rh2id(rh))+","+r2s(distance))
rh=GetNextRecord(v+"|"+new_set,,)
end
CloseFIle(f)
LaunchProgram("Notepad c:\\temp\\centroid_distances.txt")
endMacro
// adjacent polygosn selection
//----------------------------------------------
Macro "Sele_por_buffer" (source_layer,buffer_layer,new_set)
m=GetMap()
if m=null then do
showmessage("Por favor, active un mapa antes de continuar")
Return()
end
else do
l=GetMapLayers(m,"Area") //toma los nombres de los layers de
areas
if ArrayPosition(l[1], {source_layer} ,)=0 or
ArrayPosition(l[1], {buffer_layer} ,)=0 then do
Showmessage ("Uno o ambos layers pedidos no se encuentra en
el mapa")
Return()
end
end
// creates a selection set in the buffer
SetLayer(buffer_layer)
buff_set=CreateSet("Base Polygon")
SelectByQuery(buff_set, "Several", "Select * where ID > 0",)
SetLayer(source_layer)
new_set=CreateSet("Adjacent Polygons")
SetFillColor(new_set, ColorRGB(32000, 0, 0))
SetDisplayStatus(new_set, "Active")
operation="Several"
// set selections set
SetDisplayStatus(new_set, "Active")
SetFillStyle(new_set, solid)
SetSelectInclusion("Intersecting")
n_selected = SelectByVicinity ( new_set, "several",
buffer_layer+"|"+buff_set, 0)
endmacro
Health Maps wrote:
> Maptitude - http://research.umbc.edu/~roswell/maptitude.html
>
> Yes I think this will work fine, but I have 1500 polygons for which I need
> all the adjacent polygons.
>
> Richard Hoskins
> [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
> GMT -8
>
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Friday, February 09, 2001 4:49 PM
> To: Maptitude
> Subject: Re: [Maptitude] redraw dbox-->utility dbox
>
> Maptitude - http://research.umbc.edu/~roswell/maptitude.html
>
> Richard.
>
> > Maptitude - http://research.umbc.edu/~roswell/maptitude.html
> >
> > 1.
> > I want a utility that will tell me what the adjacent polygons are for a
> > polygon. For example, for Zip Code 98105, what are the Zips that share a
> > boundary. And if it would be nice to know the distance between centroids
> and
> > the lengths of the shared boundaries (and a few dozen other things ...)
> >
>
> To select adjacent polygons
>
> 1) select your base polygon
> 2) Create a small buffer around it (a buffer of 1 foot, or 1 meter
> should do)
> 3) Use "Select by Location" (Choose the buffer layer as the layer in
> "Select
> features base in.." and choose "Select all features" )
>
> I might be able to modify an old macro I have to do that.
>
> Good Luck
>
> Armando Scalise
>
> ______________________________________________________________________
> To unsubscribe, write to [EMAIL PROTECTED]
>
> ______________________________________________________________________
> To unsubscribe, write to [EMAIL PROTECTED]
______________________________________________________________________
To unsubscribe, write to [EMAIL PROTECTED]
______________________________________________________________________
To unsubscribe, write to [EMAIL PROTECTED]