Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 1 Use a feature class of your own and write a Python program ( using arcpy ) to print out the following information for
Question
Use a feature class of your own and write a Python program using arcpy to print out the following information for all the fields: name,
type, length, and, if the field is float Single or Double scale and precision. Hint: we used the name of each field in the tutorial already.
You must use
for this exercise. There are more properties in the field, and you can use the help function, such
as helpfields to see how to use them, or you can see more information about field here Submit your code in py and include the
result of the printout as comments.
Question
In QGIS, if we load the same shapefile twice, the two layers will share exactly the same name in the Layers panel. Write a Python
program to first test if there are duplicated layer names in the panel. If there are duplicated layer names, the program should post a log
message something like "There are duplicated layer names and I will fix this!" and then systematically change the duplicated names so
they are unique. One simple way to do this is to add a number to the end of an existing name. For example, if we have two appearances
of
we will change them to
and publiclibraryshp But you can come up with your own ways to
address this issue. There might be multiple cases of duplicated names and the program should be able to change their names accordingly.
For example, if we have two layers called
and three layers called
we should change them
to
publiclibraryshp countyboundary
and
countyboundary respectively. After you are
done, push a message like "I am done!" to the message bar. Make sure the message bar lasts for seconds.
Submit your code in a py file and then a screenshot of QGIS showing the result of running your program with the log message. The
following shows how the code works. If we have layers listed like something on the left, our code should change it to something like the
one on the right.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started