Assignment 9: Polygon Geometry

Verified

Added on  2019/09/16

|3
|1007
|331
Practical Assignment
AI Summary
This assignment focuses on converting points into multipart polygons using ArcGIS and Python scripting within Visual Studio. Students are tasked with creating a form to interact with ArcGIS layers, specifically a GPS point layer and a polygon layer. The assignment requires processing point data to construct polygon features, handling both land and water polygons to create inner and outer rings for multipart polygons. The code should dynamically handle an unknown number of polygons. Finally, the assignment involves calculating the area of each polygon, storing the results in the polygon layer's attribute table, and displaying the areas in a listbox within the application. The completed assignment includes a screen capture of the results and the zipped project folder.
Document Page
GIS Programming and Customization
GIS 6103 - Fall 2016
School of Forest Resources and
Conservation
Geomatics Program
________________________________________________________________________________________________________
Assignment 9: Polygon Geometry
due: Nov 18, 11:45am
Task:
To convert points into multipart polygons.
Preparation:
Unzip the attached file, open the attached mxd file and add the two shapefiles to the project.
In VisualStudio create a form that contains a list box, two comboxes, two labels, and two buttons (see figure
below).
GPS point shapefile:
The GPS point shapefile contains points collected on boundaries of street blocks (labeled “L…” in the
Polygon field, with “L” standing for “Land”). For some of these street blocks, points were also taken
alongside a lake (labeled “W…” in the Polygon field, standing for “Water”) inside the street block. To
facilitate construction of multipart polygons and correct computation of areas, the sequence of land polygon
GPS points is in clockwise direction, whereas for lakes it is in counterclockwise direction. If a street block
has a lake inside, the two groups of points share the same number in the Polygon field, such as “L2” and
“W2”. The polygon for such a street block needs to consist of two rings, one outer and one inner ring.
Functionality:
Once the form is opened by the user the code should loop through the table of content (TOC) and search
for a GPS point layer (“GPS”) and for the polygon layer (“LandPolygons”) using string matching. Once found
the names of both layers should be added to upper and lower combobox, respectively. The code should be
flexible to access these two layers independent of their location in the TOC.
Once the user clicks the “Compute Polygon” button the code should perform the following:
1) Remove all polygon features from that LandPolygons layer.
2) Your code constructs a ring feature for land based GPS points that share the same “Polygon” value.
If a lake is present, it creates also a ring feature.
3) Create a polygon from each individual ring or ring pair, respectively. The polygon consists of only
one ring if the land polygon has no lake, but it consists of two rings if a water polygon is associated
with a land polygon.
4) Each polygon should then be added to the LandPolygons layer.
5) For each polygon, access its area and report it back in the list box. By default, ArcGIS will only count
the area between the outer and inner ring for multipart polygons, i.e. the “true” land area after
subtraction of the area of the hole (the lake in this case).
6) For each polygon, the street block name (L1, L2, etc.) as well as the computed area should also be
written in the corresponding fields in the LandPolygons layer.
The second button is to close the form.
1
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
GIS Programming and Customization
GIS 6103 - Fall 2016
School of Forest Resources and
Conservation
Geomatics Program
________________________________________________________________________________________________________
The result, after clicking the “Compute polygon” button, should look similar to this:
2
Document Page
GIS Programming and Customization
GIS 6103 - Fall 2016
School of Forest Resources and
Conservation
Geomatics Program
________________________________________________________________________________________________________
Some suggestions for directions:
1) Review the example on p.273 of the course book. It shows how to construct rings from points using
the IPointCollection interface, and how to construct polygons from rings using the
IGeometryCollection interface. Use a similar approach.
2) Your code needs to automatically detect how many land and water polygons are mapped in the GPS
point file, based on different values found in the Polygon field. The code should be flexible and run
for any number of land and water polygons. Use a “land” dictionary and “water” dictionary which you
initialize and populate by parsing through the GPS point feature class. Each unique Polygon id can,
for example, be represented through a unique Key in the corresponding dictionary.
3) In the next step loop through all keys in the “land” dictionary, and for each key use a search cursor
to extract the relevant GPS points (in combination with some filter), based on which you can build
the outer ring of the land related points. Then you need to check whether the “water” dictionary
contains a polygon with that same number (e.g. “W2” for “L2”), using a comparison of keys. If this is
the case, create an inner ring from the water GPS points, and add it to the polygon.
4) To make sure a ring is closed before adding it to a polygon use the Close method.
5) To compute the area of a polygon, use the IArea interface (see ArcObjects developer helpfile). You
need to query interface from the IGeometryCollection interface (which should be used to build a
polygon) to the IArea interface to use its properties (i.e. Area in this case).
6) You can use an insert cursor to add the new polygon feature to the LandPolygons layer, or, even
easier, apply the CreateFeature method combined with Store.
7) To remove all features from the polygon feature class before each run, you can use the
DeleteSearchedRows Method on the ITable interface. See the GeoDatabase OMD.
Run the add-in, open the updated LandPolygons table, provide a screen capture, and insert it
< HERE >
Hand in:
1) This MS Word document with your completed screen captures.
2) A zipped project folder with the final version of your project.
Good luck!
3
chevron_up_icon
1 out of 3
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]