WUSTL-GIS-Programming-spring-2014 / classinfo

Class information including syllabus
The Unlicense
2 stars 13 forks source link

Assignment 4 #7

Closed blordcastillo closed 10 years ago

blordcastillo commented 10 years ago

Assignment 4 is posted. For data for this assignment, use the file geodatabase available as a zip file at https://www.dropbox.com/s/lcjodja7ix8oruh/Assignment4.gdb.zip

fbaum commented 10 years ago

The online help for CreateFeatureClass has this Note: "When you use a Template Feature Class its spatial reference is ignored." Also, the arcpy.da.InsertCursor function doesn't seem to support a "spatial_reference" argument (even though one help page says it does), so to set the spatial reference of the new feature class PublicSchools to the same as the schoolPublicDESE feature class (i.e., the template fc), I added a line like this before the call to arcpy.CreateFeatureclass_management:

descDESE = arcpy.Describe(u'schoolPublicDESE')

... and then used it in the existing line that creates the new feature class, like this:

arcpy.CreateFeatureclass_management(arcpy.env.workspace, u'PublicSchools',"POINT", u'schoolPublicDESE', spatial_reference=descDESE.spatialReference)

This should help prevent the "spatial reference" warning message when you try to add your populated PublicSchools feature class to an open ArcMap document.

Nancy-Cole commented 10 years ago

I think I got around the spatial reference problem by using these lines:

Use the Describe function to get the spatial reference of schoolPublicDESE, for use with a new feature class.

spatial_ref = arcpy.Describe(u'schoolPublicDESE').spatialReference

Create an empty feature class, PublicSchools, using schoolPublicDESE as a template.

arcpy.CreateFeatureclass_management(arcpy.env.workspace, u'PublicSchools',"POINT", u'schoolPublicDESE',"DISABLED","DISABLED",spatial_ref)

blordcastillo commented 10 years ago

Do not modify idToSchool. You can define the search cursor before the insert cursor if you want.

Nancy-Cole commented 10 years ago

There are eight St. Louis County schools whose CtyDist fields are erroneously coded without a leading "0", e.g. 96101 instead of 096101, and one school that is coded as 115 (St. Louis City) instead of 096 (St. Louis County). As a result, these 9 schools don't get "picked up" by my script for inclusion in the new feature class.

blordcastillo commented 10 years ago

Yes, those schools are outside the scope of what we have right now, as we would have to apply outside information to solve the problem.

In this case, you have your knowledge that the data is bad. But we could further deal with this by having a county boundary to test for schools with an incorrect county ID or a list of previous schools to update rather than rebuild the table from scratch.