Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
  
 
Simple GIS Queries and Editing Attribute Tables in QGIS 
Spring 2011 
 
This demo describes what you would do after you’ve collected your field data using a survey 
form and also GPS locations. What you want to do is now add the data you collected to your 
GPS locations…. 
 
Note: This demo was developed using QGIS v 1.6 on a Windows machine.  
 
1. Set up project – Bring in raster images as “backgrounds” and save QGIS project.  
 
1. New project, Settings, Project Properties – you should be able to find “NAD83 / mass 
mainland” in the list of recently used coordinate reference systems.  
 
Enable on the fly CRS projection. 
 
2. Bring in the two raster files of the UMass campus 
a. 11429050.sid and 11579050.sid 
b. Check properties – as usual, for MassGIS data, it should be Projections, Lambert 
Conformal Conic, Mass Mainland, NAD83. If QGIS has a problem (layers don’t 
overlay) or “bombs” and has to close, it is probably because something you’ve set 
with projections is not right. 
 
3. Save project as “UMass_demo” in your work folder and quit out of QGIS.  
4. Open up work folder to review all the files that are in there. 
a. two sets of aerial photos (sid files and their associated projection files) 
b. “Umass demo” qgis project file 
 
2. Map the a GPS point layer using the “delimited text” technique and save as a shape file.   
 
c. Open up Samplepoints_demo.txt – point locations near the baseball diamond, 
and some data on robin and crow sightings; This is like what you did in Friday’s 
lab mapping GPS data using a text file 
d. Plugins, Delimited Text, Add delimited text layer 
e. Browse, Samplepointsdemo.txt 
f. Delimiter string “,” [comma], Set X field – “long” and Yfield – “lat.” Click 
“OK” 
g. This data is in Geographic Coordinates, NAD83 Datum. It will probably not 
overlay correctly – you need to set the layer properties to Geographic Projection 
and NAD83. Then it should overlay correctly (IF on the fly is set on, above) 
h. The points should line up by the UMass baseball field. Some are locations of 
geocache boxes I hid, and some are points I made up for more point location 
examples for this demo.  
i. Right-click – SAVE AS SHAPE FILE to store this permanently as a shape file 
layer. Store it in your project folder, and name it “UMass_demo_pts” 
 
IMPORTANT! This is the step where you can convert the GPS data from 
Geographic coordinates to the State Plane (Mass Mainland) projection so that it 
will be compatible with other MassGIS data. This is a good thing to do so that 
your system doesn’t have to always be doing that “projection on the fly…” 
 
j. You can now (right-click) and REMOVE the “samplepoints_demo” txt data from 
the QGIS table of contents, and add the new UMass_demo_pts shapefile. Check 
the projection properties of this new shapefile (right click, properties, General tab, 
specify CRS) 
 
k. Add the new shapefile to the table of contents (add vector option) 
 
3. Change the table of contents name to “Sample plots” and change point symbology to 
bright RED 
 
l. Right-click on umass-demo_pts, properties, general, Display name ‘Sample 
plots’ 
m. Symbology, scroll down to “fill options,” change to RED color. OK.  
 
4. Review the attributes in the attribute table.  
 
n. Right click, open attribute table to view the database associated with these sample 
plot locations 
 
5. Database Queries – one form of analysis 
 
We’ve worked all this time to get to this point – where we have a meaningful GIS layer 
and we can start to look at patterns in the data over geographic space.  
 
o. You might want to think about expected geographic patterns before you do a 
query… For example, might you expect to find cardinals in certain landcover 
types over another? (remember – this data is totally made up!) 
 
p. “Show me all the sampled points where cardinals were seen” 
q. Open attribute table 
r. Advanced 
s. Num_cardni > 0 
t. OK 
u. Returns 3 records 
v. Click “Show selected only” – to see the attribute records  
w. “unselect all” button to clear the selection 
 
3. Develop a map using “print composer” that shows the number of birds found in each 
sample location based on a database attribute 
x. For example, map the number of robins that were found in each plot… 
y. Right click sample plots layer, properties 
z. Symbology tab 
aa. Label – ‘Number of robins’. Change the fill color to yellow so the attribute labels 
(next) will be easily read.  
bb. ‘Area scale field’ 
cc. Choose num_robins 
dd.  Size – set to 3 – this sets the size of the symbol shape  
ee. Layer properties, “Labels” option. 
i. Field containing label: “num_robins” 
ii. Font size – 9 
ff. Create the map “print composer” 
i. File, New Print Composer 
ii.  Click the “Add New Map” button (the + with the vector layer). 
Drag and hold it to create a rectangle for the map display region. It will 
be at the scale that you are currently at.  
iii. Set paper size (if this was for a large map plotter, you would change the 
paper size to match the plotter you intend to print on. If this was a plotter 
at a copy shop, you’d have to check with them for plotter paper 
dimensions).  
iv.  Add a legend. 
v.  Add a scale bar. On the Item tab, specify “meters” in the “Unit 
Label” 
vi. Add a title: “Number of Robins Found on the UMass Campus.” Use the 
“add label” tool.  Change/specify text size of the label at “Item” 
tab. You will need to click on the edge of the label box to display the 
entire title.  
vii. You’d want to use  the same label tool to create other metadata on your 
map – such as the projection/datum, who made it, acknowledgements to 
MassGIS for data, etc.  
viii. You can use other options on the composer menu to highlight aspects of 
your map composition, such as the “add arrow” tool, add image tool (if 
you wanted to add a jpg image), etc.  
ix. If you want to create a .jpg of the map to bring into a word processing 
document, use the “export as image” button in the composer menu.  
x. Close the composer menu. 
xi. Turn the labels and “area scale field” off. The QGIS map screen should 
change back to the simple points displayed.   
gg. You can re-edit maps you create via the “Print composer” through the “composer 
manager” in the File menu of QGIS. Open up the composer for the map we just 
created. You’ll see the map with the scaled “dots” and labels is still there and 
saved.  
  
4. Display unique values – a layer showing “number of crows” 
hh. Add layer – bring in the “UMass_demo_pts.shp” file again.  
ii. Show points where crows were found 
jj. Right click, properties 
kk. Symbology tab 
ll. Legend type - Unique value 
mm. Classification field – num_crows 
nn. Classify 
oo. 5 different classes created.  
pp. Change colors to show lighter colors for smaller numbers and darker for the larger 
numbers 
qq. Click on the first “default” option and press “delete classes” to get rid of it.  
rr. Hit OK. You should see a map with the different colored dots for the various 
values of crows found.  
ss. You could create a new map composer and map for this “query.”  
 
5. Editing attribute data  
tt. Suppose now you realize something in the data you originally entered was 
incorrect and you want to change it.  
uu. Toggle editor 
vv. If it is a shape file, you should be able to edit specific cells in the data. 
ww. Select a row you want and you should see the point highlighted in the map 
behind it. 
xx. Edit the field of data you want to change. 
yy. Turn editor off (you will need to save the shapefile) 
zz. To clear the selection use the “unselect all” button in attribute table screen 
 
6. Adding other attributes later 
 
i. Sometimes you want to add new data to the different features later. In 
QGIS, to do this,  
ii. Open up the attribute table 
iii. Turn editing on (the pencil icon – “toggle editing mode” 
iv. Some new icons are now available. One is “new column” – a rectangle 
with a little yellow star in the bottom right corner. 
v. Add new column: “food source” 
vi. Enter data for each record – “y” or “n” 
vii. Close the attribute table. 
viii. Go back to your QGIS project and open the attribute table. Your new 
data should still be in there.