Download Introduction to GIS Programming and Fundamentals with Python and ArcGIS 1st Edition Chaowei Yang ebook All Chapters PDF
Download Introduction to GIS Programming and Fundamentals with Python and ArcGIS 1st Edition Chaowei Yang ebook All Chapters PDF
com
https://textbookfull.com/product/introduction-to-gis-
programming-and-fundamentals-with-python-and-arcgis-1st-
edition-chaowei-yang/
OR CLICK BUTTON
DOWNLOAD NOW
https://textbookfull.com/product/introduction-to-scientific-
programming-with-python-joakim-sundnes/
textboxfull.com
https://textbookfull.com/product/introduction-to-computation-and-
programming-using-python-with-application-to-understanding-data-
guttag/
textboxfull.com
https://textbookfull.com/product/discovering-gis-and-arcgis-
pro-3e-3rd-edition-bradley-shellito/
textboxfull.com
Programming For Computations - Python: A Gentle
Introduction To Numerical Simulations With Python 3.6
Svein Linge
https://textbookfull.com/product/programming-for-computations-python-
a-gentle-introduction-to-numerical-simulations-with-python-3-6-svein-
linge/
textboxfull.com
https://textbookfull.com/product/bite-size-python-an-introduction-to-
python-programming-1st-edition-april-speight/
textboxfull.com
https://textbookfull.com/product/introduction-to-computing-and-
programming-in-python-global-edition-mark-j-guzdial/
textboxfull.com
Introduction to GIS
Programming and
Fundamentals with Python
and ArcGIS®
Introduction to GIS
Programming and
Fundamentals with Python
and ArcGIS®
Chaowei Yang
With the collaboration of
Manzhu Yu
Qunying Huang
Zhenlong Li
Min Sun
Kai Liu
Yongyao Jiang
Jizhe Xia
Fei Hu
CRC Press
Taylor & Francis Group
6000 Broken Sound Parkway NW, Suite 300
Boca Raton, FL 33487-2742
© 2017 by Taylor & Francis Group, LLC
CRC Press is an imprint of Taylor & Francis Group, an Informa business
No claim to original U.S. Government works
Printed on acid-free paper
International Standard Book Number-13: 978-1-4665-1008-1 (Hardback)
This book contains information obtained from authentic and highly regarded
sources. Reasonable efforts have been made to publish reliable data and
information, but the author and publisher cannot assume responsibility for the
validity of all materials or the consequences of their use. The authors and
publishers have attempted to trace the copyright holders of all material
reproduced in this publication and apologize to copyright holders if permission to
publish in this form has not been obtained. If any copyright material has not been
acknowledged please write and let us know so we may rectify in any future
reprint.
Except as permitted under U.S. Copyright Law, no part of this book may be
reprinted, reproduced, transmitted, or utilized in any form by any electronic,
mechanical, or other means, now known or hereafter invented, including
photocopying, microfilming, and recording, or in any information storage or
retrieval system, without written permission from the publishers.
For permission to photocopy or use material electronically from this work, please
access www.copyright.com (http://www.copyright.com/) or contact the Copyright
Clearance Center, Inc. (CCC), 222 Rosewood Drive, Danvers, MA 01923, 978-750-
8400. CCC is a not-for-profit organization that provides licenses and registration
for a variety of users. For organizations that have been granted a photocopy
license by the CCC, a separate system of payment has been arranged.
Trademark Notice: Product or corporate names may be trademarks or
registered trademarks, and are used only for identification and explanation without
intent to infringe.
Preface
Acknowledgments
Editor
Contributors
Section I Overview
1. Introduction
1.1 Computer Hardware and Software
1.2 GIS and Programming
1.3 Python
1.4 Class and Object
1.5 GIS Data Models
1.6 UML
1.7 Hands-On Experience with Python
1.8 Chapter Summary
Problems
2. Object-Oriented Programming
2.1 Programming Language and Python
2.2 Class and Object
2.2.1 Defining Classes
2.2.2 Object Generation
2.2.3 Attributes
2.2.4 Inheritance
2.2.5 Composition
2.3 Point, Polyline, and Polygon
2.4 Hands-On Experience with Python
2.5 Chapter Summary
Problems
3. Introduction to Python
3.1 Object-Oriented Support
3.2 Syntax
3.2.1 Case Sensitivity
3.2.2 Special Characters
3.2.3 Indentation
3.2.4 Keywords
3.2.5 Multiple Assignments
3.2.6 Namespace
3.2.7 Scope
3.3 Data Types
3.3.1 Basic Data Types
3.3.2 Composite Data Types
3.4 Miscellaneous
3.4.1 Variables
3.4.2 Code Style
3.5 Operators
3.6 Statements
3.7 Functions
3.8 Hands-On Experience with Python
3.9 Chapter Summary
Problems
6. Shapefile Handling
6.1 Binary Data Manipulation
6.2 Shapefile Introduction
6.3 Shapefile Structure and Interpretation
6.3.1 Main File Structure of a Shapefile
6.3.1.1 Main File Header
6.3.1.2 Feature Record
6.3.2 Index File Structure (.shx)
6.3.3 The .dbf File
6.4 General Programming Sequence for Handling
Shapefiles
6.5 Hands-On Experience with Mini-GIS
6.5.1 Visualize Polylines and Polygons
6.5.2 Interpret Polyline Shapefiles
6.6 Chapter Summary
Problems
9. ArcGIS Programming
9.1 ArcGIS Programming
9.2 Introduction to ArcPy Package
9.2.1 ArcPy Functions, Classes, and Modules
9.2.2 Programming with ArcPy in ArcMap
9.2.3 Programming with ArcPy in Python Window
outside ArcMap
9.2.4 Using Help Documents
9.3 Automating ArcTools with Python
9.4 Accessing and Editing Data with Cursors
9.4.1 SearchCursor
9.4.2 UpdateCursor
9.4.3 InsertCursor
9.4.4 NumPy
9.5 Describing and Listing Objects
9.5.1 Describe
9.5.2 List
9.6 Manipulating Complex Objects
9.7 Automating Map Production
9.8 Creating ArcTools from Scripts
9.9 Handling Errors and Messages
9.10 External Document and Video Resources
9.11 Implementing Spatial Relationship Calculations Using
ArcGIS
9.12 Summary
9.13 Assignment
References
Index
Preface
Hands-On Experience
As a practical text for developing programming skills, this book
makes every effort to ensure the content is as functional as possible.
For every introduced GIS fundamental principle, algorithm and
element, an example is explored as a hands-on experience using
Mini-GIS and/or ArcGIS with Python. This learning workflow helps
build a thorough understanding of the fundamentals and naturally
maps to the fundamentals and programming skills.
For system and open-source development, a step-by-step
development of a python-based Mini-GIS is presented. For
application development, ArcGIS is adopted for illustration.
The Mini-GIS is an open-source software developed for this text
and can be adopted for building other GIS applications. ArcGIS, a
commercial product from ESRI, is used to experience state-of-the-art
commercial software. For learning purpose, ArcGIS is available for
free from ESRI.
Online Materials
This book comes with the following online materials:
• Instructional slides for instructors using this text for classroom
education and professionals to assist in learning GIS
programming.
• Python codes for class exercises and hands-on experiences and
structured and labeled by chapter to code the chapter’s
sequence.
• Mini-GIS as an open-source package for learning the GIS
fundamentals and for exemplifying GIS principles and
algorithms.
• Answers to problems for instructors to check their solutions.
chapter xi.
The time for the meeting of the people to take measures for the
establishment of a government for the island of Fredonia, was fixed
for the day which followed the events narrated in the last chapter.
This meeting was looked forward to with intense interest, by all
parties. The men, who knew that there could be no peace or safety
in society, without government, regarded the event as likely to
decide whether the inhabitants of the island were to be happy or
miserable.
The women, who were perhaps not apt to reflect upon these
things, had also learned from their experience that a government,
establishing and enforcing laws, was indispensable to the quiet and
security of society: they saw that their own lives, their freedom, their
homes, were not secure, without the protection of law. Even the
children had found that government was necessary, and these as
well as the women, were now rejoicing at the prospect of having this
great blessing bestowed upon the little community of Fredonia.
The day for the meeting arrived, and the men of the island
assembled, agreeably to the appointment. First came the men of the
tent party, and then, those from the Outcast’s cave. The latter were
greeted by a shout of welcome, and mingling with the rest, a kind
shaking of hands took place between those, who so lately were
arrayed against each other in deadly conflict.
After a short time, Mr. Bonfils, being the oldest man of the
company, called the assembly to order, and he being chosen
chairman, went on to state the objects of the assembly, in the
following words:
“My dear friends; it has been the will of Providence to cast us
together upon this lonely, but beautiful island. It would seem that so
small a community, regulated by mutual respect and mutual good
will, might dwell together in peace and amity, without the restraints
of law, or the requisitions of government. But history has told us,
that in all lands, and in all ages, peace, order, justice, are only to be
secured by established laws, and the means of carrying them into
effect. There must be government, even in a family; there must be
some power to check error, to punish crime, to command obedience
to the rule of right. Where there is no government, there the violent,
the unjust, the selfish, have sway, and become tyrants over the rest
of the community. Our own unhappy experience teaches us this.
“Now we have met together, with a knowledge, a conviction of
these truths. We know, we feel, we see that law is necessary, and
that there must be a government to enforce it. Without this, there is
no peace, no security, no quiet fireside, no happy home, no pleasant
society. Without this, all is fear, anxiety, and anarchy.
“Let us then enter upon the duties of this occasion, with a proper
sense of the obligation that rests upon us; of the serious duty which
is imposed on every man present. We are about to decide questions
which are of vital interest, not only to each actor in this scene, but
to these wives and sisters and children, whom we see gathered at a
little distance, watching our proceedings, as if their very lives were
at stake.”
This speech was followed by a burst of applause; but soon a man
by the name of Maurice arose—one who had been a leading
supporter of Rogere—and addressed the assembly as follows:
“Mr. Chairman; it is well known that I am one of the persons who
have followed the opinions of that leader who lost his life in the
battle of the tents. I followed him from a conviction that his views
were right. The fact is, that I have seen so much selfishness in the
officers of the law, that I have learned to despise the law itself.
Perhaps, however, I have been wrong. I wish to ask two questions—
the first is this: Is not liberty a good thing? You will answer that it is.
It is admitted, all the world over, that liberty is one of the greatest
enjoyments of life. My second question then is—Why restrain liberty
by laws? Every law is a cord put around the limbs of liberty. If you
pass a law that I shall not steal, it is restraint of my freedom; it
limits my liberty; it takes away a part of that, which all agree is one
of the greatest benefits of life. And thus, as you proceed to pass one
law after another, do you not at last bind every member of society
by such a multiplied web of restraints, as to make him the slave of
law? And is not a member of a society where you have a system of
laws, like a fly in the hands of the spider, wound round and round by
a bondage that he cannot burst, and which only renders him a slave
of that power which has thus entangled him?”
When Maurice had done, Brusque arose, and spoke as follows:
“Mr. Chairman; I am happy that Mr. Maurice has thus stated a
difficulty which has arisen in my own mind: he has stated it fairly,
and it ought to be fairly answered. Liberty is certainly a good thing;
without it, man cannot enjoy the highest happiness of which he is
capable. All useless restraints of liberty are therefore wrong; all
unnecessary restraints of liberty are wrong. But the true state of the
case is this: we can enjoy no liberty, but by submitting to certain
restraints. It is true that every law is an abridgment of liberty; but it
is better to have some abridgment of it, than to lose it all.
“I wish to possess my life in safety; accordingly I submit to a law
which forbids murder: I wish to possess my property in security; and
therefore I submit to a law which forbids theft and violence: I wish
to possess my house without intrusion; I therefore submit to a law
which forbids one man to trespass upon the premises of another: I
wish to go and come, without hindrance, and without fear; I
therefore submit to a law which forbids highway robbery, and all
interference with a man’s pursuit of his lawful business.
“Now, if we reflect a little, we shall readily see that by submitting
to certain restraints, we do actually increase the amount of practical,
available, useful liberty. By submitting to laws, therefore, we get
more freedom than we lose. That this is the fact, may be easily
tested by observation. Go to any civilized country, where there is a
settled government and a complete system of laws, and you will
find, in general, that a man enjoys his house, his home, his lands,
his time, his thoughts, his property, without fear: whereas, if you go
to a savage land, where there is no government and no law, there
you will find your life, property, and liberty, exposed every moment
to destruction. Who, then, can fail to see that the very laws which
abridge liberty in some respects, actually increase the amount of
liberty enjoyed by the community.”
Maurice professed himself satisfied with this solution of his
difficulties; and the meeting proceeded to appoint a committee, to
go out and prepare some plan, to be submitted to the meeting. This
committee returned, and after a short space, brought in a resolution,
that Mr. Bonfils be for one year placed at the head of the little
community, with absolute power; and that, at the end of that period,
such plan of government as the people might decree, should be
established.
This resolution was adopted unanimously. The men threw up their
hats in joy, and the air rang with acclamations. The women and
children heard the cheerful sounds, and ran toward the men, who
met them half way. It was a scene of unmixed joy. Brusque and
Emilie met, and the tears of satisfaction fell down their cheeks.
François went to his aged mother, and even her dimmed eye was
lighted with pleasure at the joyful issue of the meeting.
We must now take leave of the island of Fredonia—at least for a
time—and whether we ever return to it, must depend upon the
wishes of our young readers. If they are anxious to see how the
people flourished under the reign of their aged old chief, and how
they proceeded in after years, perchance we may lift the curtain and
show them the scene that lies behind it. But I hope that our readers
have learnt, that not only men and women, but children, have an
interest in government, and therefore that it is a thing they should
try to understand.
The Tanrec.
There were once three little girls, who went to see a balloon.
When they got to the place, they saw that it was a great bag of silk,
with a netting put over it, and to this netting, a little car was
attached.
There were a great many people around the place, anxious to see
the balloon rise and sail away in the air. There were several persons
very busy in filling the balloon with what is called hydrogen gas,
which is a kind of air, and so light that it rises upward and carries the
balloon with it.
Pretty soon there was considerable gas in the balloon, and it then
began to ascend a little; in a short time it rose more, and, after a
few minutes, it seemed in such a hurry to get away that several men
were obliged to take hold of the net-work, and restrain it till all was
ready.
Now a man by the name of Lauriat, who had made the balloon,
was going up with it. When all was prepared, he got into the little
car, holding in his lap a cat fastened in a cage, with a thing like an
umbrella, attached to it. In a few moments Mr. Lauriat called out, “all
right!”—and the men let go of the net-work, and up went the
balloon, and up went Mr. Lauriat in the little car hanging beneath it!
It was a beautiful sight, and the people were so delighted, that
the air rang with acclamations. The three little girls, whom we shall
call History, Poetry, and Romance, were as much pleased as
anybody, and shouted, with their little voices, as loud as they could.
What made it all more pleasant, was that the people could see Mr.
Lauriat, who waved a little flag, as he ascended; and though it was
almost frightful to see a man so high in the air, yet he appeared
quite at his ease and very much gratified.
When the balloon had risen to a great height, so as to look only
about as large as my wig, Mr. Lauriat let the cat and the cage fall;
but the thing like an umbrella, called a parachute, kept it from
coming down very swiftly. It was a beautiful sight to see! At first the
cage and parachute were hardly visible, but they grew more and
more distinct, and at last they came nearer and nearer, and finally
dropped down upon a distant hill. Some boys ran to the place, and
behold, puss was in the cage, a good deal frightened, but as safe as
ever. There are very few cats that have had such a ride as this!
At last the balloon looked no bigger than a fly, and then it entered
a cloud and was seen no more. The company separated and went to
their homes, all talking of the balloon, and Mr. Lauriat, and puss, and
the parachute. Our three little girls also returned to their homes,
and, rushing to their mother, they were each so anxious to tell the
story, that neither could be understood. At last their mother said to
them, “My dear children, I must hear you, one at a time. Let us all
sit down, and History, who is the oldest; shall tell the story first.
Then Poetry shall tell it, and then Romance shall tell it.”
To this they all agreed, and History began as follows: “We
reached the place about four o’clock in the afternoon. There were
already many people present, but as the time advanced, others
came, and soon about two thousand people were there.
“The balloon was enclosed in a fence, made of boards, and none
but the workmen and Mr. Lauriat were permitted to enter the
enclosure. There were six large casks around, in which they made
the hydrogen gas; this was conducted to the balloon by means of
tubes.
“The balloon was a large bag of silk, about forty feet long and
eighty feet in circumference. When full of gas, it was shaped like a
bell-pear, the stem downwards. The silk was oiled, so as to retain
the gas, which is lighter than the air, and floats upward in it, as a
piece of wood does in water. The balloon was enclosed in a net-
work, and beneath, a little car, or boat, was attached to it, and in
this, Mr. Lauriat sat, when he ascended.
“As the gas was conducted to the balloon, the latter gradually
swelled out, and when it was full, the men who held it down, let go;
and it ascended with Mr. Lauriat, into the air. He was cheered by the
voices of the people, and he waved a little flag back and forth, in
return. It was a pleasing scene, in which fear for the airy sailor, and
admiration of his skill and courage, were mingled.
“Mr. Lauriat had taken up with him a cat, enclosed in a cage, and
to this cage a parachute was attached. When he had risen to the
height of about a thousand feet, he let the cage go, and it came
gently down like a snow-flake, falling at last on a distant hill. The cat
was taken up unhurt. The balloon gradually grew less and less to the
vision, and finally it disappeared in a thick cloud, upon which the
rays of the evening sun were now falling.”
Such was the account given of the scene by History; and now
Poetry began:
“Oh mother, it was beautiful! The balloon went up like a soap-
bubble, and it sailed along on the air like a bird. I could hardly
believe that it was not alive, it glided in the air so gently, and so
gracefully! And Mr. Lauriat, he looked so happy! Oh it was wonderful
to see a man so high in the air, and to see him so much at his ease!
I felt afraid for him, and yet the scene pleased me the more. I
wished to be with him, though I knew I should have been
frightened. And yet it seemed so pleasing to go up in the air, and
look down upon so many people, and to know that they were all
looking at you, and that so many hearts were beating for you, and
that so many were admiring you! It would be beautiful!
“And, mother, you know that the balloon glided up and away so
softly, that it seemed like a dream, fading from the memory. And at
last, when it was like a mere insect in the vast blue sky, it stole into
a cloud, and hid itself, and then I had a feeling of sadness. Can you
tell me why, mother?”
Here there was a pause, and the blue-eyed girl, stood for a
moment, as if expecting an answer. But Romance was impatient to
begin, and her dark eye, shaded by the long black lashes, seemed to
grow larger and brighter as she spoke thus:
“History has told you, mother, all the events that occurred, and
she has accurately described them. Poetry has painted the scene,
and made it clear and bright by comparisons. But I must tell you of
the thoughts and feelings it awakened in my breast, and of the fairy
world in which I seemed to be, while I looked on the balloon.
“When the balloon went up, it seemed as if I went with it, into a
new scene. I think I have dreamed something like it, in my sleep,
when my thoughts seemed like wings, and all around was fair and
heavenly. As the balloon ascended, I seemed to ascend also. I did
not, at the moment, think how strange it was, but I went on
fancying myself with the balloon, and riding upon the air, in that little
boat. And I thought of the vast blue space around, and the earth
beneath, and the heaven above, and I felt as if I was something like
an angel, gifted with the power of rising upward, and seeing earth,
and sky, and heaven, as others could not see them. And I felt a sort
of happiness I cannot express.
“Well, as the balloon sailed farther and farther upon the airy sea,
and as it grew less and less to the sight, like a ship that glides away
upon the ocean—I began to think of the realms to which it seemed
hastening. And at last, when it flew into the cloud, I did not dream
that it had disappeared. My eye was still bent upon the spot, and I
still fancied that I was with it, and that I was sailing on and on, upon
the blue deep, and among regions where the happy and the lovely
only dwell.”
When Romance had got to this point of her story, the mother
smiled, and History tittered aloud. Poetry, however, drew nearer, and
seemed entranced with the tale of the dark-eyed girl. But Romance
was dashed at the ridicule she had excited, and was silent.
Now I suppose some of my waggish young readers, some of the
roguish Paul Pries, will laugh at me, as History did at Romance; and
think me not a little ridiculous, for telling such a rigmarole tale as
this. But old Peter knows what he is about! He has an object in view;
and now, as Mr. Lauriat let the cat out of the car, he will “let the cat
out of the bag.”
My purpose is to teach the meaning of the three words, History,
Poetry, and Romance. History is a true record of events; and,
accordingly, the little girl whom we call History, tells the exact story
of the balloon. Poetry is a display of fanciful thoughts, and deals
much in comparison; and so, our little Poetry gives a fanciful
description of the scene, embellishing her tale by many illustrations.
Romance is a picture of fantastic and extraordinary scenes and
feelings; and our dark-haired maiden, who deals in it, sets forth the
fairy world of visions and sentiments that is reflected in her own
breast.
I suppose all my readers have heard of the Nine Muses,
goddesses of ancient Greece. One was called Clio, the muse of
history; one was Erato, the muse of poetry. And I have sometimes
fancied that the idea of these goddesses, might have originated
among the fanciful Greeks, from perceiving the different ways in
which different persons notice the same scenes; one being apt to
remark things soberly and accurately, like our Miss History; another
being apt to see them fancifully, like our Miss Poetry; and another
apt to weave a world of fiction out of them, like our Miss Romance.
The Zephyr.
Puzzles.
Portsmouth, Feb. 4, 1842.
Mr. Merry,—Sir: if you think the following worthy a place in your
valuable magazine, by inserting the same you will oblige a constant
reader.
I am a word of 18 letters.
I am composed of 16 letters.
My 2, 1, 8, is a portion of water.
My 2, 12, 4, 15, 16, 8, has been the ruin of thousands.
My 16, 1, 15, 10, 8, is the most contemptible of all animals.
My 6, 14, 4, 15, is the name of a once celebrated tragedian.
My 3, 8, 15, 15, is the name of a town not far from Boston.
My 11, 12, 1, 15, 5, 9, is the name of a great country.
My 3, 4, 6, 7, is a sheet of water.
My 11, 13, 12, 9, is one of the elements.
My 1, 13, 12, is another.
My 11, 3, 8, is an insect.
My 15, 13, 3, 7, is the name of a river justly celebrated in
ancient and modern history.
C. B. F.
Boston, February 1, 1842.
MARCH—A SONG.
THE WORDS AND MUSIC COMPOSED FOR MERRY’S MUSEUM.
V O L U M E I I I . — N o . 4 .
Montezuma.
chapter xv.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
textbookfull.com