Proceed to GeoCommunity Home Page


SpatialNewsGIS Data DepotGeoImaging ChannelGIS and MappingSoftwareGIS JobsGeoBids-RFPsGeoCommunity MarketplaceGIS Event Listings
HomeLoginAccountsAboutContactAdvertiseSearchFAQsForumsCartFree Newsletter

Sponsored by:


TOPICS
Today's News

Submit News

Feature Articles

Product Reviews

Education

News Affiliates

Discussions

Newsletters

Email Lists

Polls

Editor's Corner


SpatialNews Daily Newswire!
Subscribe now!

Latest Industry Headlines
SiteVision GIS Partnership With City of Roanoke VA Goes Live
Garmin® Introduces Delta™ Upland Remote Trainer with Beeper
Caliper Offers Updated Chile Data for Use with Maptitude 2013
Southampton’s Go! Rhinos Trail Mapped by Ordnance Survey
New Approach to Measuring Coral Growth Offers Valuable Tool for Reef Managers
Topo ly - Tailor-Fit for Companies' Online Mapping Needs

Latest GeoBids-RFPs
Nautical Charts*Poland
Software & Telemetry GPS
Spatial Data Management-DC
Geospatial and Mapping-DC
Next-Gen 911-MO

Recent Job Opportunities
Planner/GIS Specialist
Team Leader- Grape Supply Systems
Geospatial Developer

Recent Discussions
Raster images
cartographic symbology
Telephone Exchange areas in Europe
Problem showcasing Vector map on Windows CE device
Base map

GeoCommunity Mailing List
 
Mailing List Archives

Subject: [gislist] donuts - solution
Date:  12/11/2003 03:00:01 PM
From:  Till Bergmann



Hi List,

I don't know if I've got all answers yet. So I will sum up tomorrow.

As nobody provided what I was really searching for, I decided to solve the
problem by myself. You see, the Shapefile was a little more complex. So
most of the "do-it-by-hand"-solutions weren't really suitable for my
problem.
Here's a little quick 'n' dirty code that solved the problem. Careful with
multipart polygons where the single parts lie apart from another. The
script takes only the largest parts into the new shape. It's just ment for
donut polygons.

Have fun,
Till


theView = av.GetActiveDoc
holeTheme = theView.GetActiveThemes.Get(0)
holeFTab = holeTheme.GetFTab
holeFldShp = holeFTab.FindField("Shape")
holeFldId = holeFTab.FindField("id") ' insert name of the field with
numeric id-values you want to transfer

outFTab = FTab.MakeNew(("/<path>/<name>.shp").AsFileName,Polygon) ' insert
desired path and filename
outFTab.SetEditable(True)
outFldShp = outFTab.FindField("Shape")
outFldVp = Field.Make("id",#FIELD_DECIMAL,7,0)
outFTab.AddFields({outFldVp})

cnt = holeFTab.GetNumRecords
ctr = 0

for each k in holeFTab
oVp = holeFTab.ReturnValue(holeFldId,k)
oShp = holeFTab.ReturnValue(holeFldShp,k)
rec = outFTab.AddRecord
outFTab.SetValue(outFldVp,rec,oVp)
if (oShp.CountParts = 1) then
outFTab.SetValue(outFldShp,rec,oShp)
else
aLst = oShp.AsList
areaLst = {}
for each i in 0..(aLst.Count -1)
areaLst.Add(polygon.Make({aLst.Get(i)}).ReturnArea)
end
areaLst.Sort(False)
maxarea = areaLst.Get(0)
for each i in 0..(aLst.Count -1)
if (polygon.Make({aLst.Get(i)}).ReturnArea = maxarea) then
outFTab.SetValue(outFldShp,rec,polygon.Make({aLst.Get(i)}))
end
end
end
ctr = ctr + 1
av.ShowStopButton
av.SetStatus((100/cnt)*ctr)
av.ShowMsg("Removing holes...")
end
av.ClearMsg
av.ClearStatus
outFTab.SetEditable(False)
outTheme = FTheme.Make(outFTab)
theView.AddTheme(outTheme)
outTheme.SetVisible(True)



_______________________________________________
gislist mailing list
gislist@lists.geocomm.com
http://lists.geocomm.com/mailman/listinfo/gislist

_________________________________
This list is brought to you by
The GeoCommunity
http://www.geocomm.com/

Get Access to the latest GIS & Geospatial Industry RFPs and bids
http://www.geobids.com

Sponsored by:

For information
regarding
advertising rates
Click Here!

Copyright© 1995-2012 MindSites Group / Privacy Policy

GeoCommunity™, Wireless Developer Network™, GIS Data Depot®, and Spatial News™
including all logos and other service marks
are registered trademarks and trade communities of
MindSites Group