I should probably change the titles of these posts as I’m guessing ESRI will be offering more MOOCs in the future, so this could get confusing. Week 4 was much better content wise, and provided the opportunity to really use some nice tools available in ArcGIS Online. I like the fact that case studies from various disciplines are being used, to show everyone (especially the newbies) how GIS can be applied no matter what your field is.
I have found that sometimes when the analysis is complete, the newly created layer will disappear from the web map, which leads the user to believe that the analysis has failed because it appears that nothing has been created. When running the same operation again, a “layer name already exists” error proves that the layer was in fact created, but was not added to the map. This leads to the cumbersome process of having to add that layer again manually. I have also found that searching to add layers often returns no results when the whole layer name is used, but will return results for a partial match e.g. typing in “Intersect LA Crimes_cindywilliams” returned nothing but “Intersect LA Crimes_” brought up everyone’s layers and I had to scroll through it to get to mine.
Last week I posted about creating a csv file containing coordinates projected on the fly. Seeing as I had to update the files as the projection information changed, I decided I might as well optimise my code. I managed to halve the amount of code and not write anything temporary to disk as the final output I want is non-spatial anyway.
Created on 22 Sep 2014
@author: Cindy Williams
Project coordinates on the fly and write to csv
arcpy.env.overwriteOutput = True
fld = r"C:\Some\Arb\Folder"
sr_cape = arcpy.SpatialReference(r"C:\Some\Arb\Folder\cape17.prj")
sr_mines = arcpy.SpatialReference(r"C:\Some\Arb\Folder\Schwarzeck17_mines.prj")
fields = ["Field3", "SHAPE@XY"]
x_constant = 89
y_constant = 2000018
# Specify topdown=True so that it does not process the created csvs
for root, dirnames, filenames in os.walk(fld, topdown=True):
for f in filenames:
print "Processing " + f
cur_csv = os.path.join(root, f)
lyr = "XY_Layer"
# Create XY Layer in the original CS
arcpy.management.MakeXYEventLayer(cur_csv, "Field1", "Field2", lyr, sr_cape)
print "\tCreated XY Event Layer"
# Output csv filename created from splitting current csv filename
final_csv = os.path.join(fld, "Schwarzeck17_" + f.rpartition(" "))
with open(final_csv, 'wb') as csvfile:
csvwriter = csv.writer(csvfile)
# Use a cursor to project the coordinates to the new CS
with arcpy.da.SearchCursor(lyr, fields, "#", sr_mines) as cursor:
for row in cursor:
# Apply the constant and write to csv
csvwriter.writerow([row - x_constant, row - y_constant, row])
print "Processed " + final_csv
# Clean up
print "Script complete."
This week we started the first “exercise” in spatial analysis. It was quite basic in terms of GIS analysis. What I found interesting was the availability of tools and functionality in ArcGIS Online. I remember when it launched and it was just a barebones web app that could show your map and layers you’ve uploaded…and that’s about it. Now I can see how “non-GIS” people could be “doing” GIS through this interface without even realising it.
Seeing as I am part of the Enterprise GIS team, this intrigues me and worries me at the same time. We are looking to integrate more with ArcGIS Online now that our GIS system architecture is being “officially” put into place, so my main reason for sticking with this MOOC is to learn more about the capabilities of AGO.
I started ESRI’s first MOOC today, “Going Places with Spatial Analysis” on Udemy. It looks very promising, and although I don’t really do analysis anymore, it will be interesting to complete this course and learn more about the capabilities of ArcGIS online, as I will need to understand more about it for my work.
I just wish there was a download button on the videos. Not everyone is in North America ESRI – it’s faster for me to download the videos and watch it offline than to stream it using my home uncapped account.